@zzzen/pyright-internal 1.2.0-dev.20240728 → 1.2.0-dev.20240811
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/analysis.js +2 -2
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.js +1 -2
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +20 -21
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +8 -5
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.d.ts +0 -1
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +4 -1
- package/dist/analyzer/checker.js +371 -254
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/circularDependency.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +10 -10
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +17 -17
- package/dist/analyzer/codeFlowTypes.js +5 -5
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +1 -2
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/commentUtils.js +1 -2
- package/dist/analyzer/commentUtils.js.map +1 -1
- package/dist/analyzer/constraintSolution.d.ts +22 -0
- package/dist/analyzer/constraintSolution.js +77 -0
- package/dist/analyzer/constraintSolution.js.map +1 -0
- package/dist/analyzer/constraintSolver.d.ts +8 -5
- package/dist/analyzer/constraintSolver.js +427 -353
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constraintTracker.d.ts +45 -0
- package/dist/analyzer/constraintTracker.js +235 -0
- package/dist/analyzer/constraintTracker.js.map +1 -0
- package/dist/analyzer/constructorTransform.js +23 -23
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +1 -1
- package/dist/analyzer/constructors.js +71 -51
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +72 -58
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.js +11 -11
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +8 -9
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.d.ts +1 -1
- package/dist/analyzer/decorators.js +34 -30
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +2 -3
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/docStringUtils.js +2 -3
- package/dist/analyzer/docStringUtils.js.map +1 -1
- package/dist/analyzer/enums.js +17 -14
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.d.ts +2 -2
- package/dist/analyzer/functionTransform.js +2 -3
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +0 -1
- package/dist/analyzer/importResolver.js +5 -5
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +15 -15
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +2 -3
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.d.ts +1 -2
- package/dist/analyzer/operations.js +101 -79
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeReport.d.ts +3 -3
- package/dist/analyzer/packageTypeReport.js +2 -2
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +17 -13
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.d.ts +3 -3
- package/dist/analyzer/parameterUtils.js +23 -25
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +94 -92
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +2 -2
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +39 -41
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +5 -1
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.d.ts +3 -2
- package/dist/analyzer/properties.js +16 -18
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +3 -3
- package/dist/analyzer/protocols.js +58 -60
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pyTypedUtils.js +2 -3
- package/dist/analyzer/pyTypedUtils.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +6 -6
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js +5 -6
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +3 -0
- package/dist/analyzer/service.js +173 -103
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/serviceUtils.js +5 -5
- package/dist/analyzer/serviceUtils.js.map +1 -1
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +4 -5
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.js +5 -4
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/sourceMapperUtils.js +1 -2
- package/dist/analyzer/sourceMapperUtils.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +2 -3
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/symbolNameUtils.js +8 -9
- package/dist/analyzer/symbolNameUtils.js.map +1 -1
- package/dist/analyzer/symbolUtils.js +4 -5
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +5 -4
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +2 -2
- package/dist/analyzer/tuples.js +14 -14
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeComplexity.js +14 -7
- package/dist/analyzer/typeComplexity.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +2 -2
- package/dist/analyzer/typeDocStringUtils.js +34 -25
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +1021 -993
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +31 -13
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +1 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +72 -64
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +28 -26
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +36 -38
- package/dist/analyzer/typeUtils.js +465 -746
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.d.ts +2 -2
- package/dist/analyzer/typeWalker.js +10 -5
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +2 -2
- package/dist/analyzer/typedDicts.js +52 -52
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +41 -36
- package/dist/analyzer/types.js +178 -184
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +0 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +0 -1
- package/dist/backgroundThreadBase.js +7 -7
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +2 -2
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/cancellationUtils.js +9 -9
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +3 -3
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/collectionUtils.js +23 -23
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +19 -12
- package/dist/common/commandLineOptions.js +26 -9
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/commandUtils.js +1 -2
- package/dist/common/commandUtils.js.map +1 -1
- package/dist/common/configOptions.d.ts +2 -2
- package/dist/common/configOptions.js +30 -40
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +4 -4
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.js +21 -21
- package/dist/common/core.js.map +1 -1
- package/dist/common/crypto.js +1 -2
- package/dist/common/crypto.js.map +1 -1
- package/dist/common/debug.js +9 -10
- package/dist/common/debug.js.map +1 -1
- package/dist/common/deferred.js +3 -4
- package/dist/common/deferred.js.map +1 -1
- package/dist/common/diagnostic.js +3 -3
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/envVarUtils.js +2 -3
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js +4 -4
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +0 -2
- package/dist/common/fileWatcher.js +2 -2
- package/dist/common/fileWatcher.js.map +1 -1
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/logTracker.js +2 -2
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/lspUtils.d.ts +1 -1
- package/dist/common/lspUtils.js +3 -4
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/memUtils.js +2 -2
- package/dist/common/memUtils.js.map +1 -1
- package/dist/common/pathUtils.js +32 -32
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/positionUtils.js +7 -8
- package/dist/common/positionUtils.js.map +1 -1
- package/dist/common/progressReporter.js.map +1 -1
- package/dist/common/pythonVersion.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +0 -2
- package/dist/common/realFileSystem.js +2 -2
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +1 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/stringUtils.js +12 -13
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.js +13 -13
- package/dist/common/textRange.js.map +1 -1
- package/dist/common/textRangeCollection.js +2 -2
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/timing.js.map +1 -1
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js +3 -4
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +0 -1
- package/dist/common/uri/uriUtils.js +20 -20
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/uri/webUri.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +8 -9
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +2 -2
- package/dist/languageServerBase.js +5 -2
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +30 -29
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.js +4 -4
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +4 -4
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +4 -5
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +5 -5
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +3 -3
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +2 -2
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/dynamicFeature.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.js +6 -6
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/navigationUtils.js +3 -4
- package/dist/languageService/navigationUtils.js.map +1 -1
- package/dist/languageService/quickActions.js +1 -2
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +5 -5
- package/dist/languageService/tooltipUtils.js +31 -31
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +3 -0
- package/dist/localization/localize.js +7 -6
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +2 -1
- package/dist/nodeMain.js +1 -2
- package/dist/nodeMain.js.map +1 -1
- package/dist/nodeServer.js +2 -3
- package/dist/nodeServer.js.map +1 -1
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js +10 -11
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +8 -8
- package/dist/parser/parseNodes.js +5 -5
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +2 -2
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/unicode.js +468 -468
- package/dist/parser/unicode.js.map +1 -1
- package/dist/pprof/profiler.js +2 -3
- package/dist/pprof/profiler.js.map +1 -1
- package/dist/pyright.js +22 -23
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +0 -2
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +0 -2
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/cacheManager.test.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +13 -5
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/config.test.js +160 -24
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +1 -2
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourSlashRunner.test.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.classVariable.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.comment.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.class.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.for.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.method.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.dunderNew.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.enums.members.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.errorNodes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.excluded.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fstring.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.dunderNames.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.exactMatch.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.d.ts +0 -1
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.js.map +1 -1
- package/dist/tests/fourslash/completions.import.submodule.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inList.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.included.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.literals.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.localCode.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.importStub.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.property.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.override.stub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.parameters.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.params.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.parentFolder.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.parentFolders.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.plainText.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.private.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.property.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.self.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.triggers.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.typeAlias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.typeshed.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/completions.with.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.variable.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.async.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.builtinInheritedByBuiltin.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.builtinInheritedByUserCode.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.class.docString.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.classNoInit.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.stringFormat.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.parameter.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.formatted.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.import.django.view.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.import.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inferred.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.init.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.libStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.overloadedFunction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.slots.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.multipart.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.nameconflict.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.publicSymbols.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/import.wildcard.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/importnotresolved.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingModuleSource.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/noerrors.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/orderImports1.command.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/orderImports2.command.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.args.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.args.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.function.untitledFile.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.function.untitledFile.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.init.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.library.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.parens.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.parens.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.string.excluded.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/rename.string.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.cornercases.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.dunderNew.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.overload.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.simple.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/typeVerifier.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/typeVerifier.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +1 -2
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/runner.d.ts +0 -1
- package/dist/tests/harness/fourslash/runner.js +2 -3
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +7 -7
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +4 -5
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +7 -8
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/utils.d.ts +0 -2
- package/dist/tests/harness/utils.js +7 -7
- package/dist/tests/harness/utils.js.map +1 -1
- package/dist/tests/harness/vfs/factory.js +3 -3
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +0 -2
- package/dist/tests/harness/vfs/filesystem.js +2 -2
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +2 -2
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +1 -2
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +14 -14
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/lsp/webpack.testserver.config.d.ts +2 -2
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/serialization.test.js +1 -2
- package/dist/tests/serialization.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +5 -6
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.js +8 -9
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +7 -7
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +20 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +6 -2
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +3 -3
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typeEvaluator6.test.js +17 -9
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +4 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +4 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/workspaceFactory.js +3 -3
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -2
- package/dist/analyzer/typeVarContext.d.ts +0 -48
- package/dist/analyzer/typeVarContext.js +0 -288
- package/dist/analyzer/typeVarContext.js.map +0 -1
@@ -8,15 +8,112 @@
|
|
8
8
|
* Functions that operate on Type objects.
|
9
9
|
*/
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
11
|
-
exports.
|
12
|
-
exports.
|
13
|
-
exports.
|
11
|
+
exports.TypeVarTransformer = exports.UniqueSignatureTracker = exports.AssignTypeFlags = exports.ClassIteratorFlags = exports.MemberAccessFlags = void 0;
|
12
|
+
exports.isOptionalType = isOptionalType;
|
13
|
+
exports.isNoneInstance = isNoneInstance;
|
14
|
+
exports.isNoneTypeClass = isNoneTypeClass;
|
15
|
+
exports.removeNoneFromUnion = removeNoneFromUnion;
|
16
|
+
exports.isIncompleteUnknown = isIncompleteUnknown;
|
17
|
+
exports.isTypeVarSame = isTypeVarSame;
|
18
|
+
exports.makeInferenceContext = makeInferenceContext;
|
19
|
+
exports.mapSubtypes = mapSubtypes;
|
20
|
+
exports.mapSignatures = mapSignatures;
|
21
|
+
exports.cleanIncompleteUnknown = cleanIncompleteUnknown;
|
22
|
+
exports.sortTypes = sortTypes;
|
23
|
+
exports.doForEachSubtype = doForEachSubtype;
|
24
|
+
exports.someSubtypes = someSubtypes;
|
25
|
+
exports.allSubtypes = allSubtypes;
|
26
|
+
exports.doForEachSignature = doForEachSignature;
|
27
|
+
exports.areTypesSame = areTypesSame;
|
28
|
+
exports.preserveUnknown = preserveUnknown;
|
29
|
+
exports.isUnionableType = isUnionableType;
|
30
|
+
exports.derivesFromAnyOrUnknown = derivesFromAnyOrUnknown;
|
31
|
+
exports.getFullNameOfType = getFullNameOfType;
|
32
|
+
exports.addConditionToType = addConditionToType;
|
33
|
+
exports.getTypeCondition = getTypeCondition;
|
34
|
+
exports.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
|
35
|
+
exports.isTypeAliasRecursive = isTypeAliasRecursive;
|
36
|
+
exports.transformPossibleRecursiveTypeAlias = transformPossibleRecursiveTypeAlias;
|
37
|
+
exports.getTypeVarScopeId = getTypeVarScopeId;
|
38
|
+
exports.getTypeVarScopeIds = getTypeVarScopeIds;
|
39
|
+
exports.specializeWithDefaultTypeArgs = specializeWithDefaultTypeArgs;
|
40
|
+
exports.specializeWithUnknownTypeArgs = specializeWithUnknownTypeArgs;
|
41
|
+
exports.getUnknownForTypeVar = getUnknownForTypeVar;
|
42
|
+
exports.getUnknownForTypeVarTuple = getUnknownForTypeVarTuple;
|
43
|
+
exports.getUnknownTypeForCallable = getUnknownTypeForCallable;
|
44
|
+
exports.selfSpecializeClass = selfSpecializeClass;
|
45
|
+
exports.getSpecializedTupleType = getSpecializedTupleType;
|
46
|
+
exports.isLiteralType = isLiteralType;
|
47
|
+
exports.isLiteralTypeOrUnion = isLiteralTypeOrUnion;
|
48
|
+
exports.containsLiteralType = containsLiteralType;
|
49
|
+
exports.getLiteralTypeClassName = getLiteralTypeClassName;
|
50
|
+
exports.getUnionSubtypeCount = getUnionSubtypeCount;
|
51
|
+
exports.isEllipsisType = isEllipsisType;
|
52
|
+
exports.isProperty = isProperty;
|
53
|
+
exports.isCallableType = isCallableType;
|
54
|
+
exports.isDescriptorInstance = isDescriptorInstance;
|
55
|
+
exports.isMaybeDescriptorInstance = isMaybeDescriptorInstance;
|
56
|
+
exports.isTupleGradualForm = isTupleGradualForm;
|
57
|
+
exports.isTupleClass = isTupleClass;
|
58
|
+
exports.isUnboundedTupleClass = isUnboundedTupleClass;
|
59
|
+
exports.isTupleIndexUnambiguous = isTupleIndexUnambiguous;
|
60
|
+
exports.partiallySpecializeType = partiallySpecializeType;
|
61
|
+
exports.addSolutionForSelfType = addSolutionForSelfType;
|
62
|
+
exports.ensureSignaturesAreUnique = ensureSignaturesAreUnique;
|
63
|
+
exports.makeTypeVarsBound = makeTypeVarsBound;
|
64
|
+
exports.makeTypeVarsFree = makeTypeVarsFree;
|
65
|
+
exports.applySolvedTypeVars = applySolvedTypeVars;
|
66
|
+
exports.validateTypeVarDefault = validateTypeVarDefault;
|
67
|
+
exports.transformExpectedType = transformExpectedType;
|
68
|
+
exports.getProtocolSymbols = getProtocolSymbols;
|
69
|
+
exports.getProtocolSymbolsRecursive = getProtocolSymbolsRecursive;
|
70
|
+
exports.getContainerDepth = getContainerDepth;
|
71
|
+
exports.lookUpObjectMember = lookUpObjectMember;
|
72
|
+
exports.lookUpClassMember = lookUpClassMember;
|
73
|
+
exports.getClassMemberIterator = getClassMemberIterator;
|
74
|
+
exports.getClassIterator = getClassIterator;
|
75
|
+
exports.getClassFieldsRecursive = getClassFieldsRecursive;
|
76
|
+
exports.addTypeVarsToListIfUnique = addTypeVarsToListIfUnique;
|
77
|
+
exports.getTypeVarArgsRecursive = getTypeVarArgsRecursive;
|
78
|
+
exports.specializeClassType = specializeClassType;
|
79
|
+
exports.buildSolutionFromSpecializedClass = buildSolutionFromSpecializedClass;
|
80
|
+
exports.buildSolution = buildSolution;
|
81
|
+
exports.specializeForBaseClass = specializeForBaseClass;
|
82
|
+
exports.derivesFromStdlibClass = derivesFromStdlibClass;
|
83
|
+
exports.derivesFromClassRecursive = derivesFromClassRecursive;
|
84
|
+
exports.synthesizeTypeVarForSelfCls = synthesizeTypeVarForSelfCls;
|
85
|
+
exports.getDeclaredGeneratorReturnType = getDeclaredGeneratorReturnType;
|
86
|
+
exports.getGeneratorYieldType = getGeneratorYieldType;
|
87
|
+
exports.isInstantiableMetaclass = isInstantiableMetaclass;
|
88
|
+
exports.isMetaclassInstance = isMetaclassInstance;
|
89
|
+
exports.isEffectivelyInstantiable = isEffectivelyInstantiable;
|
90
|
+
exports.convertToInstance = convertToInstance;
|
91
|
+
exports.convertToInstantiable = convertToInstantiable;
|
92
|
+
exports.getMembersForClass = getMembersForClass;
|
93
|
+
exports.getMembersForModule = getMembersForModule;
|
94
|
+
exports.containsAnyRecursive = containsAnyRecursive;
|
95
|
+
exports.containsAnyOrUnknown = containsAnyOrUnknown;
|
96
|
+
exports.isPartlyUnknown = isPartlyUnknown;
|
97
|
+
exports.explodeGenericClass = explodeGenericClass;
|
98
|
+
exports.combineSameSizedTuples = combineSameSizedTuples;
|
99
|
+
exports.combineTupleTypeArgs = combineTupleTypeArgs;
|
100
|
+
exports.specializeTupleClass = specializeTupleClass;
|
101
|
+
exports.getGeneratorTypeArgs = getGeneratorTypeArgs;
|
102
|
+
exports.requiresTypeArgs = requiresTypeArgs;
|
103
|
+
exports.requiresSpecialization = requiresSpecialization;
|
104
|
+
exports.combineVariances = combineVariances;
|
105
|
+
exports.isVarianceOfTypeArgCompatible = isVarianceOfTypeArgCompatible;
|
106
|
+
exports.computeMroLinearization = computeMroLinearization;
|
107
|
+
exports.getDeclaringModulesForType = getDeclaringModulesForType;
|
108
|
+
exports.convertNodeToArg = convertNodeToArg;
|
109
|
+
exports.convertTypeToParamSpecValue = convertTypeToParamSpecValue;
|
110
|
+
exports.simplifyFunctionToParamSpec = simplifyFunctionToParamSpec;
|
14
111
|
const collectionUtils_1 = require("../common/collectionUtils");
|
15
112
|
const debug_1 = require("../common/debug");
|
113
|
+
const constraintSolution_1 = require("./constraintSolution");
|
16
114
|
const symbol_1 = require("./symbol");
|
17
115
|
const symbolUtils_1 = require("./symbolUtils");
|
18
116
|
const types_1 = require("./types");
|
19
|
-
const typeVarContext_1 = require("./typeVarContext");
|
20
117
|
const typeWalker_1 = require("./typeWalker");
|
21
118
|
var MemberAccessFlags;
|
22
119
|
(function (MemberAccessFlags) {
|
@@ -79,19 +176,19 @@ var AssignTypeFlags;
|
|
79
176
|
AssignTypeFlags[AssignTypeFlags["Default"] = 0] = "Default";
|
80
177
|
// Require invariance with respect to class matching? Normally
|
81
178
|
// subclasses are allowed.
|
82
|
-
AssignTypeFlags[AssignTypeFlags["
|
179
|
+
AssignTypeFlags[AssignTypeFlags["Invariant"] = 1] = "Invariant";
|
83
180
|
// The caller has swapped the source and dest types because
|
84
181
|
// the types are contravariant. Perform type var matching
|
85
182
|
// on dest type vars rather than source type var.
|
86
|
-
AssignTypeFlags[AssignTypeFlags["
|
183
|
+
AssignTypeFlags[AssignTypeFlags["Contravariant"] = 2] = "Contravariant";
|
87
184
|
// We're comparing type compatibility of two distinct recursive types.
|
88
185
|
// This has the potential of recursing infinitely. This flag allows us
|
89
186
|
// to detect the recursion after the first level of checking.
|
90
187
|
AssignTypeFlags[AssignTypeFlags["SkipRecursiveTypeCheck"] = 4] = "SkipRecursiveTypeCheck";
|
91
|
-
//
|
92
|
-
//
|
93
|
-
//
|
94
|
-
AssignTypeFlags[AssignTypeFlags["
|
188
|
+
// During TypeVar solving for a function call, this flag is set if
|
189
|
+
// this is the first of multiple passes. It adjusts certain heuristics
|
190
|
+
// for constraint solving.
|
191
|
+
AssignTypeFlags[AssignTypeFlags["ArgAssignmentFirstPass"] = 8] = "ArgAssignmentFirstPass";
|
95
192
|
// If the dest is not Any but the src is Any, treat it
|
96
193
|
// as incompatible. Also, treat all source TypeVars as their
|
97
194
|
// concrete counterparts. This option is used for validating
|
@@ -111,14 +208,11 @@ var AssignTypeFlags;
|
|
111
208
|
// because overloads can provide explicit type annotations for self
|
112
209
|
// or cls.
|
113
210
|
AssignTypeFlags[AssignTypeFlags["SkipSelfClsTypeCheck"] = 512] = "SkipSelfClsTypeCheck";
|
114
|
-
//
|
115
|
-
// do not generate an error. This is used for populating the
|
116
|
-
// typeVarContext when handling contravariant parameters in a callable.
|
117
|
-
AssignTypeFlags[AssignTypeFlags["IgnoreTypeVarScope"] = 1024] = "IgnoreTypeVarScope";
|
118
|
-
// We're initially populating the typeVarContext with an expected type,
|
211
|
+
// We're initially populating the constraints with an expected type,
|
119
212
|
// so TypeVars should match the specified type exactly rather than
|
120
|
-
// employing narrowing or widening
|
121
|
-
|
213
|
+
// employing narrowing or widening. The variance context determines
|
214
|
+
// whether the upper bound, lower bound, or both are established.
|
215
|
+
AssignTypeFlags[AssignTypeFlags["PopulateExpectedType"] = 2048] = "PopulateExpectedType";
|
122
216
|
// Used with PopulatingExpectedType, this flag indicates that a TypeVar
|
123
217
|
// constraint that is Unknown should be ignored.
|
124
218
|
AssignTypeFlags[AssignTypeFlags["SkipPopulateUnknownExpectedType"] = 4096] = "SkipPopulateUnknownExpectedType";
|
@@ -187,25 +281,20 @@ function isOptionalType(type) {
|
|
187
281
|
}
|
188
282
|
return false;
|
189
283
|
}
|
190
|
-
exports.isOptionalType = isOptionalType;
|
191
284
|
function isNoneInstance(type) {
|
192
285
|
return (0, types_1.isClassInstance)(type) && types_1.ClassType.isBuiltIn(type, 'NoneType');
|
193
286
|
}
|
194
|
-
exports.isNoneInstance = isNoneInstance;
|
195
287
|
function isNoneTypeClass(type) {
|
196
288
|
return (0, types_1.isInstantiableClass)(type) && types_1.ClassType.isBuiltIn(type, 'NoneType');
|
197
289
|
}
|
198
|
-
exports.isNoneTypeClass = isNoneTypeClass;
|
199
290
|
// If the type is a union, remove an "None" type from the union,
|
200
291
|
// returning only the known types.
|
201
292
|
function removeNoneFromUnion(type) {
|
202
293
|
return (0, types_1.removeFromUnion)(type, (t) => isNoneInstance(t));
|
203
294
|
}
|
204
|
-
exports.removeNoneFromUnion = removeNoneFromUnion;
|
205
295
|
function isIncompleteUnknown(type) {
|
206
296
|
return (0, types_1.isUnknown)(type) && type.priv.isIncomplete;
|
207
297
|
}
|
208
|
-
exports.isIncompleteUnknown = isIncompleteUnknown;
|
209
298
|
// Similar to isTypeSame except that type1 is a TypeVar and type2
|
210
299
|
// can be either a TypeVar of the same type or a union that includes
|
211
300
|
// conditional types associated with that bound TypeVar.
|
@@ -214,7 +303,7 @@ function isTypeVarSame(type1, type2) {
|
|
214
303
|
return true;
|
215
304
|
}
|
216
305
|
// If this isn't a bound TypeVar, return false.
|
217
|
-
if ((0, types_1.isParamSpec)(type1) || (0, types_1.isTypeVarTuple)(type1) || !
|
306
|
+
if ((0, types_1.isParamSpec)(type1) || (0, types_1.isTypeVarTuple)(type1) || !types_1.TypeVarType.hasBound(type1)) {
|
218
307
|
return false;
|
219
308
|
}
|
220
309
|
// If the second type isn't a union, return false.
|
@@ -236,14 +325,12 @@ function isTypeVarSame(type1, type2) {
|
|
236
325
|
});
|
237
326
|
return isCompatible;
|
238
327
|
}
|
239
|
-
exports.isTypeVarSame = isTypeVarSame;
|
240
328
|
function makeInferenceContext(expectedType, isTypeIncomplete, returnTypeOverride) {
|
241
329
|
if (!expectedType) {
|
242
330
|
return undefined;
|
243
331
|
}
|
244
332
|
return { expectedType, isTypeIncomplete, returnTypeOverride };
|
245
333
|
}
|
246
|
-
exports.makeInferenceContext = makeInferenceContext;
|
247
334
|
// Calls a callback for each subtype and combines the results
|
248
335
|
// into a final type. It performs no memory allocations if the
|
249
336
|
// transformed type is the same as the original.
|
@@ -267,17 +354,17 @@ function mapSubtypes(type, callback, options) {
|
|
267
354
|
for (i++; i < subtypes.length; i++) {
|
268
355
|
accumulateSubtype(callback(subtypes[i]));
|
269
356
|
}
|
270
|
-
|
357
|
+
let newType = (0, types_1.combineTypes)(typesToCombine, {
|
271
358
|
skipElideRedundantLiterals: options === null || options === void 0 ? void 0 : options.skipElideRedundantLiterals,
|
272
359
|
});
|
273
360
|
if (options === null || options === void 0 ? void 0 : options.retainTypeAlias) {
|
274
361
|
if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
|
275
|
-
types_1.TypeBase.
|
362
|
+
newType = types_1.TypeBase.cloneForTypeAlias(newType, type.props.typeAliasInfo);
|
276
363
|
}
|
277
364
|
}
|
278
365
|
else {
|
279
366
|
// Do our best to retain type aliases.
|
280
|
-
if (
|
367
|
+
if ((0, types_1.isUnion)(newType)) {
|
281
368
|
types_1.UnionType.addTypeAliasSource(newType, type);
|
282
369
|
}
|
283
370
|
}
|
@@ -292,7 +379,6 @@ function mapSubtypes(type, callback, options) {
|
|
292
379
|
}
|
293
380
|
return transformedSubtype;
|
294
381
|
}
|
295
|
-
exports.mapSubtypes = mapSubtypes;
|
296
382
|
// Iterates over each signature in a function or overload, allowing the
|
297
383
|
// caller to replace one or more signatures with new ones.
|
298
384
|
function mapSignatures(type, callback) {
|
@@ -301,7 +387,7 @@ function mapSignatures(type, callback) {
|
|
301
387
|
}
|
302
388
|
const newSignatures = [];
|
303
389
|
let changeMade = false;
|
304
|
-
types_1.
|
390
|
+
types_1.OverloadedType.getOverloads(type).forEach((overload, index) => {
|
305
391
|
const newOverload = callback(overload);
|
306
392
|
if (newOverload !== overload) {
|
307
393
|
changeMade = true;
|
@@ -314,12 +400,12 @@ function mapSignatures(type, callback) {
|
|
314
400
|
return undefined;
|
315
401
|
}
|
316
402
|
// Add the unmodified implementation if it's present.
|
317
|
-
const implementation = types_1.
|
318
|
-
|
319
|
-
|
403
|
+
const implementation = types_1.OverloadedType.getImplementation(type);
|
404
|
+
let newImplementation = implementation;
|
405
|
+
if (implementation && (0, types_1.isFunction)(implementation)) {
|
406
|
+
newImplementation = callback(implementation);
|
320
407
|
if (newImplementation) {
|
321
408
|
changeMade = true;
|
322
|
-
newSignatures.push(newImplementation);
|
323
409
|
}
|
324
410
|
}
|
325
411
|
if (!changeMade) {
|
@@ -328,9 +414,8 @@ function mapSignatures(type, callback) {
|
|
328
414
|
if (newSignatures.length === 1) {
|
329
415
|
return newSignatures[0];
|
330
416
|
}
|
331
|
-
return types_1.
|
417
|
+
return types_1.OverloadedType.create(newSignatures, newImplementation);
|
332
418
|
}
|
333
|
-
exports.mapSignatures = mapSignatures;
|
334
419
|
// The code flow engine uses a special form of the UnknownType (with the
|
335
420
|
// isIncomplete flag set) to distinguish between an unknown that was generated
|
336
421
|
// in a loop because it was temporarily incomplete versus an unknown that is
|
@@ -384,14 +469,12 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
|
|
384
469
|
// If we eliminated everything, don't return a Never.
|
385
470
|
return (0, types_1.isNever)(result) ? type : result;
|
386
471
|
}
|
387
|
-
exports.cleanIncompleteUnknown = cleanIncompleteUnknown;
|
388
472
|
// Sorts types into a deterministic order.
|
389
473
|
function sortTypes(types) {
|
390
474
|
return types.slice(0).sort((a, b) => {
|
391
475
|
return compareTypes(a, b);
|
392
476
|
});
|
393
477
|
}
|
394
|
-
exports.sortTypes = sortTypes;
|
395
478
|
function compareTypes(a, b, recursionCount = 0) {
|
396
479
|
var _a, _b;
|
397
480
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
@@ -422,7 +505,7 @@ function compareTypes(a, b, recursionCount = 0) {
|
|
422
505
|
if (aParam.category !== bParam.category) {
|
423
506
|
return bParam.category - aParam.category;
|
424
507
|
}
|
425
|
-
const typeComparison = compareTypes(types_1.FunctionType.
|
508
|
+
const typeComparison = compareTypes(types_1.FunctionType.getParamType(a, i), types_1.FunctionType.getParamType(bFunc, i));
|
426
509
|
if (typeComparison !== 0) {
|
427
510
|
return typeComparison;
|
428
511
|
}
|
@@ -441,15 +524,17 @@ function compareTypes(a, b, recursionCount = 0) {
|
|
441
524
|
}
|
442
525
|
return 0;
|
443
526
|
}
|
444
|
-
case 5 /* TypeCategory.
|
527
|
+
case 5 /* TypeCategory.Overloaded */: {
|
445
528
|
const bOver = b;
|
446
|
-
const
|
447
|
-
const
|
529
|
+
const aOverloads = types_1.OverloadedType.getOverloads(a);
|
530
|
+
const bOverloads = types_1.OverloadedType.getOverloads(bOver);
|
531
|
+
const aOverloadCount = aOverloads.length;
|
532
|
+
const bOverloadCount = bOverloads.length;
|
448
533
|
if (aOverloadCount !== bOverloadCount) {
|
449
534
|
return bOverloadCount - aOverloadCount;
|
450
535
|
}
|
451
536
|
for (let i = 0; i < aOverloadCount; i++) {
|
452
|
-
const typeComparison = compareTypes(
|
537
|
+
const typeComparison = compareTypes(aOverloads[i], bOverloads[i]);
|
453
538
|
if (typeComparison !== 0) {
|
454
539
|
return typeComparison;
|
455
540
|
}
|
@@ -541,7 +626,6 @@ function doForEachSubtype(type, callback, sortSubtypes = false) {
|
|
541
626
|
callback(type, 0, [type]);
|
542
627
|
}
|
543
628
|
}
|
544
|
-
exports.doForEachSubtype = doForEachSubtype;
|
545
629
|
function someSubtypes(type, callback) {
|
546
630
|
if ((0, types_1.isUnion)(type)) {
|
547
631
|
return type.priv.subtypes.some((subtype) => {
|
@@ -552,7 +636,6 @@ function someSubtypes(type, callback) {
|
|
552
636
|
return callback(type);
|
553
637
|
}
|
554
638
|
}
|
555
|
-
exports.someSubtypes = someSubtypes;
|
556
639
|
function allSubtypes(type, callback) {
|
557
640
|
if ((0, types_1.isUnion)(type)) {
|
558
641
|
return type.priv.subtypes.every((subtype) => {
|
@@ -563,18 +646,16 @@ function allSubtypes(type, callback) {
|
|
563
646
|
return callback(type);
|
564
647
|
}
|
565
648
|
}
|
566
|
-
exports.allSubtypes = allSubtypes;
|
567
649
|
function doForEachSignature(type, callback) {
|
568
650
|
if ((0, types_1.isFunction)(type)) {
|
569
651
|
callback(type, 0);
|
570
652
|
}
|
571
653
|
else {
|
572
|
-
types_1.
|
654
|
+
types_1.OverloadedType.getOverloads(type).forEach((overload, index) => {
|
573
655
|
callback(overload, index);
|
574
656
|
});
|
575
657
|
}
|
576
658
|
}
|
577
|
-
exports.doForEachSignature = doForEachSignature;
|
578
659
|
// Determines if all of the types in the array are the same.
|
579
660
|
function areTypesSame(types, options) {
|
580
661
|
if (types.length < 2) {
|
@@ -587,7 +668,6 @@ function areTypesSame(types, options) {
|
|
587
668
|
}
|
588
669
|
return true;
|
589
670
|
}
|
590
|
-
exports.areTypesSame = areTypesSame;
|
591
671
|
// If either type is "Unknown" (versus Any), propagate the Unknown. Preserve
|
592
672
|
// the incomplete flag on the unknown if present. The caller should verify that
|
593
673
|
// one or the other type is Unknown or Any.
|
@@ -605,7 +685,6 @@ function preserveUnknown(type1, type2) {
|
|
605
685
|
return types_1.AnyType.create();
|
606
686
|
}
|
607
687
|
}
|
608
|
-
exports.preserveUnknown = preserveUnknown;
|
609
688
|
// Determines whether the specified type is a type that can be
|
610
689
|
// combined with other types for a union.
|
611
690
|
function isUnionableType(subtypes) {
|
@@ -619,7 +698,6 @@ function isUnionableType(subtypes) {
|
|
619
698
|
// be definitively instantiable (not an instance).
|
620
699
|
return (typeFlags & 1 /* TypeFlags.Instantiable */) !== 0 && (typeFlags & 2 /* TypeFlags.Instance */) === 0;
|
621
700
|
}
|
622
|
-
exports.isUnionableType = isUnionableType;
|
623
701
|
function derivesFromAnyOrUnknown(type) {
|
624
702
|
let anyOrUnknown = false;
|
625
703
|
doForEachSubtype(type, (subtype) => {
|
@@ -639,7 +717,6 @@ function derivesFromAnyOrUnknown(type) {
|
|
639
717
|
});
|
640
718
|
return anyOrUnknown;
|
641
719
|
}
|
642
|
-
exports.derivesFromAnyOrUnknown = derivesFromAnyOrUnknown;
|
643
720
|
function getFullNameOfType(type) {
|
644
721
|
var _a, _b;
|
645
722
|
if ((_b = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.fullName) {
|
@@ -655,19 +732,26 @@ function getFullNameOfType(type) {
|
|
655
732
|
return type.shared.fullName;
|
656
733
|
case 7 /* TypeCategory.Module */:
|
657
734
|
return type.priv.moduleName;
|
658
|
-
case 5 /* TypeCategory.
|
659
|
-
|
735
|
+
case 5 /* TypeCategory.Overloaded */: {
|
736
|
+
const overloads = types_1.OverloadedType.getOverloads(type);
|
737
|
+
if (overloads.length > 0) {
|
738
|
+
return overloads[0].shared.fullName;
|
739
|
+
}
|
740
|
+
const impl = types_1.OverloadedType.getImplementation(type);
|
741
|
+
if (impl && (0, types_1.isFunction)(impl)) {
|
742
|
+
return impl.shared.fullName;
|
743
|
+
}
|
744
|
+
}
|
660
745
|
}
|
661
746
|
return undefined;
|
662
747
|
}
|
663
|
-
exports.getFullNameOfType = getFullNameOfType;
|
664
748
|
function addConditionToType(type, condition, skipSelfCondition = false) {
|
665
749
|
var _a, _b;
|
666
750
|
if (!condition) {
|
667
751
|
return type;
|
668
752
|
}
|
669
753
|
if (skipSelfCondition) {
|
670
|
-
condition = condition.filter((c) => !c.typeVar
|
754
|
+
condition = condition.filter((c) => !types_1.TypeVarType.isSelf(c.typeVar));
|
671
755
|
if (condition.length === 0) {
|
672
756
|
return type;
|
673
757
|
}
|
@@ -682,15 +766,14 @@ function addConditionToType(type, condition, skipSelfCondition = false) {
|
|
682
766
|
return type;
|
683
767
|
case 4 /* TypeCategory.Function */:
|
684
768
|
return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition, condition));
|
685
|
-
case 5 /* TypeCategory.
|
686
|
-
return types_1.
|
769
|
+
case 5 /* TypeCategory.Overloaded */:
|
770
|
+
return types_1.OverloadedType.create(types_1.OverloadedType.getOverloads(type).map((t) => addConditionToType(t, condition)));
|
687
771
|
case 6 /* TypeCategory.Class */:
|
688
772
|
return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine((_b = type.props) === null || _b === void 0 ? void 0 : _b.condition, condition));
|
689
773
|
case 8 /* TypeCategory.Union */:
|
690
774
|
return (0, types_1.combineTypes)(type.priv.subtypes.map((t) => addConditionToType(t, condition)));
|
691
775
|
}
|
692
776
|
}
|
693
|
-
exports.addConditionToType = addConditionToType;
|
694
777
|
function getTypeCondition(type) {
|
695
778
|
var _a;
|
696
779
|
switch (type.category) {
|
@@ -700,7 +783,7 @@ function getTypeCondition(type) {
|
|
700
783
|
case 3 /* TypeCategory.Never */:
|
701
784
|
case 7 /* TypeCategory.Module */:
|
702
785
|
case 9 /* TypeCategory.TypeVar */:
|
703
|
-
case 5 /* TypeCategory.
|
786
|
+
case 5 /* TypeCategory.Overloaded */:
|
704
787
|
case 8 /* TypeCategory.Union */:
|
705
788
|
return undefined;
|
706
789
|
case 6 /* TypeCategory.Class */:
|
@@ -708,13 +791,11 @@ function getTypeCondition(type) {
|
|
708
791
|
return (_a = type.props) === null || _a === void 0 ? void 0 : _a.condition;
|
709
792
|
}
|
710
793
|
}
|
711
|
-
exports.getTypeCondition = getTypeCondition;
|
712
794
|
// Indicates whether the specified type is a recursive type alias
|
713
795
|
// placeholder that has not yet been resolved.
|
714
796
|
function isTypeAliasPlaceholder(type) {
|
715
797
|
return (0, types_1.isTypeVar)(type) && types_1.TypeVarType.isTypeAliasPlaceholder(type);
|
716
798
|
}
|
717
|
-
exports.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
|
718
799
|
// Determines whether the type alias placeholder is used directly
|
719
800
|
// within the specified type. It's OK if it's used indirectly as
|
720
801
|
// a type argument.
|
@@ -733,7 +814,6 @@ function isTypeAliasRecursive(typeAliasPlaceholder, type) {
|
|
733
814
|
return ((0, types_1.findSubtype)(type, (subtype) => (0, types_1.isTypeVar)(subtype) && subtype.shared === typeAliasPlaceholder.shared) !==
|
734
815
|
undefined);
|
735
816
|
}
|
736
|
-
exports.isTypeAliasRecursive = isTypeAliasRecursive;
|
737
817
|
function transformPossibleRecursiveTypeAlias(type) {
|
738
818
|
var _a, _b;
|
739
819
|
if (type) {
|
@@ -745,21 +825,20 @@ function transformPossibleRecursiveTypeAlias(type) {
|
|
745
825
|
if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) || !type.shared.recursiveAlias.typeParams) {
|
746
826
|
return unspecializedType;
|
747
827
|
}
|
748
|
-
const
|
749
|
-
return applySolvedTypeVars(unspecializedType,
|
828
|
+
const solution = buildSolution(type.shared.recursiveAlias.typeParams, aliasInfo.typeArgs);
|
829
|
+
return applySolvedTypeVars(unspecializedType, solution);
|
750
830
|
}
|
751
831
|
if ((0, types_1.isUnion)(type) && type.priv.includesRecursiveTypeAlias) {
|
752
832
|
let newType = mapSubtypes(type, (subtype) => transformPossibleRecursiveTypeAlias(subtype));
|
753
833
|
if (newType !== type && aliasInfo) {
|
754
834
|
// Copy the type alias information if present.
|
755
|
-
newType = types_1.TypeBase.cloneForTypeAlias(newType, aliasInfo
|
835
|
+
newType = types_1.TypeBase.cloneForTypeAlias(newType, aliasInfo);
|
756
836
|
}
|
757
837
|
return newType;
|
758
838
|
}
|
759
839
|
}
|
760
840
|
return type;
|
761
841
|
}
|
762
|
-
exports.transformPossibleRecursiveTypeAlias = transformPossibleRecursiveTypeAlias;
|
763
842
|
function getTypeVarScopeId(type) {
|
764
843
|
if ((0, types_1.isClass)(type)) {
|
765
844
|
return type.shared.typeVarScopeId;
|
@@ -772,7 +851,6 @@ function getTypeVarScopeId(type) {
|
|
772
851
|
}
|
773
852
|
return undefined;
|
774
853
|
}
|
775
|
-
exports.getTypeVarScopeId = getTypeVarScopeId;
|
776
854
|
// This is similar to getTypeVarScopeId except that it includes
|
777
855
|
// the secondary scope IDs for functions.
|
778
856
|
function getTypeVarScopeIds(type) {
|
@@ -785,13 +863,9 @@ function getTypeVarScopeIds(type) {
|
|
785
863
|
if (type.priv.constructorTypeVarScopeId) {
|
786
864
|
scopeIds.push(type.priv.constructorTypeVarScopeId);
|
787
865
|
}
|
788
|
-
if (type.priv.higherOrderTypeVarScopeIds) {
|
789
|
-
scopeIds.push(...type.priv.higherOrderTypeVarScopeIds);
|
790
|
-
}
|
791
866
|
}
|
792
867
|
return scopeIds;
|
793
868
|
}
|
794
|
-
exports.getTypeVarScopeIds = getTypeVarScopeIds;
|
795
869
|
// If the class type is generic and does not already have type arguments
|
796
870
|
// specified, specialize it with default type arguments (Unknown or the
|
797
871
|
// default type if provided).
|
@@ -803,7 +877,6 @@ function specializeWithDefaultTypeArgs(type) {
|
|
803
877
|
/* isTypeArgExplicit */ false,
|
804
878
|
/* includeSubclasses */ type.priv.includeSubclasses);
|
805
879
|
}
|
806
|
-
exports.specializeWithDefaultTypeArgs = specializeWithDefaultTypeArgs;
|
807
880
|
// Specializes the class with "Unknown" type args (or the equivalent for ParamSpecs
|
808
881
|
// or TypeVarTuples).
|
809
882
|
function specializeWithUnknownTypeArgs(type, tupleClassType) {
|
@@ -818,7 +891,6 @@ function specializeWithUnknownTypeArgs(type, tupleClassType) {
|
|
818
891
|
/* isTypeArgExplicit */ false,
|
819
892
|
/* includeSubclasses */ type.priv.includeSubclasses);
|
820
893
|
}
|
821
|
-
exports.specializeWithUnknownTypeArgs = specializeWithUnknownTypeArgs;
|
822
894
|
// Returns "Unknown" for simple TypeVars or the equivalent for a ParamSpec.
|
823
895
|
function getUnknownForTypeVar(typeVar, tupleClassType) {
|
824
896
|
if ((0, types_1.isParamSpec)(typeVar)) {
|
@@ -829,14 +901,12 @@ function getUnknownForTypeVar(typeVar, tupleClassType) {
|
|
829
901
|
}
|
830
902
|
return types_1.UnknownType.create();
|
831
903
|
}
|
832
|
-
exports.getUnknownForTypeVar = getUnknownForTypeVar;
|
833
904
|
function getUnknownForTypeVarTuple(tupleClassType) {
|
834
905
|
(0, debug_1.assert)((0, types_1.isInstantiableClass)(tupleClassType) && types_1.ClassType.isBuiltIn(tupleClassType, 'tuple'));
|
835
906
|
return types_1.ClassType.cloneAsInstance(specializeTupleClass(tupleClassType, [{ type: types_1.UnknownType.create(), isUnbounded: true }],
|
836
907
|
/* isTypeArgExplicit */ true,
|
837
908
|
/* isUnpackedTuple */ true));
|
838
909
|
}
|
839
|
-
exports.getUnknownForTypeVarTuple = getUnknownForTypeVarTuple;
|
840
910
|
// Returns the equivalent of "Callable[..., Unknown]".
|
841
911
|
function getUnknownTypeForCallable() {
|
842
912
|
const newFunction = types_1.FunctionType.createSynthesizedInstance('', 32768 /* FunctionTypeFlags.GradualCallableForm */);
|
@@ -844,7 +914,6 @@ function getUnknownTypeForCallable() {
|
|
844
914
|
newFunction.shared.declaredReturnType = types_1.UnknownType.create();
|
845
915
|
return newFunction;
|
846
916
|
}
|
847
|
-
exports.getUnknownTypeForCallable = getUnknownTypeForCallable;
|
848
917
|
// If the class is generic and not already specialized, this function
|
849
918
|
// "self specializes" the class, filling in its own type parameters
|
850
919
|
// as type arguments.
|
@@ -856,11 +925,10 @@ function selfSpecializeClass(type, options) {
|
|
856
925
|
return type;
|
857
926
|
}
|
858
927
|
const typeParams = type.shared.typeParams.map((typeParam) => {
|
859
|
-
return (options === null || options === void 0 ? void 0 : options.
|
928
|
+
return (options === null || options === void 0 ? void 0 : options.useBoundTypeVars) ? types_1.TypeVarType.cloneAsBound(typeParam) : typeParam;
|
860
929
|
});
|
861
930
|
return types_1.ClassType.specialize(type, typeParams);
|
862
931
|
}
|
863
|
-
exports.selfSpecializeClass = selfSpecializeClass;
|
864
932
|
// Determines whether the type derives from tuple. If so, it returns
|
865
933
|
// the specialized tuple type.
|
866
934
|
function getSpecializedTupleType(type) {
|
@@ -883,14 +951,12 @@ function getSpecializedTupleType(type) {
|
|
883
951
|
if (types_1.ClassType.isSameGenericClass(classType, tupleClass)) {
|
884
952
|
return classType;
|
885
953
|
}
|
886
|
-
const
|
887
|
-
return applySolvedTypeVars(tupleClass,
|
954
|
+
const solution = buildSolutionFromSpecializedClass(classType);
|
955
|
+
return applySolvedTypeVars(tupleClass, solution);
|
888
956
|
}
|
889
|
-
exports.getSpecializedTupleType = getSpecializedTupleType;
|
890
957
|
function isLiteralType(type) {
|
891
958
|
return types_1.TypeBase.isInstance(type) && type.priv.literalValue !== undefined;
|
892
959
|
}
|
893
|
-
exports.isLiteralType = isLiteralType;
|
894
960
|
function isLiteralTypeOrUnion(type, allowNone = false) {
|
895
961
|
if ((0, types_1.isClassInstance)(type)) {
|
896
962
|
if (allowNone && isNoneInstance(type)) {
|
@@ -911,7 +977,6 @@ function isLiteralTypeOrUnion(type, allowNone = false) {
|
|
911
977
|
}
|
912
978
|
return false;
|
913
979
|
}
|
914
|
-
exports.isLiteralTypeOrUnion = isLiteralTypeOrUnion;
|
915
980
|
function containsLiteralType(type, includeTypeArgs = false) {
|
916
981
|
class ContainsLiteralTypeWalker extends typeWalker_1.TypeWalker {
|
917
982
|
constructor(_includeTypeArgs) {
|
@@ -935,7 +1000,6 @@ function containsLiteralType(type, includeTypeArgs = false) {
|
|
935
1000
|
walker.walk(type);
|
936
1001
|
return walker.foundLiteral;
|
937
1002
|
}
|
938
|
-
exports.containsLiteralType = containsLiteralType;
|
939
1003
|
// If all of the subtypes are literals with the same built-in class (e.g.
|
940
1004
|
// all 'int' or all 'str'), this function returns the name of that type. If
|
941
1005
|
// some of the subtypes are not literals or the literal classes don't match,
|
@@ -963,24 +1027,20 @@ function getLiteralTypeClassName(type) {
|
|
963
1027
|
}
|
964
1028
|
return undefined;
|
965
1029
|
}
|
966
|
-
exports.getLiteralTypeClassName = getLiteralTypeClassName;
|
967
1030
|
function getUnionSubtypeCount(type) {
|
968
1031
|
if ((0, types_1.isUnion)(type)) {
|
969
1032
|
return type.priv.subtypes.length;
|
970
1033
|
}
|
971
1034
|
return 1;
|
972
1035
|
}
|
973
|
-
exports.getUnionSubtypeCount = getUnionSubtypeCount;
|
974
1036
|
function isEllipsisType(type) {
|
975
1037
|
return (0, types_1.isAny)(type) && type.priv.isEllipsis;
|
976
1038
|
}
|
977
|
-
exports.isEllipsisType = isEllipsisType;
|
978
1039
|
function isProperty(type) {
|
979
1040
|
return (0, types_1.isClassInstance)(type) && types_1.ClassType.isPropertyClass(type);
|
980
1041
|
}
|
981
|
-
exports.isProperty = isProperty;
|
982
1042
|
function isCallableType(type) {
|
983
|
-
if ((0, types_1.isFunction)(type) || (0, types_1.
|
1043
|
+
if ((0, types_1.isFunction)(type) || (0, types_1.isOverloaded)(type) || (0, types_1.isAnyOrUnknown)(type)) {
|
984
1044
|
return true;
|
985
1045
|
}
|
986
1046
|
if (isEffectivelyInstantiable(type)) {
|
@@ -998,14 +1058,12 @@ function isCallableType(type) {
|
|
998
1058
|
}
|
999
1059
|
return false;
|
1000
1060
|
}
|
1001
|
-
exports.isCallableType = isCallableType;
|
1002
1061
|
function isDescriptorInstance(type, requireSetter = false) {
|
1003
1062
|
if ((0, types_1.isUnion)(type)) {
|
1004
1063
|
return type.priv.subtypes.every((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
|
1005
1064
|
}
|
1006
1065
|
return isMaybeDescriptorInstance(type, requireSetter);
|
1007
1066
|
}
|
1008
|
-
exports.isDescriptorInstance = isDescriptorInstance;
|
1009
1067
|
function isMaybeDescriptorInstance(type, requireSetter = false) {
|
1010
1068
|
if ((0, types_1.isUnion)(type)) {
|
1011
1069
|
return type.priv.subtypes.some((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
|
@@ -1021,7 +1079,6 @@ function isMaybeDescriptorInstance(type, requireSetter = false) {
|
|
1021
1079
|
}
|
1022
1080
|
return true;
|
1023
1081
|
}
|
1024
|
-
exports.isMaybeDescriptorInstance = isMaybeDescriptorInstance;
|
1025
1082
|
function isTupleGradualForm(type) {
|
1026
1083
|
return ((0, types_1.isClassInstance)(type) &&
|
1027
1084
|
isTupleClass(type) &&
|
@@ -1030,11 +1087,9 @@ function isTupleGradualForm(type) {
|
|
1030
1087
|
(0, types_1.isAnyOrUnknown)(type.priv.tupleTypeArgs[0].type) &&
|
1031
1088
|
type.priv.tupleTypeArgs[0].isUnbounded);
|
1032
1089
|
}
|
1033
|
-
exports.isTupleGradualForm = isTupleGradualForm;
|
1034
1090
|
function isTupleClass(type) {
|
1035
1091
|
return types_1.ClassType.isBuiltIn(type, 'tuple');
|
1036
1092
|
}
|
1037
|
-
exports.isTupleClass = isTupleClass;
|
1038
1093
|
// Indicates whether the type is a tuple class of
|
1039
1094
|
// the form tuple[x, ...] where the number of elements
|
1040
1095
|
// in the tuple is unknown.
|
@@ -1042,7 +1097,6 @@ function isUnboundedTupleClass(type) {
|
|
1042
1097
|
var _a;
|
1043
1098
|
return (_a = type.priv.tupleTypeArgs) === null || _a === void 0 ? void 0 : _a.some((t) => t.isUnbounded || (0, types_1.isUnpackedTypeVarTuple)(t.type));
|
1044
1099
|
}
|
1045
|
-
exports.isUnboundedTupleClass = isUnboundedTupleClass;
|
1046
1100
|
// Indicates whether the specified index is within range and its type is unambiguous
|
1047
1101
|
// in that it doesn't involve any element ranges that are of indeterminate length.
|
1048
1102
|
function isTupleIndexUnambiguous(type, index) {
|
@@ -1058,7 +1112,6 @@ function isTupleIndexUnambiguous(type, index) {
|
|
1058
1112
|
const upperIndexLimit = unboundedIndex < 0 ? type.priv.tupleTypeArgs.length : unboundedIndex;
|
1059
1113
|
return index < upperIndexLimit;
|
1060
1114
|
}
|
1061
|
-
exports.isTupleIndexUnambiguous = isTupleIndexUnambiguous;
|
1062
1115
|
// Partially specializes a type within the context of a specified
|
1063
1116
|
// (presumably specialized) class. Optionally specializes the `Self`
|
1064
1117
|
// type variables, replacing them with selfClass.
|
@@ -1069,11 +1122,11 @@ function partiallySpecializeType(type, contextClassType, typeClassType, selfClas
|
|
1069
1122
|
return type;
|
1070
1123
|
}
|
1071
1124
|
// Partially specialize the type using the specialized class type vars.
|
1072
|
-
const
|
1125
|
+
const solution = buildSolutionFromSpecializedClass(contextClassType);
|
1073
1126
|
if (selfClass) {
|
1074
|
-
|
1127
|
+
addSolutionForSelfType(solution, contextClassType, selfClass);
|
1075
1128
|
}
|
1076
|
-
let result = applySolvedTypeVars(type,
|
1129
|
+
let result = applySolvedTypeVars(type, solution, { typeClassType });
|
1077
1130
|
// If this is a property, we may need to partially specialize the
|
1078
1131
|
// access methods associated with it.
|
1079
1132
|
if ((0, types_1.isClass)(result)) {
|
@@ -1095,8 +1148,7 @@ function partiallySpecializeType(type, contextClassType, typeClassType, selfClas
|
|
1095
1148
|
}
|
1096
1149
|
return result;
|
1097
1150
|
}
|
1098
|
-
|
1099
|
-
function populateTypeVarContextForSelfType(typeVarContext, contextClassType, selfClass) {
|
1151
|
+
function addSolutionForSelfType(solution, contextClassType, selfClass) {
|
1100
1152
|
const synthesizedSelfTypeVar = synthesizeTypeVarForSelfCls(contextClassType, /* isClsParam */ false);
|
1101
1153
|
const selfInstance = convertToInstance(selfClass);
|
1102
1154
|
// We can't call stripLiteralValue here because that method requires the type evaluator.
|
@@ -1109,89 +1161,32 @@ function populateTypeVarContextForSelfType(typeVarContext, contextClassType, sel
|
|
1109
1161
|
}
|
1110
1162
|
return subtype;
|
1111
1163
|
});
|
1112
|
-
|
1113
|
-
setTypeVarType(typeVarContext, synthesizedSelfTypeVar, selfInstance, selfWithoutLiteral);
|
1114
|
-
}
|
1164
|
+
solution.setType(synthesizedSelfTypeVar, selfWithoutLiteral);
|
1115
1165
|
}
|
1116
|
-
exports.populateTypeVarContextForSelfType = populateTypeVarContextForSelfType;
|
1117
1166
|
// Looks for duplicate function types within the type and ensures that
|
1118
1167
|
// if they are generic, they have unique type variables.
|
1119
|
-
function
|
1168
|
+
function ensureSignaturesAreUnique(type, signatureTracker, expressionOffset) {
|
1120
1169
|
const transformer = new UniqueFunctionSignatureTransformer(signatureTracker, expressionOffset);
|
1121
1170
|
return transformer.apply(type, 0);
|
1122
1171
|
}
|
1123
|
-
|
1124
|
-
|
1125
|
-
const transformer = new InternalScopeUpdateTransform(scopeIds);
|
1172
|
+
function makeTypeVarsBound(type, scopeIds) {
|
1173
|
+
const transformer = new BoundTypeVarTransform(scopeIds);
|
1126
1174
|
return transformer.apply(type, 0);
|
1127
1175
|
}
|
1128
|
-
|
1129
|
-
|
1130
|
-
const transformer = new ExternalScopeUpdateTransform(scopeIds);
|
1176
|
+
function makeTypeVarsFree(type, scopeIds) {
|
1177
|
+
const transformer = new FreeTypeVarTransform(scopeIds);
|
1131
1178
|
return transformer.apply(type, 0);
|
1132
1179
|
}
|
1133
|
-
exports.updateTypeWithExternalTypeVars = updateTypeWithExternalTypeVars;
|
1134
1180
|
// Specializes a (potentially generic) type by substituting
|
1135
1181
|
// type variables from a type var map.
|
1136
|
-
function applySolvedTypeVars(type,
|
1137
|
-
// Use a shortcut if
|
1138
|
-
if (
|
1139
|
-
!options.unknownIfNotFound &&
|
1140
|
-
!options.eliminateUnsolvedInUnions &&
|
1141
|
-
!options.applyInScopePlaceholders) {
|
1182
|
+
function applySolvedTypeVars(type, solution, options = {}) {
|
1183
|
+
// Use a shortcut if constraints is empty and no transform is necessary.
|
1184
|
+
if (solution.isEmpty() && !options.replaceUnsolved) {
|
1142
1185
|
return type;
|
1143
1186
|
}
|
1144
|
-
|
1145
|
-
applyInScopePlaceholders(typeVarContext);
|
1146
|
-
}
|
1147
|
-
const transformer = new ApplySolvedTypeVarsTransformer(typeVarContext, options);
|
1187
|
+
const transformer = new ApplySolvedTypeVarsTransformer(solution, options);
|
1148
1188
|
return transformer.apply(type, 0);
|
1149
1189
|
}
|
1150
|
-
exports.applySolvedTypeVars = applySolvedTypeVars;
|
1151
|
-
// Applies solved TypeVars from one context to this context.
|
1152
|
-
function applySourceContextTypeVars(destContext, srcContext) {
|
1153
|
-
if (srcContext.isEmpty()) {
|
1154
|
-
return;
|
1155
|
-
}
|
1156
|
-
destContext.doForEachSolutionSet((solutionSet) => {
|
1157
|
-
applySourceContextTypeVarsToSignature(solutionSet, srcContext);
|
1158
|
-
});
|
1159
|
-
}
|
1160
|
-
exports.applySourceContextTypeVars = applySourceContextTypeVars;
|
1161
|
-
function applySourceContextTypeVarsToSignature(solutionSet, srcContext) {
|
1162
|
-
solutionSet.getTypeVars().forEach((entry) => {
|
1163
|
-
const newLowerBound = entry.lowerBound ? applySolvedTypeVars(entry.lowerBound, srcContext) : undefined;
|
1164
|
-
const newLowerBoundNoLiterals = entry.lowerBoundNoLiterals
|
1165
|
-
? applySolvedTypeVars(entry.lowerBoundNoLiterals, srcContext)
|
1166
|
-
: undefined;
|
1167
|
-
const newUpperBound = entry.upperBound ? applySolvedTypeVars(entry.upperBound, srcContext) : undefined;
|
1168
|
-
solutionSet.setTypeVarType(entry.typeVar, newLowerBound, newLowerBoundNoLiterals, newUpperBound);
|
1169
|
-
});
|
1170
|
-
}
|
1171
|
-
exports.applySourceContextTypeVarsToSignature = applySourceContextTypeVarsToSignature;
|
1172
|
-
// If the TypeVarContext contains any type variables whose types depend on
|
1173
|
-
// in-scope placeholders used for bidirectional type inference, replace those
|
1174
|
-
// with the solved type associated with those in-scope placeholders.
|
1175
|
-
function applyInScopePlaceholders(typeVarContext) {
|
1176
|
-
typeVarContext.doForEachSolutionSet((solutionSet) => {
|
1177
|
-
solutionSet.getTypeVars().forEach((entry) => {
|
1178
|
-
const typeVar = entry.typeVar;
|
1179
|
-
if (!typeVar.priv.isInScopePlaceholder) {
|
1180
|
-
const newLowerBound = entry.lowerBound
|
1181
|
-
? applyInScopePlaceholdersToType(entry.lowerBound, solutionSet)
|
1182
|
-
: undefined;
|
1183
|
-
const newLowerBoundNoLiterals = entry.lowerBoundNoLiterals
|
1184
|
-
? applyInScopePlaceholdersToType(entry.lowerBoundNoLiterals, solutionSet)
|
1185
|
-
: undefined;
|
1186
|
-
const newUpperBound = entry.upperBound
|
1187
|
-
? applyInScopePlaceholdersToType(entry.upperBound, solutionSet)
|
1188
|
-
: undefined;
|
1189
|
-
solutionSet.setTypeVarType(entry.typeVar, newLowerBound, newLowerBoundNoLiterals, newUpperBound);
|
1190
|
-
}
|
1191
|
-
});
|
1192
|
-
});
|
1193
|
-
}
|
1194
|
-
exports.applyInScopePlaceholders = applyInScopePlaceholders;
|
1195
1190
|
// Validates that a default type associated with a TypeVar does not refer to
|
1196
1191
|
// other TypeVars or ParamSpecs that are out of scope.
|
1197
1192
|
function validateTypeVarDefault(typeVar, liveTypeParams, invalidTypeVars) {
|
@@ -1202,12 +1197,6 @@ function validateTypeVarDefault(typeVar, liveTypeParams, invalidTypeVars) {
|
|
1202
1197
|
validator.apply(typeVar.shared.defaultType, 0);
|
1203
1198
|
}
|
1204
1199
|
}
|
1205
|
-
exports.validateTypeVarDefault = validateTypeVarDefault;
|
1206
|
-
function replaceTypeVarsWithAny(type) {
|
1207
|
-
const transformer = new TypeVarAnyReplacer();
|
1208
|
-
return transformer.apply(type, 0);
|
1209
|
-
}
|
1210
|
-
exports.replaceTypeVarsWithAny = replaceTypeVarsWithAny;
|
1211
1200
|
// During bidirectional type inference for constructors, an "expected type"
|
1212
1201
|
// is used to prepopulate the type var map. This is problematic when the
|
1213
1202
|
// expected type uses TypeVars that are not part of the context of the
|
@@ -1217,7 +1206,6 @@ function transformExpectedType(expectedType, liveTypeVarScopes, usageOffset) {
|
|
1217
1206
|
const transformer = new ExpectedTypeTransformer(liveTypeVarScopes, usageOffset);
|
1218
1207
|
return transformer.apply(expectedType, 0);
|
1219
1208
|
}
|
1220
|
-
exports.transformExpectedType = transformExpectedType;
|
1221
1209
|
// Given a protocol class (or abstract class), this function returns
|
1222
1210
|
// a set of all the symbols (indexed by symbol name) that are part of
|
1223
1211
|
// that protocol and its protocol parent classes. If a same-named symbol
|
@@ -1229,7 +1217,6 @@ function getProtocolSymbols(classType) {
|
|
1229
1217
|
}
|
1230
1218
|
return symbolMap;
|
1231
1219
|
}
|
1232
|
-
exports.getProtocolSymbols = getProtocolSymbols;
|
1233
1220
|
function getProtocolSymbolsRecursive(classType, symbolMap, classFlags = 512 /* ClassTypeFlags.ProtocolClass */, recursionCount = 0) {
|
1234
1221
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1235
1222
|
return;
|
@@ -1254,7 +1241,6 @@ function getProtocolSymbolsRecursive(classType, symbolMap, classFlags = 512 /* C
|
|
1254
1241
|
}
|
1255
1242
|
});
|
1256
1243
|
}
|
1257
|
-
exports.getProtocolSymbolsRecursive = getProtocolSymbolsRecursive;
|
1258
1244
|
// Determines the maximum depth of a tuple, list, set or dictionary.
|
1259
1245
|
// For example, if the type is tuple[tuple[tuple[int]]], its depth would be 3.
|
1260
1246
|
function getContainerDepth(type, recursionCount = 0) {
|
@@ -1287,14 +1273,12 @@ function getContainerDepth(type, recursionCount = 0) {
|
|
1287
1273
|
}
|
1288
1274
|
return 1 + maxChildDepth;
|
1289
1275
|
}
|
1290
|
-
exports.getContainerDepth = getContainerDepth;
|
1291
1276
|
function lookUpObjectMember(objectType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
|
1292
1277
|
if ((0, types_1.isClassInstance)(objectType)) {
|
1293
1278
|
return lookUpClassMember(objectType, memberName, flags, skipMroClass);
|
1294
1279
|
}
|
1295
1280
|
return undefined;
|
1296
1281
|
}
|
1297
|
-
exports.lookUpObjectMember = lookUpObjectMember;
|
1298
1282
|
// Looks up a member in a class using the multiple-inheritance rules
|
1299
1283
|
// defined by Python.
|
1300
1284
|
function lookUpClassMember(classType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
|
@@ -1318,7 +1302,6 @@ function lookUpClassMember(classType, memberName, flags = 0 /* MemberAccessFlags
|
|
1318
1302
|
const memberItr = getClassMemberIterator(classType, memberName, flags, skipMroClass);
|
1319
1303
|
return (_b = memberItr.next()) === null || _b === void 0 ? void 0 : _b.value;
|
1320
1304
|
}
|
1321
|
-
exports.lookUpClassMember = lookUpClassMember;
|
1322
1305
|
// Iterates members in a class matching memberName using the multiple-inheritance rules.
|
1323
1306
|
// For more details, see this note on method resolution
|
1324
1307
|
// order: https://www.python.org/download/releases/2.3/mro/.
|
@@ -1454,7 +1437,6 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* MemberAcces
|
|
1454
1437
|
}
|
1455
1438
|
return undefined;
|
1456
1439
|
}
|
1457
|
-
exports.getClassMemberIterator = getClassMemberIterator;
|
1458
1440
|
function* getClassIterator(classType, flags = 0 /* ClassIteratorFlags.Default */, skipMroClass) {
|
1459
1441
|
if ((0, types_1.isClass)(classType)) {
|
1460
1442
|
let foundSkipMroClass = skipMroClass === undefined;
|
@@ -1499,7 +1481,6 @@ function* getClassIterator(classType, flags = 0 /* ClassIteratorFlags.Default */
|
|
1499
1481
|
}
|
1500
1482
|
return undefined;
|
1501
1483
|
}
|
1502
|
-
exports.getClassIterator = getClassIterator;
|
1503
1484
|
function getClassFieldsRecursive(classType) {
|
1504
1485
|
const memberMap = new Map();
|
1505
1486
|
// Evaluate the types of members from the end of the MRO to the beginning.
|
@@ -1529,7 +1510,6 @@ function getClassFieldsRecursive(classType) {
|
|
1529
1510
|
});
|
1530
1511
|
return memberMap;
|
1531
1512
|
}
|
1532
|
-
exports.getClassFieldsRecursive = getClassFieldsRecursive;
|
1533
1513
|
// Combines two lists of type var types, maintaining the combined order
|
1534
1514
|
// but removing any duplicates.
|
1535
1515
|
function addTypeVarsToListIfUnique(list1, list2, typeVarScopeId) {
|
@@ -1542,7 +1522,6 @@ function addTypeVarsToListIfUnique(list1, list2, typeVarScopeId) {
|
|
1542
1522
|
}
|
1543
1523
|
}
|
1544
1524
|
}
|
1545
|
-
exports.addTypeVarsToListIfUnique = addTypeVarsToListIfUnique;
|
1546
1525
|
// Walks the type recursively (in a depth-first manner), finds all
|
1547
1526
|
// type variables that are referenced, and returns an ordered list
|
1548
1527
|
// of unique type variables. For example, if the type is
|
@@ -1593,7 +1572,7 @@ function getTypeVarArgsRecursive(type, recursionCount = 0) {
|
|
1593
1572
|
if ((0, types_1.isFunction)(type)) {
|
1594
1573
|
const combinedList = [];
|
1595
1574
|
for (let i = 0; i < type.shared.parameters.length; i++) {
|
1596
|
-
addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(types_1.FunctionType.
|
1575
|
+
addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(types_1.FunctionType.getParamType(type, i), recursionCount));
|
1597
1576
|
}
|
1598
1577
|
const returnType = types_1.FunctionType.getEffectiveReturnType(type);
|
1599
1578
|
if (returnType) {
|
@@ -1603,82 +1582,21 @@ function getTypeVarArgsRecursive(type, recursionCount = 0) {
|
|
1603
1582
|
}
|
1604
1583
|
return [];
|
1605
1584
|
}
|
1606
|
-
exports.getTypeVarArgsRecursive = getTypeVarArgsRecursive;
|
1607
1585
|
// Creates a specialized version of the class, filling in any unspecified
|
1608
1586
|
// type arguments with Unknown.
|
1609
1587
|
function specializeClassType(type) {
|
1610
|
-
const
|
1588
|
+
const solution = new constraintSolution_1.ConstraintSolution();
|
1611
1589
|
const typeParams = types_1.ClassType.getTypeParams(type);
|
1612
1590
|
typeParams.forEach((typeParam) => {
|
1613
|
-
|
1591
|
+
solution.setType(typeParam, applySolvedTypeVars(typeParam.shared.defaultType, solution));
|
1614
1592
|
});
|
1615
|
-
return applySolvedTypeVars(type,
|
1593
|
+
return applySolvedTypeVars(type, solution);
|
1616
1594
|
}
|
1617
|
-
exports.specializeClassType = specializeClassType;
|
1618
|
-
// Recursively finds all of the type arguments and sets them
|
1619
|
-
// to the specified srcType.
|
1620
|
-
function setTypeArgsRecursive(destType, srcType, typeVarContext, recursionCount = 0) {
|
1621
|
-
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1622
|
-
return;
|
1623
|
-
}
|
1624
|
-
recursionCount++;
|
1625
|
-
if (typeVarContext.isLocked()) {
|
1626
|
-
return;
|
1627
|
-
}
|
1628
|
-
switch (destType.category) {
|
1629
|
-
case 8 /* TypeCategory.Union */:
|
1630
|
-
doForEachSubtype(destType, (subtype) => {
|
1631
|
-
setTypeArgsRecursive(subtype, srcType, typeVarContext, recursionCount);
|
1632
|
-
});
|
1633
|
-
break;
|
1634
|
-
case 6 /* TypeCategory.Class */:
|
1635
|
-
if (destType.priv.typeArgs) {
|
1636
|
-
destType.priv.typeArgs.forEach((typeArg) => {
|
1637
|
-
setTypeArgsRecursive(typeArg, srcType, typeVarContext, recursionCount);
|
1638
|
-
});
|
1639
|
-
}
|
1640
|
-
if (destType.priv.tupleTypeArgs) {
|
1641
|
-
destType.priv.tupleTypeArgs.forEach((typeArg) => {
|
1642
|
-
setTypeArgsRecursive(typeArg.type, srcType, typeVarContext, recursionCount);
|
1643
|
-
});
|
1644
|
-
}
|
1645
|
-
break;
|
1646
|
-
case 4 /* TypeCategory.Function */:
|
1647
|
-
if (destType.priv.specializedTypes) {
|
1648
|
-
destType.priv.specializedTypes.parameterTypes.forEach((paramType) => {
|
1649
|
-
setTypeArgsRecursive(paramType, srcType, typeVarContext, recursionCount);
|
1650
|
-
});
|
1651
|
-
if (destType.priv.specializedTypes.returnType) {
|
1652
|
-
setTypeArgsRecursive(destType.priv.specializedTypes.returnType, srcType, typeVarContext, recursionCount);
|
1653
|
-
}
|
1654
|
-
}
|
1655
|
-
else {
|
1656
|
-
destType.shared.parameters.forEach((param) => {
|
1657
|
-
setTypeArgsRecursive(param.type, srcType, typeVarContext, recursionCount);
|
1658
|
-
});
|
1659
|
-
if (destType.shared.declaredReturnType) {
|
1660
|
-
setTypeArgsRecursive(destType.shared.declaredReturnType, srcType, typeVarContext, recursionCount);
|
1661
|
-
}
|
1662
|
-
}
|
1663
|
-
break;
|
1664
|
-
case 5 /* TypeCategory.OverloadedFunction */:
|
1665
|
-
destType.priv.overloads.forEach((subtype) => {
|
1666
|
-
setTypeArgsRecursive(subtype, srcType, typeVarContext, recursionCount);
|
1667
|
-
});
|
1668
|
-
break;
|
1669
|
-
case 9 /* TypeCategory.TypeVar */:
|
1670
|
-
if (!typeVarContext.getMainSolutionSet().getTypeVar(destType)) {
|
1671
|
-
setTypeVarType(typeVarContext, destType, srcType);
|
1672
|
-
}
|
1673
|
-
break;
|
1674
|
-
}
|
1675
|
-
}
|
1676
|
-
exports.setTypeArgsRecursive = setTypeArgsRecursive;
|
1677
1595
|
// Builds a mapping between type parameters and their specialized
|
1678
1596
|
// types. For example, if the generic type is Dict[_T1, _T2] and the
|
1679
1597
|
// specialized type is Dict[str, int], it returns a map that associates
|
1680
1598
|
// _T1 with str and _T2 with int.
|
1681
|
-
function
|
1599
|
+
function buildSolutionFromSpecializedClass(classType) {
|
1682
1600
|
const typeParams = types_1.ClassType.getTypeParams(classType);
|
1683
1601
|
let typeArgs;
|
1684
1602
|
if (classType.priv.tupleTypeArgs) {
|
@@ -1690,45 +1608,20 @@ function buildTypeVarContextFromSpecializedClass(classType) {
|
|
1690
1608
|
else {
|
1691
1609
|
typeArgs = classType.priv.typeArgs;
|
1692
1610
|
}
|
1693
|
-
return
|
1611
|
+
return buildSolution(typeParams, typeArgs);
|
1694
1612
|
}
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1613
|
+
function buildSolution(typeParams, typeArgs) {
|
1614
|
+
const solution = new constraintSolution_1.ConstraintSolution();
|
1615
|
+
if (!typeArgs) {
|
1616
|
+
return solution;
|
1617
|
+
}
|
1698
1618
|
typeParams.forEach((typeParam, index) => {
|
1699
|
-
|
1700
|
-
|
1701
|
-
if ((0, types_1.isParamSpec)(typeParam)) {
|
1702
|
-
if (index < typeArgs.length) {
|
1703
|
-
typeArgType = typeArgs[index];
|
1704
|
-
if ((0, types_1.isFunction)(typeArgType) && types_1.FunctionType.isParamSpecValue(typeArgType)) {
|
1705
|
-
const parameters = [];
|
1706
|
-
const typeArgFunctionType = typeArgType;
|
1707
|
-
typeArgType.shared.parameters.forEach((param, paramIndex) => {
|
1708
|
-
parameters.push(types_1.FunctionParam.create(param.category, types_1.FunctionType.getEffectiveParamType(typeArgFunctionType, paramIndex), param.flags & types_1.FunctionParamFlags.NameSynthesized, param.name, param.defaultType));
|
1709
|
-
});
|
1710
|
-
setTypeVarType(typeVarContext, typeParam, typeArgType);
|
1711
|
-
}
|
1712
|
-
else if ((0, types_1.isParamSpec)(typeArgType) || (0, types_1.isAnyOrUnknown)(typeArgType)) {
|
1713
|
-
setTypeVarType(typeVarContext, typeParam, typeArgType);
|
1714
|
-
}
|
1715
|
-
}
|
1716
|
-
}
|
1717
|
-
else {
|
1718
|
-
if (index >= typeArgs.length) {
|
1719
|
-
typeArgType = types_1.AnyType.create();
|
1720
|
-
}
|
1721
|
-
else {
|
1722
|
-
typeArgType = typeArgs[index];
|
1723
|
-
}
|
1724
|
-
setTypeVarType(typeVarContext, typeParam, typeArgType,
|
1725
|
-
/* lowerBoundNoLiterals */ undefined, typeArgType);
|
1726
|
-
}
|
1619
|
+
if (index < typeArgs.length) {
|
1620
|
+
solution.setType(typeParam, typeArgs[index]);
|
1727
1621
|
}
|
1728
1622
|
});
|
1729
|
-
return
|
1623
|
+
return solution;
|
1730
1624
|
}
|
1731
|
-
exports.buildTypeVarContext = buildTypeVarContext;
|
1732
1625
|
// Determines the specialized base class type that srcType derives from.
|
1733
1626
|
function specializeForBaseClass(srcType, baseClass) {
|
1734
1627
|
const typeParams = types_1.ClassType.getTypeParams(baseClass);
|
@@ -1737,16 +1630,14 @@ function specializeForBaseClass(srcType, baseClass) {
|
|
1737
1630
|
if (typeParams.length === 0) {
|
1738
1631
|
return baseClass;
|
1739
1632
|
}
|
1740
|
-
const
|
1741
|
-
const specializedType = applySolvedTypeVars(baseClass,
|
1633
|
+
const solution = buildSolutionFromSpecializedClass(srcType);
|
1634
|
+
const specializedType = applySolvedTypeVars(baseClass, solution);
|
1742
1635
|
(0, debug_1.assert)((0, types_1.isInstantiableClass)(specializedType));
|
1743
1636
|
return specializedType;
|
1744
1637
|
}
|
1745
|
-
exports.specializeForBaseClass = specializeForBaseClass;
|
1746
1638
|
function derivesFromStdlibClass(classType, className) {
|
1747
1639
|
return classType.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, className));
|
1748
1640
|
}
|
1749
|
-
exports.derivesFromStdlibClass = derivesFromStdlibClass;
|
1750
1641
|
// If ignoreUnknown is true, an unknown base class is ignored when
|
1751
1642
|
// checking for derivation. If ignoreUnknown is false, a return value
|
1752
1643
|
// of true is assumed.
|
@@ -1767,7 +1658,6 @@ function derivesFromClassRecursive(classType, baseClassToFind, ignoreUnknown) {
|
|
1767
1658
|
}
|
1768
1659
|
return false;
|
1769
1660
|
}
|
1770
|
-
exports.derivesFromClassRecursive = derivesFromClassRecursive;
|
1771
1661
|
function synthesizeTypeVarForSelfCls(classType, isClsParam) {
|
1772
1662
|
var _a;
|
1773
1663
|
const selfType = types_1.TypeVarType.createInstance(`__type_of_self__`);
|
@@ -1783,7 +1673,6 @@ function synthesizeTypeVarForSelfCls(classType, isClsParam) {
|
|
1783
1673
|
selfType.shared.boundType = types_1.ClassType.cloneAsInstance(boundType);
|
1784
1674
|
return isClsParam ? types_1.TypeVarType.cloneAsInstantiable(selfType) : selfType;
|
1785
1675
|
}
|
1786
|
-
exports.synthesizeTypeVarForSelfCls = synthesizeTypeVarForSelfCls;
|
1787
1676
|
// Returns the declared "return" type (the type returned from a return statement)
|
1788
1677
|
// if it was declared, or undefined otherwise.
|
1789
1678
|
function getDeclaredGeneratorReturnType(functionType) {
|
@@ -1797,7 +1686,6 @@ function getDeclaredGeneratorReturnType(functionType) {
|
|
1797
1686
|
}
|
1798
1687
|
return undefined;
|
1799
1688
|
}
|
1800
|
-
exports.getDeclaredGeneratorReturnType = getDeclaredGeneratorReturnType;
|
1801
1689
|
// If the declared return type is a Generator, Iterable, Iterator or the async
|
1802
1690
|
// counterparts, returns the yield type. If the type is invalid for a generator,
|
1803
1691
|
// returns undefined.
|
@@ -1825,17 +1713,14 @@ function getGeneratorYieldType(declaredReturnType, isAsync) {
|
|
1825
1713
|
});
|
1826
1714
|
return isLegalGeneratorType ? yieldType : undefined;
|
1827
1715
|
}
|
1828
|
-
exports.getGeneratorYieldType = getGeneratorYieldType;
|
1829
1716
|
function isInstantiableMetaclass(type) {
|
1830
1717
|
return ((0, types_1.isInstantiableClass)(type) &&
|
1831
1718
|
type.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'type')));
|
1832
1719
|
}
|
1833
|
-
exports.isInstantiableMetaclass = isInstantiableMetaclass;
|
1834
1720
|
function isMetaclassInstance(type) {
|
1835
1721
|
return ((0, types_1.isClassInstance)(type) &&
|
1836
1722
|
type.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'type')));
|
1837
1723
|
}
|
1838
|
-
exports.isMetaclassInstance = isMetaclassInstance;
|
1839
1724
|
function isEffectivelyInstantiable(type, options, recursionCount = 0) {
|
1840
1725
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1841
1726
|
return false;
|
@@ -1859,7 +1744,6 @@ function isEffectivelyInstantiable(type, options, recursionCount = 0) {
|
|
1859
1744
|
}
|
1860
1745
|
return false;
|
1861
1746
|
}
|
1862
|
-
exports.isEffectivelyInstantiable = isEffectivelyInstantiable;
|
1863
1747
|
function convertToInstance(type, includeSubclasses = true) {
|
1864
1748
|
var _a, _b;
|
1865
1749
|
// See if we've already performed this conversion and cached it.
|
@@ -1921,7 +1805,7 @@ function convertToInstance(type, includeSubclasses = true) {
|
|
1921
1805
|
// Copy over any type alias information.
|
1922
1806
|
const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
|
1923
1807
|
if (aliasInfo && type !== result) {
|
1924
|
-
result = types_1.TypeBase.cloneForTypeAlias(result, aliasInfo
|
1808
|
+
result = types_1.TypeBase.cloneForTypeAlias(result, aliasInfo);
|
1925
1809
|
}
|
1926
1810
|
if (type !== result && includeSubclasses) {
|
1927
1811
|
// Cache the converted value for next time.
|
@@ -1932,7 +1816,6 @@ function convertToInstance(type, includeSubclasses = true) {
|
|
1932
1816
|
}
|
1933
1817
|
return result;
|
1934
1818
|
}
|
1935
|
-
exports.convertToInstance = convertToInstance;
|
1936
1819
|
function convertToInstantiable(type, includeSubclasses = true) {
|
1937
1820
|
var _a;
|
1938
1821
|
// See if we've already performed this conversion and cached it.
|
@@ -1962,7 +1845,6 @@ function convertToInstantiable(type, includeSubclasses = true) {
|
|
1962
1845
|
}
|
1963
1846
|
return result;
|
1964
1847
|
}
|
1965
|
-
exports.convertToInstantiable = convertToInstantiable;
|
1966
1848
|
function getMembersForClass(classType, symbolTable, includeInstanceVars) {
|
1967
1849
|
classType.shared.mro.forEach((mroClass) => {
|
1968
1850
|
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
@@ -2012,7 +1894,6 @@ function getMembersForClass(classType, symbolTable, includeInstanceVars) {
|
|
2012
1894
|
}
|
2013
1895
|
}
|
2014
1896
|
}
|
2015
|
-
exports.getMembersForClass = getMembersForClass;
|
2016
1897
|
function getMembersForModule(moduleType, symbolTable) {
|
2017
1898
|
// Start with the loader fields. If there are any symbols of the
|
2018
1899
|
// same name defined within the module, they will overwrite the
|
@@ -2026,7 +1907,6 @@ function getMembersForModule(moduleType, symbolTable) {
|
|
2026
1907
|
symbolTable.set(name, symbol);
|
2027
1908
|
});
|
2028
1909
|
}
|
2029
|
-
exports.getMembersForModule = getMembersForModule;
|
2030
1910
|
// Determines if the type contains an Any recursively.
|
2031
1911
|
function containsAnyRecursive(type, includeUnknown = true) {
|
2032
1912
|
class AnyWalker extends typeWalker_1.TypeWalker {
|
@@ -2050,7 +1930,6 @@ function containsAnyRecursive(type, includeUnknown = true) {
|
|
2050
1930
|
walker.walk(type);
|
2051
1931
|
return walker.foundAny;
|
2052
1932
|
}
|
2053
|
-
exports.containsAnyRecursive = containsAnyRecursive;
|
2054
1933
|
// Determines if the type contains an Any or Unknown type. If so,
|
2055
1934
|
// it returns the Any or Unknown type. Unknowns are preferred over
|
2056
1935
|
// Any if both are present. If recurse is true, it will recurse
|
@@ -2091,7 +1970,6 @@ function containsAnyOrUnknown(type, recurse) {
|
|
2091
1970
|
walker.walk(type);
|
2092
1971
|
return walker.anyOrUnknownType;
|
2093
1972
|
}
|
2094
|
-
exports.containsAnyOrUnknown = containsAnyOrUnknown;
|
2095
1973
|
// Determines if any part of the type contains "Unknown", including any type arguments.
|
2096
1974
|
// This function does not use the TypeWalker because it is called very frequently,
|
2097
1975
|
// and allocating a memory walker object for every call significantly increases
|
@@ -2138,8 +2016,8 @@ function isPartlyUnknown(type, recursionCount = 0) {
|
|
2138
2016
|
return false;
|
2139
2017
|
}
|
2140
2018
|
// See if a function has an unknown type.
|
2141
|
-
if ((0, types_1.
|
2142
|
-
return types_1.
|
2019
|
+
if ((0, types_1.isOverloaded)(type)) {
|
2020
|
+
return types_1.OverloadedType.getOverloads(type).some((overload) => {
|
2143
2021
|
return isPartlyUnknown(overload, recursionCount);
|
2144
2022
|
});
|
2145
2023
|
}
|
@@ -2147,7 +2025,7 @@ function isPartlyUnknown(type, recursionCount = 0) {
|
|
2147
2025
|
for (let i = 0; i < type.shared.parameters.length; i++) {
|
2148
2026
|
// Ignore parameters such as "*" that have no name.
|
2149
2027
|
if (type.shared.parameters[i].name) {
|
2150
|
-
const paramType = types_1.FunctionType.
|
2028
|
+
const paramType = types_1.FunctionType.getParamType(type, i);
|
2151
2029
|
if (isPartlyUnknown(paramType, recursionCount)) {
|
2152
2030
|
return true;
|
2153
2031
|
}
|
@@ -2162,7 +2040,6 @@ function isPartlyUnknown(type, recursionCount = 0) {
|
|
2162
2040
|
}
|
2163
2041
|
return false;
|
2164
2042
|
}
|
2165
|
-
exports.isPartlyUnknown = isPartlyUnknown;
|
2166
2043
|
// If the specified type is a generic class with a single type argument
|
2167
2044
|
// that is a union, it "explodes" the class into a union of classes with
|
2168
2045
|
// each element of the union - e.g. Foo[A | B] becomes Foo[A] | Foo[B].
|
@@ -2174,7 +2051,6 @@ function explodeGenericClass(classType) {
|
|
2174
2051
|
return types_1.ClassType.specialize(classType, [subtype]);
|
2175
2052
|
}));
|
2176
2053
|
}
|
2177
|
-
exports.explodeGenericClass = explodeGenericClass;
|
2178
2054
|
// If the type is a union of same-sized tuples, these are combined into
|
2179
2055
|
// a single tuple with that size. Otherwise, returns undefined.
|
2180
2056
|
function combineSameSizedTuples(type, tupleType) {
|
@@ -2224,7 +2100,6 @@ function combineSameSizedTuples(type, tupleType) {
|
|
2224
2100
|
return { type: (0, types_1.combineTypes)(entry), isUnbounded: false };
|
2225
2101
|
})));
|
2226
2102
|
}
|
2227
|
-
exports.combineSameSizedTuples = combineSameSizedTuples;
|
2228
2103
|
function combineTupleTypeArgs(typeArgs) {
|
2229
2104
|
return (0, types_1.combineTypes)(typeArgs.map((t) => {
|
2230
2105
|
if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedTypeVarTuple)(t.type)) {
|
@@ -2234,7 +2109,6 @@ function combineTupleTypeArgs(typeArgs) {
|
|
2234
2109
|
return t.type;
|
2235
2110
|
}));
|
2236
2111
|
}
|
2237
|
-
exports.combineTupleTypeArgs = combineTupleTypeArgs;
|
2238
2112
|
// Tuples require special handling for specialization. This method computes
|
2239
2113
|
// the "effective" type argument, which is a union of the variadic type
|
2240
2114
|
// arguments.
|
@@ -2246,8 +2120,7 @@ function specializeTupleClass(classType, typeArgs, isTypeArgExplicit = true, isU
|
|
2246
2120
|
}
|
2247
2121
|
return clonedClassType;
|
2248
2122
|
}
|
2249
|
-
|
2250
|
-
function _expandVariadicUnpackedUnion(type) {
|
2123
|
+
function _expandUnpackedTypeVarTupleUnion(type) {
|
2251
2124
|
if ((0, types_1.isClassInstance)(type) && isTupleClass(type) && type.priv.tupleTypeArgs && type.priv.isUnpacked) {
|
2252
2125
|
return (0, types_1.combineTypes)(type.priv.tupleTypeArgs.map((t) => t.type));
|
2253
2126
|
}
|
@@ -2269,7 +2142,6 @@ function getGeneratorTypeArgs(returnType) {
|
|
2269
2142
|
}
|
2270
2143
|
return undefined;
|
2271
2144
|
}
|
2272
|
-
exports.getGeneratorTypeArgs = getGeneratorTypeArgs;
|
2273
2145
|
function requiresTypeArgs(classType) {
|
2274
2146
|
if (classType.shared.typeParams.length > 0) {
|
2275
2147
|
const firstTypeParam = classType.shared.typeParams[0];
|
@@ -2307,7 +2179,6 @@ function requiresTypeArgs(classType) {
|
|
2307
2179
|
}
|
2308
2180
|
return false;
|
2309
2181
|
}
|
2310
|
-
exports.requiresTypeArgs = requiresTypeArgs;
|
2311
2182
|
function requiresSpecialization(type, options, recursionCount = 0) {
|
2312
2183
|
var _a;
|
2313
2184
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
@@ -2328,7 +2199,6 @@ function requiresSpecialization(type, options, recursionCount = 0) {
|
|
2328
2199
|
}
|
2329
2200
|
return result;
|
2330
2201
|
}
|
2331
|
-
exports.requiresSpecialization = requiresSpecialization;
|
2332
2202
|
function _requiresSpecialization(type, options, recursionCount = 0) {
|
2333
2203
|
var _a, _b;
|
2334
2204
|
// If the type is conditioned on a TypeVar, it may need to be specialized.
|
@@ -2350,7 +2220,7 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
|
|
2350
2220
|
}
|
2351
2221
|
case 4 /* TypeCategory.Function */: {
|
2352
2222
|
for (let i = 0; i < type.shared.parameters.length; i++) {
|
2353
|
-
if (requiresSpecialization(types_1.FunctionType.
|
2223
|
+
if (requiresSpecialization(types_1.FunctionType.getParamType(type, i), options, recursionCount)) {
|
2354
2224
|
return true;
|
2355
2225
|
}
|
2356
2226
|
}
|
@@ -2369,8 +2239,16 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
|
|
2369
2239
|
}
|
2370
2240
|
return false;
|
2371
2241
|
}
|
2372
|
-
case 5 /* TypeCategory.
|
2373
|
-
|
2242
|
+
case 5 /* TypeCategory.Overloaded */: {
|
2243
|
+
const overloads = types_1.OverloadedType.getOverloads(type);
|
2244
|
+
if (overloads.some((overload) => requiresSpecialization(overload, options, recursionCount))) {
|
2245
|
+
return true;
|
2246
|
+
}
|
2247
|
+
const impl = types_1.OverloadedType.getImplementation(type);
|
2248
|
+
if (impl) {
|
2249
|
+
return requiresSpecialization(impl, options, recursionCount);
|
2250
|
+
}
|
2251
|
+
return false;
|
2374
2252
|
}
|
2375
2253
|
case 8 /* TypeCategory.Union */: {
|
2376
2254
|
return type.priv.subtypes.some((subtype) => requiresSpecialization(subtype, options, recursionCount));
|
@@ -2378,7 +2256,7 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
|
|
2378
2256
|
case 9 /* TypeCategory.TypeVar */: {
|
2379
2257
|
// Most TypeVar types need to be specialized.
|
2380
2258
|
if (!type.shared.recursiveAlias) {
|
2381
|
-
if (
|
2259
|
+
if (types_1.TypeVarType.isSelf(type) && (options === null || options === void 0 ? void 0 : options.ignoreSelf)) {
|
2382
2260
|
return false;
|
2383
2261
|
}
|
2384
2262
|
return true;
|
@@ -2405,7 +2283,6 @@ function combineVariances(variance1, variance2) {
|
|
2405
2283
|
}
|
2406
2284
|
return variance1;
|
2407
2285
|
}
|
2408
|
-
exports.combineVariances = combineVariances;
|
2409
2286
|
// Determines if the variance of the type argument for a generic class is compatible
|
2410
2287
|
// With the declared variance of the corresponding type parameter.
|
2411
2288
|
function isVarianceOfTypeArgCompatible(type, typeParamVariance) {
|
@@ -2454,7 +2331,6 @@ function isVarianceOfTypeArgCompatible(type, typeParamVariance) {
|
|
2454
2331
|
}
|
2455
2332
|
return true;
|
2456
2333
|
}
|
2457
|
-
exports.isVarianceOfTypeArgCompatible = isVarianceOfTypeArgCompatible;
|
2458
2334
|
// Computes the method resolution ordering for a class whose base classes
|
2459
2335
|
// have already been filled in. The algorithm for computing MRO is described
|
2460
2336
|
// here: https://www.python.org/download/releases/2.3/mro/. It returns true
|
@@ -2492,9 +2368,9 @@ function computeMroLinearization(classType) {
|
|
2492
2368
|
const classListsToMerge = [];
|
2493
2369
|
filteredBaseClasses.forEach((baseClass) => {
|
2494
2370
|
if ((0, types_1.isInstantiableClass)(baseClass)) {
|
2495
|
-
const
|
2371
|
+
const solution = buildSolutionFromSpecializedClass(baseClass);
|
2496
2372
|
classListsToMerge.push(baseClass.shared.mro.map((mroClass) => {
|
2497
|
-
return applySolvedTypeVars(mroClass,
|
2373
|
+
return applySolvedTypeVars(mroClass, solution);
|
2498
2374
|
}));
|
2499
2375
|
}
|
2500
2376
|
else {
|
@@ -2502,12 +2378,12 @@ function computeMroLinearization(classType) {
|
|
2502
2378
|
}
|
2503
2379
|
});
|
2504
2380
|
classListsToMerge.push(filteredBaseClasses.map((baseClass) => {
|
2505
|
-
const
|
2506
|
-
return applySolvedTypeVars(baseClass,
|
2381
|
+
const solution = buildSolutionFromSpecializedClass(classType);
|
2382
|
+
return applySolvedTypeVars(baseClass, solution);
|
2507
2383
|
}));
|
2508
2384
|
// The first class in the MRO is the class itself.
|
2509
|
-
const
|
2510
|
-
let specializedClassType = applySolvedTypeVars(classType,
|
2385
|
+
const solution = buildSolutionFromSpecializedClass(classType);
|
2386
|
+
let specializedClassType = applySolvedTypeVars(classType, solution);
|
2511
2387
|
if (!(0, types_1.isClass)(specializedClassType) && !(0, types_1.isAnyOrUnknown)(specializedClassType)) {
|
2512
2388
|
specializedClassType = types_1.UnknownType.create();
|
2513
2389
|
}
|
@@ -2584,7 +2460,6 @@ function computeMroLinearization(classType) {
|
|
2584
2460
|
}
|
2585
2461
|
return isMroFound;
|
2586
2462
|
}
|
2587
|
-
exports.computeMroLinearization = computeMroLinearization;
|
2588
2463
|
// Returns zero or more unique module names that point to the place(s)
|
2589
2464
|
// where the type is declared. Unions, for example, can result in more
|
2590
2465
|
// than one result. Type arguments are not included.
|
@@ -2593,7 +2468,6 @@ function getDeclaringModulesForType(type) {
|
|
2593
2468
|
addDeclaringModuleNamesForType(type, moduleList);
|
2594
2469
|
return moduleList;
|
2595
2470
|
}
|
2596
|
-
exports.getDeclaringModulesForType = getDeclaringModulesForType;
|
2597
2471
|
function convertNodeToArg(node) {
|
2598
2472
|
return {
|
2599
2473
|
argCategory: node.d.argCategory,
|
@@ -2601,7 +2475,6 @@ function convertNodeToArg(node) {
|
|
2601
2475
|
valueExpression: node.d.valueExpr,
|
2602
2476
|
};
|
2603
2477
|
}
|
2604
|
-
exports.convertNodeToArg = convertNodeToArg;
|
2605
2478
|
function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
|
2606
2479
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
2607
2480
|
return;
|
@@ -2621,10 +2494,15 @@ function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
|
|
2621
2494
|
addIfUnique(type.shared.moduleName);
|
2622
2495
|
break;
|
2623
2496
|
}
|
2624
|
-
case 5 /* TypeCategory.
|
2625
|
-
|
2497
|
+
case 5 /* TypeCategory.Overloaded */: {
|
2498
|
+
const overloads = types_1.OverloadedType.getOverloads(type);
|
2499
|
+
overloads.forEach((overload) => {
|
2626
2500
|
addDeclaringModuleNamesForType(overload, moduleList, recursionCount);
|
2627
2501
|
});
|
2502
|
+
const impl = types_1.OverloadedType.getImplementation(type);
|
2503
|
+
if (impl) {
|
2504
|
+
addDeclaringModuleNamesForType(impl, moduleList, recursionCount);
|
2505
|
+
}
|
2628
2506
|
break;
|
2629
2507
|
}
|
2630
2508
|
case 8 /* TypeCategory.Union */: {
|
@@ -2650,41 +2528,24 @@ function convertTypeToParamSpecValue(type) {
|
|
2650
2528
|
return newFunction;
|
2651
2529
|
}
|
2652
2530
|
if ((0, types_1.isFunction)(type)) {
|
2531
|
+
// If it's already a ParamSpecValue, return it as is.
|
2532
|
+
if (types_1.FunctionType.isParamSpecValue(type)) {
|
2533
|
+
return type;
|
2534
|
+
}
|
2653
2535
|
const newFunction = types_1.FunctionType.createInstance('', '', '', type.shared.flags | 65536 /* FunctionTypeFlags.ParamSpecValue */, type.shared.docString);
|
2654
2536
|
newFunction.shared.deprecatedMessage = type.shared.deprecatedMessage;
|
2655
2537
|
type.shared.parameters.forEach((param, index) => {
|
2656
|
-
types_1.FunctionType.addParam(newFunction, types_1.FunctionParam.create(param.category, types_1.FunctionType.
|
2538
|
+
types_1.FunctionType.addParam(newFunction, types_1.FunctionParam.create(param.category, types_1.FunctionType.getParamType(type, index), param.flags, param.name, types_1.FunctionType.getParamDefaultType(type, index)));
|
2657
2539
|
});
|
2658
|
-
|
2659
|
-
newFunction.priv.higherOrderTypeVarScopeIds = [...type.priv.higherOrderTypeVarScopeIds];
|
2660
|
-
newFunction.shared.typeVarScopeId = newFunction.priv.higherOrderTypeVarScopeIds.pop();
|
2661
|
-
}
|
2540
|
+
newFunction.shared.typeVarScopeId = type.shared.typeVarScopeId;
|
2662
2541
|
newFunction.priv.constructorTypeVarScopeId = type.priv.constructorTypeVarScopeId;
|
2663
2542
|
return newFunction;
|
2664
2543
|
}
|
2665
2544
|
return types_1.ParamSpecType.getUnknown();
|
2666
2545
|
}
|
2667
|
-
exports.convertTypeToParamSpecValue = convertTypeToParamSpecValue;
|
2668
|
-
// This function calls the setTypeVarType method on the TypeVarContext after
|
2669
|
-
// converting the parameters for use with a ParamSpec.
|
2670
|
-
function setTypeVarType(typeVarContext, typeVar, lowerBound, lowerBoundNoLiterals, upperBound) {
|
2671
|
-
if ((0, types_1.isParamSpec)(typeVar)) {
|
2672
|
-
if (lowerBound) {
|
2673
|
-
lowerBound = convertTypeToParamSpecValue(lowerBound);
|
2674
|
-
}
|
2675
|
-
if (lowerBoundNoLiterals) {
|
2676
|
-
lowerBoundNoLiterals = convertTypeToParamSpecValue(lowerBoundNoLiterals);
|
2677
|
-
}
|
2678
|
-
if (upperBound) {
|
2679
|
-
lowerBound = convertTypeToParamSpecValue(upperBound);
|
2680
|
-
}
|
2681
|
-
}
|
2682
|
-
typeVarContext.setTypeVarType(typeVar, lowerBound, lowerBoundNoLiterals, upperBound);
|
2683
|
-
}
|
2684
|
-
exports.setTypeVarType = setTypeVarType;
|
2685
2546
|
// Converts a FunctionType into a ParamSpec if it consists only of
|
2686
2547
|
// (* args: P.args, ** kwargs: P.kwargs). Otherwise returns the original type.
|
2687
|
-
function
|
2548
|
+
function simplifyFunctionToParamSpec(type) {
|
2688
2549
|
const paramSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(type);
|
2689
2550
|
const withoutParamSpec = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(type);
|
2690
2551
|
let hasParams = withoutParamSpec.shared.parameters.length > 0;
|
@@ -2700,31 +2561,18 @@ function convertParamSpecValueToType(type) {
|
|
2700
2561
|
if (!hasParams && paramSpec) {
|
2701
2562
|
return paramSpec;
|
2702
2563
|
}
|
2703
|
-
|
2704
|
-
const functionType = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | withoutParamSpec.shared.flags);
|
2705
|
-
types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.shared.typeVarScopeId);
|
2706
|
-
types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.priv.higherOrderTypeVarScopeIds);
|
2707
|
-
functionType.priv.constructorTypeVarScopeId = withoutParamSpec.priv.constructorTypeVarScopeId;
|
2708
|
-
withoutParamSpec.shared.parameters.forEach((entry, index) => {
|
2709
|
-
types_1.FunctionType.addParam(functionType, types_1.FunctionParam.create(entry.category, types_1.FunctionType.getEffectiveParamType(withoutParamSpec, index), (entry.flags & types_1.FunctionParamFlags.NameSynthesized) | types_1.FunctionParamFlags.TypeDeclared, entry.name, entry.defaultType));
|
2710
|
-
});
|
2711
|
-
if (paramSpec) {
|
2712
|
-
types_1.FunctionType.addParamSpecVariadics(functionType, paramSpec);
|
2713
|
-
}
|
2714
|
-
functionType.shared.docString = withoutParamSpec.shared.docString;
|
2715
|
-
functionType.shared.deprecatedMessage = withoutParamSpec.shared.deprecatedMessage;
|
2716
|
-
functionType.shared.methodClass = withoutParamSpec.shared.methodClass;
|
2717
|
-
return functionType;
|
2564
|
+
return type;
|
2718
2565
|
}
|
2719
|
-
exports.convertParamSpecValueToType = convertParamSpecValueToType;
|
2720
2566
|
// Recursively walks a type and calls a callback for each TypeVar, allowing
|
2721
2567
|
// it to be replaced with something else.
|
2722
2568
|
class TypeVarTransformer {
|
2723
2569
|
constructor() {
|
2724
|
-
this._isTransformingTypeArg = false;
|
2725
2570
|
this._pendingTypeVarTransformations = new Set();
|
2726
2571
|
this._pendingFunctionTransformations = [];
|
2727
2572
|
}
|
2573
|
+
get pendingTypeVarTransformations() {
|
2574
|
+
return this._pendingTypeVarTransformations;
|
2575
|
+
}
|
2728
2576
|
apply(type, recursionCount) {
|
2729
2577
|
var _a, _b, _c;
|
2730
2578
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
@@ -2765,7 +2613,7 @@ class TypeVarTransformer {
|
|
2765
2613
|
return replacementType;
|
2766
2614
|
});
|
2767
2615
|
if (requiresUpdate) {
|
2768
|
-
return types_1.TypeBase.cloneForTypeAlias(type,
|
2616
|
+
return types_1.TypeBase.cloneForTypeAlias(type, { ...aliasInfo, typeArgs });
|
2769
2617
|
}
|
2770
2618
|
return type;
|
2771
2619
|
}
|
@@ -2774,43 +2622,36 @@ class TypeVarTransformer {
|
|
2774
2622
|
// type variables in the same scope recursively by setting it the scope in the
|
2775
2623
|
// _pendingTypeVarTransformations set.
|
2776
2624
|
if (!this._isTypeVarScopePending(type.priv.scopeId)) {
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2625
|
+
let paramSpecAccess;
|
2626
|
+
// If this is a ParamSpec with a ".args" or ".kwargs" access, strip
|
2627
|
+
// it off for now. We'll add it back later if appropriate.
|
2628
|
+
if ((0, types_1.isParamSpec)(type) && type.priv.paramSpecAccess) {
|
2629
|
+
paramSpecAccess = type.priv.paramSpecAccess;
|
2630
|
+
type = types_1.TypeVarType.cloneForParamSpecAccess(type, /* access */ undefined);
|
2631
|
+
}
|
2632
|
+
replacementType = (_c = this.transformTypeVar(type, recursionCount)) !== null && _c !== void 0 ? _c : type;
|
2633
|
+
if ((0, types_1.isParamSpec)(type) && replacementType !== type) {
|
2634
|
+
replacementType = simplifyFunctionToParamSpec(convertTypeToParamSpecValue(replacementType));
|
2635
|
+
}
|
2636
|
+
// If the original type was a ParamSpec with a ".args" or ".kwargs" access,
|
2637
|
+
// preserve that information in the transformed type.
|
2638
|
+
if (paramSpecAccess) {
|
2639
|
+
if ((0, types_1.isParamSpec)(replacementType)) {
|
2640
|
+
replacementType = types_1.TypeVarType.cloneForParamSpecAccess(replacementType, paramSpecAccess);
|
2781
2641
|
}
|
2782
|
-
|
2783
|
-
|
2784
|
-
const paramSpecType = convertParamSpecValueToType(paramSpecValue);
|
2785
|
-
if (type.priv.paramSpecAccess) {
|
2786
|
-
if ((0, types_1.isParamSpec)(paramSpecType)) {
|
2787
|
-
replacementType = types_1.TypeVarType.cloneForParamSpecAccess(paramSpecType, type.priv.paramSpecAccess);
|
2788
|
-
}
|
2789
|
-
else {
|
2790
|
-
replacementType = types_1.UnknownType.create();
|
2791
|
-
}
|
2792
|
-
}
|
2793
|
-
else {
|
2794
|
-
replacementType = paramSpecType;
|
2795
|
-
}
|
2642
|
+
else {
|
2643
|
+
replacementType = types_1.UnknownType.create();
|
2796
2644
|
}
|
2797
2645
|
}
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
}
|
2808
|
-
}
|
2809
|
-
// If we're transforming a variadic type variable that was in a union,
|
2810
|
-
// expand the union types.
|
2811
|
-
if ((0, types_1.isTypeVarTuple)(type) && type.priv.isVariadicInUnion) {
|
2812
|
-
replacementType = _expandVariadicUnpackedUnion(replacementType);
|
2813
|
-
}
|
2646
|
+
// If we're transforming a TypeVarTuple that was in a union,
|
2647
|
+
// expand the union types.
|
2648
|
+
if ((0, types_1.isTypeVarTuple)(type) && type.priv.isInUnion) {
|
2649
|
+
replacementType = _expandUnpackedTypeVarTupleUnion(replacementType);
|
2650
|
+
}
|
2651
|
+
if (type.priv.scopeId) {
|
2652
|
+
this._pendingTypeVarTransformations.add(type.priv.scopeId);
|
2653
|
+
replacementType = this.apply(replacementType, recursionCount);
|
2654
|
+
this._pendingTypeVarTransformations.delete(type.priv.scopeId);
|
2814
2655
|
}
|
2815
2656
|
}
|
2816
2657
|
return replacementType;
|
@@ -2818,12 +2659,12 @@ class TypeVarTransformer {
|
|
2818
2659
|
if ((0, types_1.isUnion)(type)) {
|
2819
2660
|
const newUnionType = mapSubtypes(type, (subtype) => {
|
2820
2661
|
let transformedType = this.apply(subtype, recursionCount);
|
2821
|
-
// If we're transforming a
|
2822
|
-
// combine the individual types within the
|
2662
|
+
// If we're transforming a TypeVarTuple within a union,
|
2663
|
+
// combine the individual types within the TypeVarTuple.
|
2823
2664
|
if ((0, types_1.isTypeVarTuple)(subtype) && !(0, types_1.isTypeVarTuple)(transformedType)) {
|
2824
2665
|
const subtypesToCombine = [];
|
2825
2666
|
doForEachSubtype(transformedType, (transformedSubtype) => {
|
2826
|
-
subtypesToCombine.push(
|
2667
|
+
subtypesToCombine.push(_expandUnpackedTypeVarTupleUnion(transformedSubtype));
|
2827
2668
|
});
|
2828
2669
|
transformedType = (0, types_1.combineTypes)(subtypesToCombine);
|
2829
2670
|
}
|
@@ -2847,7 +2688,7 @@ class TypeVarTransformer {
|
|
2847
2688
|
this._pendingFunctionTransformations.pop();
|
2848
2689
|
return result;
|
2849
2690
|
}
|
2850
|
-
if ((0, types_1.
|
2691
|
+
if ((0, types_1.isOverloaded)(type)) {
|
2851
2692
|
// Prevent recursion.
|
2852
2693
|
if (this._pendingFunctionTransformations.some((t) => t === type)) {
|
2853
2694
|
return type;
|
@@ -2855,22 +2696,31 @@ class TypeVarTransformer {
|
|
2855
2696
|
this._pendingFunctionTransformations.push(type);
|
2856
2697
|
let requiresUpdate = false;
|
2857
2698
|
// Specialize each of the functions in the overload.
|
2699
|
+
const overloads = types_1.OverloadedType.getOverloads(type);
|
2858
2700
|
const newOverloads = [];
|
2859
|
-
|
2701
|
+
overloads.forEach((entry) => {
|
2860
2702
|
const replacementType = this.transformTypeVarsInFunctionType(entry, recursionCount);
|
2861
2703
|
if ((0, types_1.isFunction)(replacementType)) {
|
2862
2704
|
newOverloads.push(replacementType);
|
2863
2705
|
}
|
2864
2706
|
else {
|
2865
|
-
(0, collectionUtils_1.appendArray)(newOverloads,
|
2707
|
+
(0, collectionUtils_1.appendArray)(newOverloads, types_1.OverloadedType.getOverloads(replacementType));
|
2866
2708
|
}
|
2867
2709
|
if (replacementType !== entry) {
|
2868
2710
|
requiresUpdate = true;
|
2869
2711
|
}
|
2870
2712
|
});
|
2713
|
+
const impl = types_1.OverloadedType.getImplementation(type);
|
2714
|
+
let newImpl = impl;
|
2715
|
+
if (impl) {
|
2716
|
+
newImpl = this.apply(impl, recursionCount);
|
2717
|
+
if (newImpl !== impl) {
|
2718
|
+
requiresUpdate = true;
|
2719
|
+
}
|
2720
|
+
}
|
2871
2721
|
this._pendingFunctionTransformations.pop();
|
2872
2722
|
// Construct a new overload with the specialized function types.
|
2873
|
-
return requiresUpdate ? types_1.
|
2723
|
+
return requiresUpdate ? types_1.OverloadedType.create(newOverloads, newImpl) : type;
|
2874
2724
|
}
|
2875
2725
|
return type;
|
2876
2726
|
}
|
@@ -2880,13 +2730,10 @@ class TypeVarTransformer {
|
|
2880
2730
|
transformTupleTypeVar(paramSpec, recursionCount) {
|
2881
2731
|
return undefined;
|
2882
2732
|
}
|
2883
|
-
transformParamSpec(paramSpec, recursionCount) {
|
2884
|
-
return undefined;
|
2885
|
-
}
|
2886
2733
|
transformUnionSubtype(preTransform, postTransform, recursionCount) {
|
2887
2734
|
return postTransform;
|
2888
2735
|
}
|
2889
|
-
|
2736
|
+
doForEachConstraintSet(callback) {
|
2890
2737
|
// By default, simply return the result of the callback. Subclasses
|
2891
2738
|
// can override this method as they see fit.
|
2892
2739
|
return callback();
|
@@ -2905,15 +2752,14 @@ class TypeVarTransformer {
|
|
2905
2752
|
}
|
2906
2753
|
return updatedType;
|
2907
2754
|
});
|
2908
|
-
return requiresUpdate
|
2909
|
-
? types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParams, newTypeArgs)
|
2910
|
-
: type;
|
2755
|
+
return requiresUpdate ? types_1.TypeBase.cloneForTypeAlias(type, { ...aliasInfo, typeArgs: newTypeArgs }) : type;
|
2911
2756
|
}
|
2912
2757
|
transformConditionalType(type, recursionCount) {
|
2913
2758
|
// By default, do not perform any transform.
|
2914
2759
|
return type;
|
2915
2760
|
}
|
2916
2761
|
transformTypeVarsInClassType(classType, recursionCount) {
|
2762
|
+
var _a;
|
2917
2763
|
const typeParams = types_1.ClassType.getTypeParams(classType);
|
2918
2764
|
// Handle the common case where the class has no type parameters.
|
2919
2765
|
if (typeParams.length === 0 &&
|
@@ -2924,18 +2770,6 @@ class TypeVarTransformer {
|
|
2924
2770
|
let newTypeArgs;
|
2925
2771
|
let newTupleTypeArgs;
|
2926
2772
|
let specializationNeeded = false;
|
2927
|
-
const transformParamSpec = (paramSpec) => {
|
2928
|
-
const paramSpecValue = this.transformParamSpec(paramSpec, recursionCount);
|
2929
|
-
if (paramSpecValue) {
|
2930
|
-
specializationNeeded = true;
|
2931
|
-
return convertParamSpecValueToType(paramSpecValue);
|
2932
|
-
}
|
2933
|
-
else {
|
2934
|
-
return paramSpec;
|
2935
|
-
}
|
2936
|
-
};
|
2937
|
-
const wasTransformingTypeArg = this._isTransformingTypeArg;
|
2938
|
-
this._isTransformingTypeArg = true;
|
2939
2773
|
// If type args were previously provided, specialize them.
|
2940
2774
|
// Handle tuples specially.
|
2941
2775
|
if (types_1.ClassType.isTupleClass(classType)) {
|
@@ -2987,52 +2821,20 @@ class TypeVarTransformer {
|
|
2987
2821
|
}
|
2988
2822
|
}
|
2989
2823
|
if (!newTypeArgs) {
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
// (e.g. Union[Unpack[Vs]]), expand the subtypes into a union here.
|
3000
|
-
if ((0, types_1.isTypeVar)(oldTypeArgType) &&
|
3001
|
-
(0, types_1.isTypeVarTuple)(oldTypeArgType) &&
|
3002
|
-
oldTypeArgType.priv.isVariadicInUnion) {
|
3003
|
-
newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
|
3004
|
-
}
|
3005
|
-
}
|
3006
|
-
return newTypeArgType;
|
3007
|
-
});
|
3008
|
-
}
|
3009
|
-
else {
|
3010
|
-
newTypeArgs = [];
|
3011
|
-
typeParams.forEach((typeParam) => {
|
3012
|
-
let replacementType = typeParam;
|
3013
|
-
if ((0, types_1.isParamSpec)(typeParam)) {
|
3014
|
-
replacementType = transformParamSpec(typeParam);
|
3015
|
-
if (replacementType !== typeParam) {
|
3016
|
-
specializationNeeded = true;
|
3017
|
-
}
|
3018
|
-
}
|
3019
|
-
else {
|
3020
|
-
if (!this._isTypeVarScopePending(typeParam.priv.scopeId)) {
|
3021
|
-
const transformedType = this.transformTypeVar(typeParam, recursionCount);
|
3022
|
-
replacementType = transformedType !== null && transformedType !== void 0 ? transformedType : typeParam;
|
3023
|
-
if (replacementType !== typeParam) {
|
3024
|
-
specializationNeeded = true;
|
3025
|
-
}
|
3026
|
-
else if (transformedType !== undefined && !classType.priv.typeArgs) {
|
3027
|
-
specializationNeeded = true;
|
3028
|
-
}
|
3029
|
-
}
|
2824
|
+
const typeArgs = (_a = classType.priv.typeArgs) !== null && _a !== void 0 ? _a : typeParams;
|
2825
|
+
newTypeArgs = typeArgs.map((oldTypeArgType) => {
|
2826
|
+
let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
|
2827
|
+
if (newTypeArgType !== oldTypeArgType) {
|
2828
|
+
specializationNeeded = true;
|
2829
|
+
// If this was a TypeVarTuple that was part of a union
|
2830
|
+
// (e.g. Union[Unpack[Vs]]), expand the subtypes into a union here.
|
2831
|
+
if ((0, types_1.isTypeVar)(oldTypeArgType) && (0, types_1.isTypeVarTuple)(oldTypeArgType) && oldTypeArgType.priv.isInUnion) {
|
2832
|
+
newTypeArgType = _expandUnpackedTypeVarTupleUnion(newTypeArgType);
|
3030
2833
|
}
|
3031
|
-
|
3032
|
-
|
3033
|
-
}
|
2834
|
+
}
|
2835
|
+
return newTypeArgType;
|
2836
|
+
});
|
3034
2837
|
}
|
3035
|
-
this._isTransformingTypeArg = wasTransformingTypeArg;
|
3036
2838
|
// If specialization wasn't needed, don't allocate a new class.
|
3037
2839
|
if (!specializationNeeded) {
|
3038
2840
|
return classType;
|
@@ -3042,7 +2844,7 @@ class TypeVarTransformer {
|
|
3042
2844
|
/* includeSubclasses */ undefined, newTupleTypeArgs);
|
3043
2845
|
}
|
3044
2846
|
transformTypeVarsInFunctionType(sourceType, recursionCount) {
|
3045
|
-
return this.
|
2847
|
+
return this.doForEachConstraintSet(() => {
|
3046
2848
|
let functionType = sourceType;
|
3047
2849
|
const declaredReturnType = types_1.FunctionType.getEffectiveReturnType(functionType);
|
3048
2850
|
const specializedReturnType = declaredReturnType
|
@@ -3051,32 +2853,31 @@ class TypeVarTransformer {
|
|
3051
2853
|
let typesRequiredSpecialization = declaredReturnType !== specializedReturnType;
|
3052
2854
|
const specializedParams = {
|
3053
2855
|
parameterTypes: [],
|
3054
|
-
|
2856
|
+
parameterDefaultTypes: undefined,
|
3055
2857
|
returnType: specializedReturnType,
|
3056
2858
|
};
|
3057
2859
|
const paramSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(functionType);
|
3058
2860
|
if (paramSpec) {
|
3059
|
-
const paramSpecType = this.
|
2861
|
+
const paramSpecType = this.transformTypeVar(paramSpec, recursionCount);
|
3060
2862
|
if (paramSpecType) {
|
3061
|
-
const
|
3062
|
-
|
2863
|
+
const paramSpecValue = convertTypeToParamSpecValue(paramSpecType);
|
2864
|
+
const transformedParamSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(paramSpecValue);
|
2865
|
+
if (paramSpecValue.shared.parameters.length > 0 ||
|
3063
2866
|
!transformedParamSpec ||
|
3064
2867
|
!(0, types_1.isTypeSame)(paramSpec, transformedParamSpec)) {
|
3065
|
-
functionType = types_1.FunctionType.applyParamSpecValue(functionType,
|
2868
|
+
functionType = types_1.FunctionType.applyParamSpecValue(functionType, paramSpecValue);
|
3066
2869
|
}
|
3067
2870
|
}
|
3068
2871
|
}
|
3069
2872
|
let variadicParamIndex;
|
3070
2873
|
let variadicTypesToUnpack;
|
3071
2874
|
const specializedDefaultArgs = [];
|
3072
|
-
const wasTransformingTypeArg = this._isTransformingTypeArg;
|
3073
|
-
this._isTransformingTypeArg = true;
|
3074
2875
|
for (let i = 0; i < functionType.shared.parameters.length; i++) {
|
3075
|
-
const paramType = types_1.FunctionType.
|
2876
|
+
const paramType = types_1.FunctionType.getParamType(functionType, i);
|
3076
2877
|
const specializedType = this.apply(paramType, recursionCount);
|
3077
2878
|
specializedParams.parameterTypes.push(specializedType);
|
3078
2879
|
// Do we need to specialize the default argument type for this parameter?
|
3079
|
-
let defaultArgType = types_1.FunctionType.
|
2880
|
+
let defaultArgType = types_1.FunctionType.getParamDefaultType(functionType, i);
|
3080
2881
|
if (defaultArgType) {
|
3081
2882
|
const specializedArgType = this.apply(defaultArgType, recursionCount);
|
3082
2883
|
if (specializedArgType !== defaultArgType) {
|
@@ -3121,12 +2922,11 @@ class TypeVarTransformer {
|
|
3121
2922
|
functionType.priv.strippedFirstParamType = newStrippedType;
|
3122
2923
|
}
|
3123
2924
|
}
|
3124
|
-
this._isTransformingTypeArg = wasTransformingTypeArg;
|
3125
2925
|
if (!typesRequiredSpecialization) {
|
3126
2926
|
return functionType;
|
3127
2927
|
}
|
3128
2928
|
if (specializedDefaultArgs.some((t) => t !== undefined)) {
|
3129
|
-
specializedParams.
|
2929
|
+
specializedParams.parameterDefaultTypes = specializedDefaultArgs;
|
3130
2930
|
}
|
3131
2931
|
// If there was no unpacked variadic type variable, we're done.
|
3132
2932
|
if (!variadicTypesToUnpack) {
|
@@ -3158,7 +2958,7 @@ class TypeVarTransformer {
|
|
3158
2958
|
}
|
3159
2959
|
}
|
3160
2960
|
else {
|
3161
|
-
const param =
|
2961
|
+
const param = functionType.shared.parameters[index];
|
3162
2962
|
if ((0, types_1.isKeywordOnlySeparator)(param)) {
|
3163
2963
|
insertKeywordOnlySeparator = false;
|
3164
2964
|
}
|
@@ -3166,17 +2966,15 @@ class TypeVarTransformer {
|
|
3166
2966
|
insertKeywordOnlySeparator = false;
|
3167
2967
|
}
|
3168
2968
|
// Insert a keyword-only separator parameter if we previously
|
3169
|
-
// unpacked a
|
2969
|
+
// unpacked a TypeVarTuple.
|
3170
2970
|
if (param.category === 0 /* ParamCategory.Simple */ && param.name && insertKeywordOnlySeparator) {
|
3171
2971
|
types_1.FunctionType.addKeywordOnlyParamSeparator(newFunctionType);
|
3172
2972
|
insertKeywordOnlySeparator = false;
|
3173
2973
|
}
|
3174
|
-
param.type = paramType;
|
3175
|
-
if (param.name && types_1.FunctionParam.isNameSynthesized(param)) {
|
3176
|
-
param.name = `__p${newFunctionType.shared.parameters.length}`;
|
3177
|
-
}
|
3178
2974
|
if (param.category !== 0 /* ParamCategory.Simple */ || param.name || !swallowPositionOnlySeparator) {
|
3179
|
-
types_1.FunctionType.addParam(newFunctionType, param)
|
2975
|
+
types_1.FunctionType.addParam(newFunctionType, types_1.FunctionParam.create(param.category, paramType, param.flags, param.name && types_1.FunctionParam.isNameSynthesized(param)
|
2976
|
+
? `__p${newFunctionType.shared.parameters.length}`
|
2977
|
+
: param.name, types_1.FunctionType.getParamDefaultType(functionType, index)));
|
3180
2978
|
}
|
3181
2979
|
}
|
3182
2980
|
});
|
@@ -3188,18 +2986,7 @@ class TypeVarTransformer {
|
|
3188
2986
|
return !!typeVarScopeId && this._pendingTypeVarTransformations.has(typeVarScopeId);
|
3189
2987
|
}
|
3190
2988
|
}
|
3191
|
-
|
3192
|
-
class TypeVarAnyReplacer extends TypeVarTransformer {
|
3193
|
-
constructor() {
|
3194
|
-
super();
|
3195
|
-
}
|
3196
|
-
transformTypeVar(typeVar) {
|
3197
|
-
return types_1.AnyType.create();
|
3198
|
-
}
|
3199
|
-
transformParamSpec(paramSpec) {
|
3200
|
-
return types_1.ParamSpecType.getUnknown();
|
3201
|
-
}
|
3202
|
-
}
|
2989
|
+
exports.TypeVarTransformer = TypeVarTransformer;
|
3203
2990
|
// For a TypeVar with a default type, validates whether the default type is using
|
3204
2991
|
// any other TypeVars that are not currently in scope.
|
3205
2992
|
class TypeVarDefaultValidator extends TypeVarTransformer {
|
@@ -3210,18 +2997,11 @@ class TypeVarDefaultValidator extends TypeVarTransformer {
|
|
3210
2997
|
}
|
3211
2998
|
transformTypeVar(typeVar) {
|
3212
2999
|
const replacementType = this._liveTypeParams.find((param) => param.shared.name === typeVar.shared.name);
|
3213
|
-
if (!replacementType || (0, types_1.isParamSpec)(replacementType)) {
|
3000
|
+
if (!replacementType || (0, types_1.isParamSpec)(replacementType) !== (0, types_1.isParamSpec)(typeVar)) {
|
3214
3001
|
this._invalidTypeVars.add(typeVar.shared.name);
|
3215
3002
|
}
|
3216
3003
|
return types_1.UnknownType.create();
|
3217
3004
|
}
|
3218
|
-
transformParamSpec(paramSpec) {
|
3219
|
-
const replacementType = this._liveTypeParams.find((param) => param.shared.name === paramSpec.shared.name);
|
3220
|
-
if (!replacementType || !(0, types_1.isParamSpec)(replacementType)) {
|
3221
|
-
this._invalidTypeVars.add(paramSpec.shared.name);
|
3222
|
-
}
|
3223
|
-
return undefined;
|
3224
|
-
}
|
3225
3005
|
}
|
3226
3006
|
class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
|
3227
3007
|
constructor(_signatureTracker, _expressionOffset) {
|
@@ -3250,26 +3030,27 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
|
|
3250
3030
|
offsetIndex = existingSignature.expressionOffsets.length;
|
3251
3031
|
}
|
3252
3032
|
if (offsetIndex > 0) {
|
3253
|
-
const
|
3033
|
+
const solution = new constraintSolution_1.ConstraintSolution();
|
3254
3034
|
// Create new type variables with the same scope but with
|
3255
3035
|
// different (unique) names.
|
3256
3036
|
sourceType.shared.typeParams.forEach((typeParam) => {
|
3257
3037
|
if (typeParam.priv.scopeType === 1 /* TypeVarScopeType.Function */) {
|
3258
3038
|
const replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.shared.name}(${offsetIndex})`);
|
3259
|
-
|
3039
|
+
solution.setType(typeParam, replacement);
|
3260
3040
|
}
|
3261
3041
|
});
|
3262
|
-
updatedSourceType = applySolvedTypeVars(sourceType,
|
3263
|
-
(0, debug_1.assert)((0, types_1.isFunction)(updatedSourceType) || (0, types_1.
|
3042
|
+
updatedSourceType = applySolvedTypeVars(sourceType, solution);
|
3043
|
+
(0, debug_1.assert)((0, types_1.isFunction)(updatedSourceType) || (0, types_1.isOverloaded)(updatedSourceType));
|
3264
3044
|
}
|
3265
3045
|
}
|
3266
3046
|
this._signatureTracker.addSignature(sourceType, this._expressionOffset);
|
3267
3047
|
return updatedSourceType;
|
3268
3048
|
}
|
3269
3049
|
}
|
3270
|
-
// Replaces the
|
3271
|
-
//
|
3272
|
-
|
3050
|
+
// Replaces the free type vars within a type with their corresponding bound
|
3051
|
+
// type vars if they are in one of the specified scopes. If undefined is
|
3052
|
+
// passed for the scopeIds list, all free type vars are replaced.
|
3053
|
+
class BoundTypeVarTransform extends TypeVarTransformer {
|
3273
3054
|
constructor(_scopeIds) {
|
3274
3055
|
super();
|
3275
3056
|
this._scopeIds = _scopeIds;
|
@@ -3280,35 +3061,30 @@ class InternalScopeUpdateTransform extends TypeVarTransformer {
|
|
3280
3061
|
}
|
3281
3062
|
return undefined;
|
3282
3063
|
}
|
3283
|
-
transformParamSpec(paramSpec) {
|
3284
|
-
if (this._isTypeVarInScope(paramSpec)) {
|
3285
|
-
return convertTypeToParamSpecValue(this._replaceTypeVar(paramSpec));
|
3286
|
-
}
|
3287
|
-
return undefined;
|
3288
|
-
}
|
3289
3064
|
_isTypeVarInScope(typeVar) {
|
3290
|
-
|
3065
|
+
if (!typeVar.priv.scopeId) {
|
3066
|
+
return false;
|
3067
|
+
}
|
3068
|
+
// If no scopeIds were specified, transform all Type Vars.
|
3069
|
+
if (!this._scopeIds) {
|
3070
|
+
return true;
|
3071
|
+
}
|
3072
|
+
return this._scopeIds.includes(typeVar.priv.scopeId);
|
3291
3073
|
}
|
3292
3074
|
_replaceTypeVar(typeVar) {
|
3293
|
-
return types_1.TypeVarType.
|
3075
|
+
return types_1.TypeVarType.cloneAsBound(typeVar);
|
3294
3076
|
}
|
3295
3077
|
}
|
3296
|
-
// Replaces the
|
3297
|
-
//
|
3298
|
-
class
|
3078
|
+
// Replaces the bound type vars within a type with their corresponding
|
3079
|
+
// free type vars.
|
3080
|
+
class FreeTypeVarTransform extends TypeVarTransformer {
|
3299
3081
|
constructor(_scopeIds) {
|
3300
3082
|
super();
|
3301
3083
|
this._scopeIds = _scopeIds;
|
3302
3084
|
}
|
3303
3085
|
transformTypeVar(typeVar) {
|
3304
|
-
if (typeVar.priv.
|
3305
|
-
return typeVar.priv.
|
3306
|
-
}
|
3307
|
-
return undefined;
|
3308
|
-
}
|
3309
|
-
transformParamSpec(paramSpec) {
|
3310
|
-
if (paramSpec.priv.externalTypeVar && this._isTypeVarInScope(paramSpec.priv.externalTypeVar)) {
|
3311
|
-
return convertTypeToParamSpecValue(paramSpec.priv.externalTypeVar);
|
3086
|
+
if (typeVar.priv.freeTypeVar && this._isTypeVarInScope(typeVar.priv.freeTypeVar)) {
|
3087
|
+
return typeVar.priv.freeTypeVar;
|
3312
3088
|
}
|
3313
3089
|
return undefined;
|
3314
3090
|
}
|
@@ -3322,144 +3098,120 @@ class ExternalScopeUpdateTransform extends TypeVarTransformer {
|
|
3322
3098
|
// Specializes a (potentially generic) type by substituting
|
3323
3099
|
// type variables from a type var map.
|
3324
3100
|
class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
3325
|
-
constructor(
|
3101
|
+
constructor(_solution, _options) {
|
3326
3102
|
super();
|
3327
|
-
this.
|
3103
|
+
this._solution = _solution;
|
3328
3104
|
this._options = _options;
|
3329
3105
|
this._isSolvingDefaultType = false;
|
3330
3106
|
}
|
3331
3107
|
transformTypeVar(typeVar, recursionCount) {
|
3332
|
-
var _a, _b;
|
3333
|
-
const solutionSet = this.
|
3334
|
-
// If
|
3335
|
-
|
3336
|
-
|
3337
|
-
let replacement = solutionSet.getTypeVarType(typeVar, !!this._options.useLowerBoundOnly);
|
3338
|
-
// If there was no lower bound but there is an upper bound that
|
3339
|
-
// contains literals or a TypeVar, we'll use the upper bound even if
|
3340
|
-
// "useLowerBoundOnly" is specified.
|
3341
|
-
if (!replacement && this._options.useLowerBoundOnly) {
|
3342
|
-
const wideType = solutionSet.getTypeVarType(typeVar);
|
3343
|
-
if (wideType) {
|
3344
|
-
if ((0, types_1.isTypeVar)(wideType) || containsLiteralType(wideType, /* includeTypeArgs */ true)) {
|
3345
|
-
replacement = wideType;
|
3346
|
-
}
|
3347
|
-
}
|
3348
|
-
}
|
3108
|
+
var _a, _b, _c;
|
3109
|
+
const solutionSet = this._solution.getSolutionSet((_a = this._activeConstraintSetIndex) !== null && _a !== void 0 ? _a : 0);
|
3110
|
+
// If we're solving a default type, handle type variables with no scope ID.
|
3111
|
+
if (this._isSolvingDefaultType && !typeVar.priv.scopeId) {
|
3112
|
+
const replacement = this._getReplacementForDefaultByName(typeVar, solutionSet);
|
3349
3113
|
if (replacement) {
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3114
|
+
return replacement;
|
3115
|
+
}
|
3116
|
+
if (typeVar.shared.isDefaultExplicit) {
|
3117
|
+
return this.apply(typeVar.shared.defaultType, recursionCount);
|
3118
|
+
}
|
3119
|
+
return types_1.UnknownType.create();
|
3120
|
+
}
|
3121
|
+
if (!this._shouldReplaceTypeVar(typeVar)) {
|
3122
|
+
return undefined;
|
3123
|
+
}
|
3124
|
+
let replacement = solutionSet.getType(typeVar);
|
3125
|
+
if (replacement) {
|
3126
|
+
// No more processing is needed for ParamSpecs.
|
3127
|
+
if ((0, types_1.isParamSpec)(typeVar)) {
|
3128
|
+
return replacement;
|
3129
|
+
}
|
3130
|
+
if (types_1.TypeBase.isInstantiable(typeVar)) {
|
3131
|
+
if ((0, types_1.isAnyOrUnknown)(replacement) &&
|
3132
|
+
this._options.typeClassType &&
|
3133
|
+
(0, types_1.isInstantiableClass)(this._options.typeClassType)) {
|
3134
|
+
replacement = types_1.ClassType.specialize(types_1.ClassType.cloneAsInstance(this._options.typeClassType), [
|
3135
|
+
replacement,
|
3136
|
+
]);
|
3361
3137
|
}
|
3362
3138
|
else {
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3370
|
-
|
3371
|
-
|
3372
|
-
|
3373
|
-
|
3374
|
-
|
3375
|
-
|
3376
|
-
|
3377
|
-
|
3378
|
-
|
3379
|
-
|
3139
|
+
replacement = convertToInstantiable(replacement, /* includeSubclasses */ false);
|
3140
|
+
}
|
3141
|
+
}
|
3142
|
+
else {
|
3143
|
+
// If the TypeVar is not instantiable (i.e. not a type[T]), then
|
3144
|
+
// it represents an instance of a type. If the replacement includes
|
3145
|
+
// a generic class that has not been specialized, specialize it
|
3146
|
+
// now with default type arguments.
|
3147
|
+
replacement = mapSubtypes(replacement, (subtype) => {
|
3148
|
+
if ((0, types_1.isClassInstance)(subtype)) {
|
3149
|
+
// If the includeSubclasses wasn't set, force it to be set by
|
3150
|
+
// converting to/from an instantiable.
|
3151
|
+
if (!subtype.priv.includeSubclasses) {
|
3152
|
+
subtype = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneAsInstantiable(subtype));
|
3153
|
+
}
|
3154
|
+
if (subtype.shared.typeParams && !subtype.priv.typeArgs) {
|
3155
|
+
if (this._options.replaceUnsolved) {
|
3156
|
+
return this._options.replaceUnsolved.useUnknown
|
3157
|
+
? specializeWithUnknownTypeArgs(subtype, this._options.replaceUnsolved.tupleClassType)
|
3158
|
+
: specializeWithDefaultTypeArgs(subtype);
|
3380
3159
|
}
|
3381
3160
|
}
|
3382
|
-
|
3383
|
-
|
3384
|
-
}
|
3385
|
-
if ((0, types_1.isTypeVarTuple)(replacement) && (0, types_1.isTypeVarTuple)(typeVar) && typeVar.priv.isVariadicUnpacked) {
|
3386
|
-
return types_1.TypeVarType.cloneForUnpacked(replacement, typeVar.priv.isVariadicInUnion);
|
3387
|
-
}
|
3388
|
-
// If this isn't a variadic typeVar, combine all of the tuple
|
3389
|
-
// type args into a common type.
|
3390
|
-
if (!(0, types_1.isTypeVarTuple)(typeVar) &&
|
3391
|
-
(0, types_1.isClassInstance)(replacement) &&
|
3392
|
-
replacement.priv.tupleTypeArgs &&
|
3393
|
-
replacement.priv.isUnpacked) {
|
3394
|
-
replacement = combineTupleTypeArgs(replacement.priv.tupleTypeArgs);
|
3395
|
-
}
|
3396
|
-
if (!(0, types_1.isTypeVar)(replacement) ||
|
3397
|
-
!replacement.priv.isInScopePlaceholder ||
|
3398
|
-
!this._options.unknownIfNotFound) {
|
3399
|
-
return replacement;
|
3400
|
-
}
|
3161
|
+
}
|
3162
|
+
return subtype;
|
3163
|
+
});
|
3401
3164
|
}
|
3402
|
-
|
3403
|
-
|
3404
|
-
// default or Unknown.
|
3405
|
-
let useDefaultOrUnknown = false;
|
3406
|
-
if (this._options.unknownIfNotFound) {
|
3407
|
-
const exemptTypeVars = (_b = this._options.unknownExemptTypeVars) !== null && _b !== void 0 ? _b : [];
|
3408
|
-
const typeVarInstance = types_1.TypeBase.isInstance(typeVar) ? typeVar : types_1.TypeVarType.cloneAsInstance(typeVar);
|
3409
|
-
if (!exemptTypeVars.some((t) => (0, types_1.isTypeSame)(t, typeVarInstance))) {
|
3410
|
-
useDefaultOrUnknown = true;
|
3411
|
-
}
|
3165
|
+
if ((0, types_1.isTypeVarTuple)(replacement) && (0, types_1.isTypeVarTuple)(typeVar) && typeVar.priv.isUnpacked) {
|
3166
|
+
return types_1.TypeVarType.cloneForUnpacked(replacement, typeVar.priv.isInUnion);
|
3412
3167
|
}
|
3413
|
-
|
3414
|
-
|
3168
|
+
// If this isn't a TypeVarTuple, combine all of the tuple
|
3169
|
+
// type args into a common type.
|
3170
|
+
if (!(0, types_1.isTypeVarTuple)(typeVar) &&
|
3171
|
+
(0, types_1.isClassInstance)(replacement) &&
|
3172
|
+
replacement.priv.tupleTypeArgs &&
|
3173
|
+
replacement.priv.isUnpacked) {
|
3174
|
+
replacement = combineTupleTypeArgs(replacement.priv.tupleTypeArgs);
|
3415
3175
|
}
|
3416
|
-
if (
|
3417
|
-
|
3418
|
-
if (typeVar.shared.isDefaultExplicit && !this._options.useUnknownOverDefault) {
|
3419
|
-
return this._solveDefaultType(typeVar, recursionCount);
|
3420
|
-
}
|
3421
|
-
return getUnknownForTypeVar(typeVar, this._options.tupleClassType);
|
3176
|
+
if (!(0, types_1.isTypeVar)(replacement) || !types_1.TypeVarType.isUnification(replacement) || !this._options.replaceUnsolved) {
|
3177
|
+
return replacement;
|
3422
3178
|
}
|
3423
3179
|
}
|
3424
|
-
|
3425
|
-
|
3426
|
-
const replacementEntry = solutionSet
|
3427
|
-
.getTypeVars()
|
3428
|
-
.find((entry) => entry.typeVar.shared.name === typeVar.shared.name);
|
3429
|
-
if (replacementEntry) {
|
3430
|
-
return solutionSet.getTypeVarType(replacementEntry.typeVar);
|
3431
|
-
}
|
3432
|
-
if (typeVar.shared.isDefaultExplicit) {
|
3433
|
-
return this.apply(typeVar.shared.defaultType, recursionCount);
|
3434
|
-
}
|
3435
|
-
return types_1.UnknownType.create();
|
3180
|
+
if (!this._shouldReplaceUnsolvedTypeVar(typeVar)) {
|
3181
|
+
return undefined;
|
3436
3182
|
}
|
3437
|
-
|
3183
|
+
// Use the default value if there is one.
|
3184
|
+
if (typeVar.shared.isDefaultExplicit && !((_b = this._options.replaceUnsolved) === null || _b === void 0 ? void 0 : _b.useUnknown)) {
|
3185
|
+
return this._solveDefaultType(typeVar, recursionCount);
|
3186
|
+
}
|
3187
|
+
return getUnknownForTypeVar(typeVar, (_c = this._options.replaceUnsolved) === null || _c === void 0 ? void 0 : _c.tupleClassType);
|
3438
3188
|
}
|
3439
3189
|
transformUnionSubtype(preTransform, postTransform) {
|
3440
|
-
var _a;
|
3190
|
+
var _a, _b;
|
3441
3191
|
// If a union contains unsolved TypeVars within scope, eliminate them
|
3442
3192
|
// unless this results in an empty union. This elimination is needed
|
3443
3193
|
// in cases where TypeVars can go unsolved due to unions in parameter
|
3444
3194
|
// annotations, like this:
|
3445
3195
|
// def test(x: Union[str, T]) -> Union[str, T]
|
3446
|
-
if (this._options.eliminateUnsolvedInUnions) {
|
3196
|
+
if ((_a = this._options.replaceUnsolved) === null || _a === void 0 ? void 0 : _a.eliminateUnsolvedInUnions) {
|
3447
3197
|
if ((0, types_1.isTypeVar)(preTransform) &&
|
3448
|
-
preTransform
|
3449
|
-
this.
|
3450
|
-
const solutionSet = this.
|
3451
|
-
const typeVarType = solutionSet.
|
3198
|
+
this._shouldReplaceTypeVar(preTransform) &&
|
3199
|
+
this._shouldReplaceUnsolvedTypeVar(preTransform)) {
|
3200
|
+
const solutionSet = this._solution.getSolutionSet((_b = this._activeConstraintSetIndex) !== null && _b !== void 0 ? _b : 0);
|
3201
|
+
const typeVarType = solutionSet.getType(preTransform);
|
3452
3202
|
// Did the TypeVar remain unsolved?
|
3453
|
-
if (!typeVarType || ((0, types_1.isTypeVar)(typeVarType) &&
|
3203
|
+
if (!typeVarType || ((0, types_1.isTypeVar)(typeVarType) && types_1.TypeVarType.isUnification(typeVarType))) {
|
3454
3204
|
// If the TypeVar was not transformed, then it was unsolved,
|
3455
3205
|
// and we'll eliminate it.
|
3456
3206
|
if (preTransform === postTransform) {
|
3457
3207
|
return undefined;
|
3458
3208
|
}
|
3459
|
-
// If
|
3209
|
+
// If useDefaultForUnsolved or useUnknownForUnsolved is true, the postTransform type will
|
3460
3210
|
// be Unknown, which we want to eliminate.
|
3461
|
-
if (
|
3462
|
-
|
3211
|
+
if (this._options.replaceUnsolved) {
|
3212
|
+
if ((0, types_1.isUnknown)(postTransform)) {
|
3213
|
+
return undefined;
|
3214
|
+
}
|
3463
3215
|
}
|
3464
3216
|
}
|
3465
3217
|
}
|
@@ -3468,84 +3220,41 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3468
3220
|
}
|
3469
3221
|
transformTupleTypeVar(typeVar) {
|
3470
3222
|
var _a;
|
3471
|
-
if (!
|
3223
|
+
if (!this._shouldReplaceTypeVar(typeVar)) {
|
3472
3224
|
const defaultType = typeVar.shared.defaultType;
|
3473
3225
|
if (typeVar.shared.isDefaultExplicit && (0, types_1.isClassInstance)(defaultType) && defaultType.priv.tupleTypeArgs) {
|
3474
3226
|
return defaultType.priv.tupleTypeArgs;
|
3475
3227
|
}
|
3476
3228
|
return undefined;
|
3477
3229
|
}
|
3478
|
-
const solutionSet = this.
|
3479
|
-
const value = solutionSet.
|
3230
|
+
const solutionSet = this._solution.getSolutionSet((_a = this._activeConstraintSetIndex) !== null && _a !== void 0 ? _a : 0);
|
3231
|
+
const value = solutionSet.getType(typeVar);
|
3480
3232
|
if (value && (0, types_1.isClassInstance)(value) && value.priv.tupleTypeArgs && (0, types_1.isUnpackedClass)(value)) {
|
3481
3233
|
return value.priv.tupleTypeArgs;
|
3482
3234
|
}
|
3483
3235
|
return undefined;
|
3484
3236
|
}
|
3485
|
-
transformParamSpec(paramSpec, recursionCount) {
|
3486
|
-
var _a, _b;
|
3487
|
-
const solutionSet = this._typeVarContext.getSolutionSet((_a = this._activeSolutionSetIndex) !== null && _a !== void 0 ? _a : 0);
|
3488
|
-
// If we're solving a default type, handle param specs with no scope ID.
|
3489
|
-
if (this._isSolvingDefaultType && !paramSpec.priv.scopeId) {
|
3490
|
-
const replacementEntry = solutionSet
|
3491
|
-
.getTypeVars()
|
3492
|
-
.find((entry) => entry.typeVar.shared.name === paramSpec.shared.name);
|
3493
|
-
if (replacementEntry && (0, types_1.isParamSpec)(replacementEntry.typeVar)) {
|
3494
|
-
return solutionSet.getTypeVarType(replacementEntry.typeVar);
|
3495
|
-
}
|
3496
|
-
if (paramSpec.shared.isDefaultExplicit) {
|
3497
|
-
return convertTypeToParamSpecValue(this.apply(paramSpec.shared.defaultType, recursionCount));
|
3498
|
-
}
|
3499
|
-
return types_1.ParamSpecType.getUnknown();
|
3500
|
-
}
|
3501
|
-
if (!paramSpec.priv.scopeId || !this._typeVarContext.hasSolveForScope(paramSpec.priv.scopeId)) {
|
3502
|
-
return undefined;
|
3503
|
-
}
|
3504
|
-
const transformedParamSpec = solutionSet.getTypeVarType(paramSpec);
|
3505
|
-
if (transformedParamSpec) {
|
3506
|
-
return transformedParamSpec;
|
3507
|
-
}
|
3508
|
-
let useDefaultOrUnknown = false;
|
3509
|
-
if (this._options.unknownIfNotFound) {
|
3510
|
-
const exemptTypeVars = (_b = this._options.unknownExemptTypeVars) !== null && _b !== void 0 ? _b : [];
|
3511
|
-
if (!exemptTypeVars.some((t) => (0, types_1.isTypeSame)(t, paramSpec, { ignoreTypeFlags: true }))) {
|
3512
|
-
useDefaultOrUnknown = true;
|
3513
|
-
}
|
3514
|
-
}
|
3515
|
-
else if (this._options.applyInScopePlaceholders && paramSpec.priv.isInScopePlaceholder) {
|
3516
|
-
useDefaultOrUnknown = true;
|
3517
|
-
}
|
3518
|
-
if (useDefaultOrUnknown) {
|
3519
|
-
// Use the default value if there is one.
|
3520
|
-
if (paramSpec.shared.isDefaultExplicit && !this._options.useUnknownOverDefault) {
|
3521
|
-
return convertTypeToParamSpecValue(this._solveDefaultType(paramSpec, recursionCount));
|
3522
|
-
}
|
3523
|
-
// Convert to the ParamSpec equivalent of "Unknown".
|
3524
|
-
return types_1.ParamSpecType.getUnknown();
|
3525
|
-
}
|
3526
|
-
return undefined;
|
3527
|
-
}
|
3528
3237
|
transformConditionalType(type, recursionCount) {
|
3529
3238
|
var _a, _b, _c, _d;
|
3530
3239
|
if (!((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition)) {
|
3531
3240
|
return type;
|
3532
3241
|
}
|
3533
|
-
const solutionSet = this.
|
3242
|
+
const solutionSet = this._solution.getSolutionSet((_b = this._activeConstraintSetIndex) !== null && _b !== void 0 ? _b : 0);
|
3534
3243
|
for (const condition of type.props.condition) {
|
3535
3244
|
// This doesn't apply to bound type variables.
|
3536
|
-
if (condition.typeVar
|
3245
|
+
if (!types_1.TypeVarType.hasConstraints(condition.typeVar)) {
|
3537
3246
|
continue;
|
3538
3247
|
}
|
3539
|
-
const conditionTypeVar = (_d = (_c = condition.typeVar.priv) === null || _c === void 0 ? void 0 : _c.
|
3540
|
-
const
|
3541
|
-
if (!
|
3248
|
+
const conditionTypeVar = (_d = (_c = condition.typeVar.priv) === null || _c === void 0 ? void 0 : _c.freeTypeVar) !== null && _d !== void 0 ? _d : condition.typeVar;
|
3249
|
+
const replacement = solutionSet.getType(conditionTypeVar);
|
3250
|
+
if (!replacement || condition.constraintIndex >= conditionTypeVar.shared.constraints.length) {
|
3542
3251
|
continue;
|
3543
3252
|
}
|
3544
|
-
const value = solutionSet.
|
3253
|
+
const value = solutionSet.getType(conditionTypeVar);
|
3545
3254
|
if (!value) {
|
3546
3255
|
continue;
|
3547
3256
|
}
|
3548
|
-
const constraintType =
|
3257
|
+
const constraintType = conditionTypeVar.shared.constraints[condition.constraintIndex];
|
3549
3258
|
// If this violates the constraint, substitute a Never type.
|
3550
3259
|
if (!(0, types_1.isTypeSame)(constraintType, value)) {
|
3551
3260
|
return types_1.NeverType.createNever();
|
@@ -3553,19 +3262,19 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3553
3262
|
}
|
3554
3263
|
return type;
|
3555
3264
|
}
|
3556
|
-
|
3557
|
-
const
|
3265
|
+
doForEachConstraintSet(callback) {
|
3266
|
+
const solutionSets = this._solution.getSolutionSets();
|
3558
3267
|
// Handle the common case where there are not multiple signature contexts.
|
3559
|
-
if (
|
3268
|
+
if (solutionSets.length <= 1) {
|
3560
3269
|
return callback();
|
3561
3270
|
}
|
3562
3271
|
// Loop through all of the signature contexts in the type var context
|
3563
3272
|
// to create an overload type.
|
3564
|
-
const overloadTypes =
|
3565
|
-
this.
|
3273
|
+
const overloadTypes = solutionSets.map((_, index) => {
|
3274
|
+
this._activeConstraintSetIndex = index;
|
3566
3275
|
return callback();
|
3567
3276
|
});
|
3568
|
-
this.
|
3277
|
+
this._activeConstraintSetIndex = undefined;
|
3569
3278
|
const filteredOverloads = [];
|
3570
3279
|
doForEachSubtype((0, types_1.combineTypes)(overloadTypes), (subtype) => {
|
3571
3280
|
(0, debug_1.assert)((0, types_1.isFunction)(subtype));
|
@@ -3575,7 +3284,51 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3575
3284
|
if (filteredOverloads.length === 1) {
|
3576
3285
|
return filteredOverloads[0];
|
3577
3286
|
}
|
3578
|
-
return types_1.
|
3287
|
+
return types_1.OverloadedType.create(filteredOverloads);
|
3288
|
+
}
|
3289
|
+
// Handle the case where we need the default replacement value for a typeVar
|
3290
|
+
// that has no scope and therefore doesn't have an assigned scopeID. We'll
|
3291
|
+
// look it up by name in the solution set. This is a bit hacky because there
|
3292
|
+
// could be multiple typeVars with the same name, but we'll assume that this
|
3293
|
+
// won't happen.
|
3294
|
+
_getReplacementForDefaultByName(typeVar, solutionSet) {
|
3295
|
+
let replacementValue;
|
3296
|
+
const partialScopeId = `${typeVar.shared.name}.`;
|
3297
|
+
solutionSet.doForEachTypeVar((value, typeVarId) => {
|
3298
|
+
if (typeVarId.startsWith(partialScopeId)) {
|
3299
|
+
replacementValue = value;
|
3300
|
+
}
|
3301
|
+
});
|
3302
|
+
return replacementValue;
|
3303
|
+
}
|
3304
|
+
_shouldReplaceTypeVar(typeVar) {
|
3305
|
+
if (!typeVar.priv.scopeId || types_1.TypeVarType.isBound(typeVar)) {
|
3306
|
+
return false;
|
3307
|
+
}
|
3308
|
+
return true;
|
3309
|
+
}
|
3310
|
+
_shouldReplaceUnsolvedTypeVar(typeVar) {
|
3311
|
+
var _a;
|
3312
|
+
// Never replace nested TypeVars with unknown.
|
3313
|
+
if (this.pendingTypeVarTransformations.size > 0) {
|
3314
|
+
return false;
|
3315
|
+
}
|
3316
|
+
if (!typeVar.priv.scopeId) {
|
3317
|
+
return false;
|
3318
|
+
}
|
3319
|
+
if (!this._options.replaceUnsolved) {
|
3320
|
+
return false;
|
3321
|
+
}
|
3322
|
+
if (!this._options.replaceUnsolved.scopeIds.includes(typeVar.priv.scopeId)) {
|
3323
|
+
return false;
|
3324
|
+
}
|
3325
|
+
const exemptTypeVars = (_a = this._options.replaceUnsolved) === null || _a === void 0 ? void 0 : _a.unsolvedExemptTypeVars;
|
3326
|
+
if (exemptTypeVars) {
|
3327
|
+
if (exemptTypeVars.some((t) => (0, types_1.isTypeSame)(t, typeVar, { ignoreTypeFlags: true }))) {
|
3328
|
+
return false;
|
3329
|
+
}
|
3330
|
+
}
|
3331
|
+
return true;
|
3579
3332
|
}
|
3580
3333
|
_solveDefaultType(typeVar, recursionCount) {
|
3581
3334
|
const defaultType = typeVar.shared.defaultType;
|
@@ -3594,46 +3347,12 @@ class ExpectedTypeTransformer extends TypeVarTransformer {
|
|
3594
3347
|
}
|
3595
3348
|
transformTypeVar(typeVar) {
|
3596
3349
|
if (!this._isTypeVarLive(typeVar)) {
|
3597
|
-
return types_1.TypeVarType.
|
3598
|
-
}
|
3599
|
-
return undefined;
|
3600
|
-
}
|
3601
|
-
transformParamSpec(paramSpec) {
|
3602
|
-
if (!this._isTypeVarLive(paramSpec)) {
|
3603
|
-
return convertTypeToParamSpecValue(types_1.TypeVarType.cloneAsInScopePlaceholder(paramSpec, this._usageOffset));
|
3350
|
+
return types_1.TypeVarType.cloneAsUnificationVar(typeVar, this._usageOffset);
|
3604
3351
|
}
|
3605
3352
|
return undefined;
|
3606
3353
|
}
|
3607
3354
|
_isTypeVarLive(typeVar) {
|
3608
|
-
return this._liveTypeVarScopes.some((scopeId) => { var _a; return typeVar.priv.scopeId === scopeId || ((_a = typeVar.priv.
|
3609
|
-
}
|
3610
|
-
}
|
3611
|
-
class InScopePlaceholderTransformer extends TypeVarTransformer {
|
3612
|
-
constructor(_solutionSet) {
|
3613
|
-
super();
|
3614
|
-
this._solutionSet = _solutionSet;
|
3355
|
+
return this._liveTypeVarScopes.some((scopeId) => { var _a; return typeVar.priv.scopeId === scopeId || ((_a = typeVar.priv.freeTypeVar) === null || _a === void 0 ? void 0 : _a.priv.scopeId) === scopeId; });
|
3615
3356
|
}
|
3616
|
-
transformTypeVar(typeVar) {
|
3617
|
-
var _a;
|
3618
|
-
if (typeVar.priv.isInScopePlaceholder) {
|
3619
|
-
return (_a = this._solutionSet.getTypeVarType(typeVar)) !== null && _a !== void 0 ? _a : typeVar;
|
3620
|
-
}
|
3621
|
-
return undefined;
|
3622
|
-
}
|
3623
|
-
transformParamSpec(paramSpec) {
|
3624
|
-
if (paramSpec.priv.isInScopePlaceholder) {
|
3625
|
-
return this._solutionSet.getTypeVarType(paramSpec);
|
3626
|
-
}
|
3627
|
-
return undefined;
|
3628
|
-
}
|
3629
|
-
}
|
3630
|
-
function applyInScopePlaceholdersToType(type, solutionSet) {
|
3631
|
-
// Handle the common case where there are no in-scope placeholders.
|
3632
|
-
// No more work is required in this case.
|
3633
|
-
if (!solutionSet.getTypeVars().some((entry) => entry.typeVar.priv.isInScopePlaceholder)) {
|
3634
|
-
return type;
|
3635
|
-
}
|
3636
|
-
const transformer = new InScopePlaceholderTransformer(solutionSet);
|
3637
|
-
return transformer.apply(type, 0);
|
3638
3357
|
}
|
3639
3358
|
//# sourceMappingURL=typeUtils.js.map
|