@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
@@ -10,145 +10,397 @@
|
|
10
10
|
*
|
11
11
|
*/
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
exports.
|
13
|
+
exports.assignTypeVar = assignTypeVar;
|
14
|
+
exports.solveConstraints = solveConstraints;
|
15
|
+
exports.applySourceSolutionToConstraints = applySourceSolutionToConstraints;
|
16
|
+
exports.solveConstraintSet = solveConstraintSet;
|
17
|
+
exports.addConstraintsForExpectedType = addConstraintsForExpectedType;
|
14
18
|
const diagnostic_1 = require("../common/diagnostic");
|
15
19
|
const localize_1 = require("../localization/localize");
|
20
|
+
const constraintSolution_1 = require("./constraintSolution");
|
21
|
+
const constraintTracker_1 = require("./constraintTracker");
|
16
22
|
const typeEvaluatorTypes_1 = require("./typeEvaluatorTypes");
|
17
23
|
const types_1 = require("./types");
|
18
24
|
const typeUtils_1 = require("./typeUtils");
|
19
|
-
const typeVarContext_1 = require("./typeVarContext");
|
20
25
|
// As we widen the lower bound of a type variable, we may end up with
|
21
26
|
// many subtypes. For performance reasons, we need to cap this at some
|
22
27
|
// point. This constant determines the cap.
|
23
28
|
const maxSubtypeCountForTypeVarLowerBound = 64;
|
24
|
-
// This debugging switch enables logging of the
|
29
|
+
// This debugging switch enables logging of the constraints before and
|
25
30
|
// after it is updated by the constraint solver.
|
26
|
-
const
|
31
|
+
const logConstraintsUpdates = false;
|
27
32
|
// Assigns the source type to the dest type var in the type var context. If an existing
|
28
33
|
// type is already associated with that type var name, it attempts to either widen or
|
29
34
|
// narrow the type (depending on the value of the isContravariant parameter). The goal is
|
30
35
|
// to produce the narrowest type that meets all of the requirements. If the type var context
|
31
36
|
// has been "locked", it simply validates that the srcType is compatible (with no attempt
|
32
37
|
// to widen or narrow).
|
33
|
-
function
|
34
|
-
|
38
|
+
function assignTypeVar(evaluator, destType, srcType, diag, constraints, flags = 0 /* AssignTypeFlags.Default */, recursionCount = 0) {
|
39
|
+
let isAssignable;
|
40
|
+
if (logConstraintsUpdates) {
|
35
41
|
const indent = ' '.repeat(recursionCount * 2);
|
36
42
|
console.log(`${indent}`);
|
37
|
-
console.log(`${indent}
|
43
|
+
console.log(`${indent}assignTypeVar called with`);
|
38
44
|
console.log(`${indent}destType: ${evaluator.printType(destType)}`);
|
39
45
|
console.log(`${indent}srcType: ${evaluator.printType(srcType)}`);
|
40
46
|
console.log(`${indent}flags: ${flags}`);
|
41
|
-
|
42
|
-
|
47
|
+
if (constraints) {
|
48
|
+
logConstraints(evaluator, constraints, indent);
|
49
|
+
}
|
43
50
|
}
|
44
|
-
let isTypeVarInScope = true;
|
45
|
-
const isInvariant = (flags & 1 /* AssignTypeFlags.EnforceInvariance */) !== 0;
|
46
|
-
const isContravariant = (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0 && !isInvariant;
|
47
51
|
// If the TypeVar doesn't have a scope ID, then it's being used
|
48
52
|
// outside of a valid TypeVar scope. This will be reported as a
|
49
53
|
// separate error. Just ignore this case to avoid redundant errors.
|
50
54
|
if (!destType.priv.scopeId) {
|
51
55
|
return true;
|
52
56
|
}
|
57
|
+
if (types_1.TypeVarType.isBound(destType) && !types_1.TypeVarType.isUnification(destType)) {
|
58
|
+
return assignBoundTypeVar(evaluator, destType, srcType, diag, flags);
|
59
|
+
}
|
53
60
|
// Handle type[T] as a dest and a special form as a source.
|
54
61
|
if (types_1.TypeBase.isInstantiable(destType) &&
|
55
62
|
(0, types_1.isInstantiableClass)(srcType) &&
|
56
63
|
evaluator.isSpecialFormClass(srcType, flags)) {
|
57
64
|
return false;
|
58
65
|
}
|
59
|
-
//
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
// An TypeVar can always be assigned to itself, but we won't record this in the constraints.
|
67
|
+
if ((0, types_1.isTypeSame)(destType, srcType)) {
|
68
|
+
return true;
|
69
|
+
}
|
70
|
+
if ((0, types_1.isParamSpec)(destType)) {
|
71
|
+
// Handle ParamSpecs specially.
|
72
|
+
isAssignable = assignParamSpec(evaluator, destType, srcType, diag, constraints, recursionCount);
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
if ((0, types_1.isTypeVarTuple)(destType) && !destType.priv.isInUnion) {
|
76
|
+
const tupleClassType = evaluator.getTupleClassType();
|
77
|
+
if (!(0, types_1.isUnpacked)(srcType) && tupleClassType) {
|
78
|
+
// Package up the type into a tuple.
|
79
|
+
srcType = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: srcType, isUnbounded: false }],
|
80
|
+
/* isTypeArgExplicit */ true,
|
81
|
+
/* isUnpackedTuple */ true));
|
74
82
|
}
|
75
83
|
}
|
76
|
-
//
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
84
|
+
// If we're assigning an unpacked TypeVarTuple to a regular TypeVar,
|
85
|
+
// we need to treat it as a union of the unpacked TypeVarTuple.
|
86
|
+
if ((0, types_1.isTypeVarTuple)(srcType) &&
|
87
|
+
srcType.priv.isUnpacked &&
|
88
|
+
!srcType.priv.isInUnion &&
|
89
|
+
!(0, types_1.isTypeVarTuple)(destType)) {
|
90
|
+
srcType = types_1.TypeVarType.cloneForUnpacked(srcType, /* isInUnion */ true);
|
82
91
|
}
|
83
|
-
//
|
84
|
-
//
|
85
|
-
|
86
|
-
|
92
|
+
// Handle the constrained case. This case needs to be handled specially
|
93
|
+
// because type narrowing isn't used in this case. For example, if the
|
94
|
+
// source type is "Literal[1]" and the constraint list includes the type
|
95
|
+
// "float", the resulting type is float.
|
96
|
+
if (types_1.TypeVarType.hasConstraints(destType)) {
|
97
|
+
isAssignable = assignConstrainedTypeVar(evaluator, destType, srcType, diag, constraints, flags, recursionCount);
|
87
98
|
}
|
88
|
-
|
89
|
-
|
90
|
-
if ((flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */) !== 0) {
|
91
|
-
return true;
|
99
|
+
else {
|
100
|
+
isAssignable = assignUnconstrainedTypeVar(evaluator, destType, srcType, diag, constraints, flags, recursionCount);
|
92
101
|
}
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
102
|
+
}
|
103
|
+
if (logConstraintsUpdates) {
|
104
|
+
const indent = ' '.repeat(recursionCount * 2);
|
105
|
+
console.log(`${indent}`);
|
106
|
+
if (constraints) {
|
107
|
+
logConstraints(evaluator, constraints, indent);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return isAssignable;
|
111
|
+
}
|
112
|
+
// Returns a solution for the type variables tracked by the constraint tracker.
|
113
|
+
function solveConstraints(evaluator, constraints, options) {
|
114
|
+
const solutionSets = [];
|
115
|
+
constraints.doForEachConstraintSet((constraintSet) => {
|
116
|
+
const solutionSet = solveConstraintSet(evaluator, constraintSet, options);
|
117
|
+
solutionSets.push(solutionSet);
|
118
|
+
});
|
119
|
+
return new constraintSolution_1.ConstraintSolution(solutionSets);
|
120
|
+
}
|
121
|
+
// Applies solved TypeVars from one context to this context.
|
122
|
+
function applySourceSolutionToConstraints(constraints, srcSolution) {
|
123
|
+
if (srcSolution.isEmpty()) {
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
constraints.doForEachConstraintSet((constraintSet) => {
|
127
|
+
constraintSet.getTypeVars().forEach((entry) => {
|
128
|
+
constraintSet.setBounds(entry.typeVar, entry.lowerBound ? (0, typeUtils_1.applySolvedTypeVars)(entry.lowerBound, srcSolution) : undefined, entry.upperBound ? (0, typeUtils_1.applySolvedTypeVars)(entry.upperBound, srcSolution) : undefined, entry.retainLiterals);
|
129
|
+
});
|
130
|
+
});
|
131
|
+
}
|
132
|
+
function solveConstraintSet(evaluator, constraintSet, options) {
|
133
|
+
const solutionSet = new constraintSolution_1.ConstraintSolutionSet(constraintSet.getScopeIds());
|
134
|
+
constraintSet.doForEachTypeVar((entry) => {
|
135
|
+
solveTypeVarRecursive(evaluator, constraintSet, options, solutionSet, entry);
|
136
|
+
});
|
137
|
+
return solutionSet;
|
138
|
+
}
|
139
|
+
function solveTypeVarRecursive(evaluator, constraintSet, options, solutionSet, entry) {
|
140
|
+
// If this TypeVar already has a solution, don't attempt to re-solve it.
|
141
|
+
if (solutionSet.hasType(entry.typeVar)) {
|
142
|
+
return solutionSet.getType(entry.typeVar);
|
143
|
+
}
|
144
|
+
// Protect against infinite recursion by setting the initial value to undefined.
|
145
|
+
solutionSet.setType(entry.typeVar, undefined);
|
146
|
+
let value = getTypeVarType(evaluator, constraintSet, entry.typeVar, options === null || options === void 0 ? void 0 : options.useLowerBoundOnly);
|
147
|
+
if (value) {
|
148
|
+
// Are there any unsolved TypeVars in this type?
|
149
|
+
const typeVars = (0, typeUtils_1.getTypeVarArgsRecursive)(value);
|
150
|
+
if (typeVars.length > 0) {
|
151
|
+
const dependentSolution = new constraintSolution_1.ConstraintSolution();
|
152
|
+
for (const typeVar of typeVars) {
|
153
|
+
// Don't attempt to replace a TypeVar with itself.
|
154
|
+
if ((0, types_1.isTypeSame)(typeVar, entry.typeVar, { ignoreTypeFlags: true })) {
|
155
|
+
continue;
|
156
|
+
}
|
157
|
+
// Don't attempt to solve or replace bound TypeVars.
|
158
|
+
if (types_1.TypeVarType.isBound(typeVar)) {
|
159
|
+
continue;
|
160
|
+
}
|
161
|
+
const dependentEntry = constraintSet.getTypeVar(typeVar);
|
162
|
+
if (!dependentEntry) {
|
163
|
+
continue;
|
164
|
+
}
|
165
|
+
const dependentType = solveTypeVarRecursive(evaluator, constraintSet, options, solutionSet, dependentEntry);
|
166
|
+
if (dependentType) {
|
167
|
+
dependentSolution.setType(typeVar, dependentType);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
// Apply the dependent TypeVar values to the current TypeVar value.
|
171
|
+
if (!dependentSolution.isEmpty()) {
|
172
|
+
value = (0, typeUtils_1.applySolvedTypeVars)(value, dependentSolution);
|
173
|
+
}
|
99
174
|
}
|
100
175
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
176
|
+
solutionSet.setType(entry.typeVar, value);
|
177
|
+
return value;
|
178
|
+
}
|
179
|
+
// In cases where the expected type is a specialized base class of the
|
180
|
+
// source type, we need to determine which type arguments in the derived
|
181
|
+
// class will make it compatible with the specialized base class. This method
|
182
|
+
// performs this reverse mapping of type arguments and populates the type var
|
183
|
+
// map for the target type. If the type is not assignable to the expected type,
|
184
|
+
// it returns false.
|
185
|
+
function addConstraintsForExpectedType(evaluator, type, expectedType, constraints, liveTypeVarScopes, usageOffset = undefined) {
|
186
|
+
if ((0, types_1.isAny)(expectedType)) {
|
187
|
+
type.shared.typeParams.forEach((typeParam) => {
|
188
|
+
constraints.setBounds(typeParam, expectedType, expectedType);
|
189
|
+
});
|
104
190
|
return true;
|
105
191
|
}
|
106
|
-
if ((
|
107
|
-
|
108
|
-
/* destTypeVarContext */ undefined,
|
109
|
-
/* srcTypeVarContext */ undefined, flags, recursionCount);
|
192
|
+
if ((0, types_1.isTypeVar)(expectedType) && types_1.TypeVarType.isSelf(expectedType) && expectedType.shared.boundType) {
|
193
|
+
expectedType = expectedType.shared.boundType;
|
110
194
|
}
|
111
|
-
if ((0, types_1.
|
112
|
-
return
|
195
|
+
if (!(0, types_1.isClass)(expectedType)) {
|
196
|
+
return false;
|
113
197
|
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
198
|
+
// If the expected type is generic (but not specialized), we can't proceed.
|
199
|
+
const expectedTypeArgs = expectedType.priv.typeArgs;
|
200
|
+
if (!expectedTypeArgs) {
|
201
|
+
return evaluator.assignType(type, expectedType,
|
202
|
+
/* diag */ undefined, constraints, 2048 /* AssignTypeFlags.PopulateExpectedType */);
|
203
|
+
}
|
204
|
+
evaluator.inferVarianceForClass(type);
|
205
|
+
// If the expected type is the same as the target type (commonly the case),
|
206
|
+
// we can use a faster method.
|
207
|
+
if (types_1.ClassType.isSameGenericClass(expectedType, type)) {
|
208
|
+
const solution = (0, typeUtils_1.buildSolutionFromSpecializedClass)(expectedType);
|
209
|
+
const typeParams = types_1.ClassType.getTypeParams(expectedType);
|
210
|
+
typeParams.forEach((typeParam) => {
|
211
|
+
let typeArgValue = solution.getMainSolutionSet().getType(typeParam);
|
212
|
+
if (typeArgValue && liveTypeVarScopes) {
|
213
|
+
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes, usageOffset);
|
122
214
|
}
|
123
|
-
|
124
|
-
|
215
|
+
if (typeArgValue) {
|
216
|
+
const variance = types_1.TypeVarType.getVariance(typeParam);
|
217
|
+
constraints.setBounds(typeParam, variance === 3 /* Variance.Covariant */ ? undefined : typeArgValue, variance === 4 /* Variance.Contravariant */ ? undefined : typeArgValue);
|
218
|
+
}
|
219
|
+
});
|
220
|
+
return true;
|
221
|
+
}
|
222
|
+
// Create a generic version of the expected type.
|
223
|
+
const expectedTypeScopeId = (0, typeUtils_1.getTypeVarScopeId)(expectedType);
|
224
|
+
const synthExpectedTypeArgs = types_1.ClassType.getTypeParams(expectedType).map((typeParam, index) => {
|
225
|
+
const typeVar = types_1.TypeVarType.createInstance(`__dest${index}`, (0, types_1.isParamSpec)(typeParam) ? types_1.TypeVarKind.ParamSpec : types_1.TypeVarKind.TypeVar);
|
226
|
+
typeVar.shared.isSynthesized = true;
|
227
|
+
// Use invariance here so we set the lower and upper bound on the TypeVar.
|
228
|
+
typeVar.shared.declaredVariance = 2 /* Variance.Invariant */;
|
229
|
+
typeVar.priv.scopeId = expectedTypeScopeId;
|
230
|
+
return typeVar;
|
231
|
+
});
|
232
|
+
const genericExpectedType = types_1.ClassType.specialize(expectedType, synthExpectedTypeArgs);
|
233
|
+
// For each type param in the target type, create a placeholder type variable.
|
234
|
+
const typeArgs = types_1.ClassType.getTypeParams(type).map((typeParam, index) => {
|
235
|
+
const typeVar = types_1.TypeVarType.createInstance(`__source${index}`, (0, types_1.isParamSpec)(typeParam) ? types_1.TypeVarKind.ParamSpec : types_1.TypeVarKind.TypeVar);
|
236
|
+
typeVar.shared.isSynthesized = true;
|
237
|
+
typeVar.shared.synthesizedIndex = index;
|
238
|
+
typeVar.shared.isExemptFromBoundCheck = true;
|
239
|
+
return types_1.TypeVarType.cloneAsUnificationVar(typeVar);
|
240
|
+
});
|
241
|
+
const specializedType = types_1.ClassType.specialize(type, typeArgs);
|
242
|
+
const syntheticConstraints = new constraintTracker_1.ConstraintTracker();
|
243
|
+
if (evaluator.assignType(genericExpectedType, specializedType,
|
244
|
+
/* diag */ undefined, syntheticConstraints, 2048 /* AssignTypeFlags.PopulateExpectedType */)) {
|
245
|
+
let isResultValid = true;
|
246
|
+
synthExpectedTypeArgs.forEach((typeVar, index) => {
|
247
|
+
let synthTypeVar = getTypeVarType(evaluator, syntheticConstraints.getMainConstraintSet(), typeVar);
|
248
|
+
const otherSubtypes = [];
|
249
|
+
// If the resulting type is a union, try to find a matching type var and move
|
250
|
+
// the remaining subtypes to the "otherSubtypes" array.
|
251
|
+
if (synthTypeVar) {
|
252
|
+
if ((0, types_1.isParamSpec)(typeVar) && (0, types_1.isFunction)(synthTypeVar)) {
|
253
|
+
synthTypeVar = (0, typeUtils_1.simplifyFunctionToParamSpec)(synthTypeVar);
|
254
|
+
}
|
255
|
+
if ((0, types_1.isUnion)(synthTypeVar)) {
|
256
|
+
let foundSynthTypeVar;
|
257
|
+
(0, typeUtils_1.sortTypes)(synthTypeVar.priv.subtypes).forEach((subtype) => {
|
258
|
+
if ((0, types_1.isTypeVar)(subtype) &&
|
259
|
+
subtype.shared.isSynthesized &&
|
260
|
+
subtype.shared.synthesizedIndex !== undefined &&
|
261
|
+
!foundSynthTypeVar) {
|
262
|
+
foundSynthTypeVar = subtype;
|
263
|
+
}
|
264
|
+
else {
|
265
|
+
otherSubtypes.push(subtype);
|
266
|
+
}
|
267
|
+
});
|
268
|
+
if (foundSynthTypeVar) {
|
269
|
+
synthTypeVar = foundSynthTypeVar;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
}
|
273
|
+
// Is this one of the synthesized type vars we allocated above? If so,
|
274
|
+
// the type arg that corresponds to this type var maps back to the target type.
|
275
|
+
if (synthTypeVar &&
|
276
|
+
(0, types_1.isTypeVar)(synthTypeVar) &&
|
277
|
+
synthTypeVar.shared.isSynthesized &&
|
278
|
+
synthTypeVar.shared.synthesizedIndex !== undefined) {
|
279
|
+
const targetTypeVar = types_1.ClassType.getTypeParams(specializedType)[synthTypeVar.shared.synthesizedIndex];
|
280
|
+
if (index < expectedTypeArgs.length) {
|
281
|
+
let typeArgValue = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expectedTypeArgs[index]);
|
282
|
+
if (otherSubtypes.length > 0) {
|
283
|
+
typeArgValue = (0, types_1.combineTypes)([typeArgValue, ...otherSubtypes]);
|
284
|
+
}
|
285
|
+
if (liveTypeVarScopes) {
|
286
|
+
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes, usageOffset);
|
287
|
+
}
|
288
|
+
if (typeArgValue) {
|
289
|
+
const variance = types_1.TypeVarType.getVariance(typeVar);
|
290
|
+
// If this type variable already has a type, don't overwrite it. This can
|
291
|
+
// happen if a single type variable in the derived class is used multiple times
|
292
|
+
// in the specialized base class type (e.g. Mapping[T, T]).
|
293
|
+
if (constraints.getMainConstraintSet().getTypeVar(targetTypeVar)) {
|
294
|
+
isResultValid = false;
|
295
|
+
typeArgValue = types_1.UnknownType.create();
|
296
|
+
}
|
297
|
+
constraints.setBounds(targetTypeVar, variance === 3 /* Variance.Covariant */ ? undefined : typeArgValue, variance === 4 /* Variance.Contravariant */ ? undefined : typeArgValue);
|
298
|
+
}
|
299
|
+
else {
|
300
|
+
isResultValid = false;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}
|
304
|
+
});
|
305
|
+
return isResultValid;
|
306
|
+
}
|
307
|
+
return false;
|
308
|
+
}
|
309
|
+
function stripLiteralsForLowerBound(evaluator, typeVar, lowerBound) {
|
310
|
+
return (0, types_1.isTypeVarTuple)(typeVar)
|
311
|
+
? stripLiteralValueForUnpackedTuple(evaluator, lowerBound)
|
312
|
+
: evaluator.stripLiteralValue(lowerBound);
|
313
|
+
}
|
314
|
+
function getTypeVarType(evaluator, constraintSet, typeVar, useLowerBoundOnly) {
|
315
|
+
const entry = constraintSet.getTypeVar(typeVar);
|
316
|
+
if (!entry) {
|
317
|
+
return undefined;
|
318
|
+
}
|
319
|
+
if ((0, types_1.isParamSpec)(typeVar)) {
|
320
|
+
if (!entry.lowerBound) {
|
321
|
+
return undefined;
|
322
|
+
}
|
323
|
+
if ((0, types_1.isFunction)(entry.lowerBound)) {
|
324
|
+
return entry.lowerBound;
|
325
|
+
}
|
326
|
+
if ((0, types_1.isAnyOrUnknown)(entry.lowerBound)) {
|
327
|
+
return types_1.ParamSpecType.getUnknown();
|
328
|
+
}
|
329
|
+
}
|
330
|
+
let result;
|
331
|
+
let lowerBound = entry.lowerBound;
|
332
|
+
if (lowerBound) {
|
333
|
+
if (!entry.retainLiterals) {
|
334
|
+
const lowerNoLiterals = stripLiteralsForLowerBound(evaluator, typeVar, lowerBound);
|
335
|
+
// If we can widen the lower bound to a non-literal type without
|
336
|
+
// exceeding the upper bound, use the widened type.
|
337
|
+
if (lowerNoLiterals !== lowerBound) {
|
338
|
+
if (!entry.upperBound || evaluator.assignType(entry.upperBound, lowerNoLiterals)) {
|
339
|
+
if (types_1.TypeVarType.hasConstraints(typeVar)) {
|
340
|
+
// Does it still match a value constraint?
|
341
|
+
if (typeVar.shared.constraints.some((constraint) => (0, types_1.isTypeSame)(lowerNoLiterals, constraint))) {
|
342
|
+
lowerBound = lowerNoLiterals;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
else {
|
346
|
+
lowerBound = lowerNoLiterals;
|
347
|
+
}
|
348
|
+
}
|
125
349
|
}
|
126
350
|
}
|
351
|
+
result = lowerBound;
|
352
|
+
}
|
353
|
+
else if (!useLowerBoundOnly) {
|
354
|
+
result = entry.upperBound;
|
355
|
+
}
|
356
|
+
return result;
|
357
|
+
}
|
358
|
+
// Handles an assignment to a TypeVar that is "bound" rather than "free".
|
359
|
+
// In general, such assignments are not allowed, but there are some special
|
360
|
+
// cases to be handled.
|
361
|
+
function assignBoundTypeVar(evaluator, destType, srcType, diag, flags) {
|
362
|
+
// Handle Any as a source.
|
363
|
+
if ((0, types_1.isAnyOrUnknown)(srcType) || ((0, types_1.isClass)(srcType) && types_1.ClassType.derivesFromAnyOrUnknown(srcType))) {
|
364
|
+
return true;
|
365
|
+
}
|
366
|
+
// Is this the equivalent of an "Unknown" for a ParamSpec?
|
367
|
+
if ((0, types_1.isParamSpec)(destType) && (0, types_1.isFunction)(srcType) && types_1.FunctionType.isGradualCallableForm(srcType)) {
|
368
|
+
return true;
|
127
369
|
}
|
128
|
-
//
|
129
|
-
|
130
|
-
if ((0, types_1.
|
131
|
-
|
132
|
-
!srcType.priv.isVariadicInUnion &&
|
133
|
-
!(0, types_1.isTypeVarTuple)(destType)) {
|
134
|
-
srcType = types_1.TypeVarType.cloneForUnpacked(srcType, /* isInUnion */ true);
|
370
|
+
// Never is always assignable in a covariant context.
|
371
|
+
const isCovariant = (flags & (1 /* AssignTypeFlags.Invariant */ | 2 /* AssignTypeFlags.Contravariant */)) === 0;
|
372
|
+
if ((0, types_1.isNever)(srcType) && isCovariant) {
|
373
|
+
return true;
|
135
374
|
}
|
136
|
-
// Handle
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
375
|
+
// Handle a type[Any] as a source.
|
376
|
+
if ((0, types_1.isClassInstance)(srcType) && types_1.ClassType.isBuiltIn(srcType, 'type')) {
|
377
|
+
if (!srcType.priv.typeArgs || srcType.priv.typeArgs.length < 1 || (0, types_1.isAnyOrUnknown)(srcType.priv.typeArgs[0])) {
|
378
|
+
if (types_1.TypeBase.isInstantiable(destType)) {
|
379
|
+
return true;
|
380
|
+
}
|
381
|
+
}
|
142
382
|
}
|
383
|
+
// Emit an error unless this is a synthesized type variable used
|
384
|
+
// for pseudo-generic classes.
|
385
|
+
if (!destType.shared.isSynthesized || types_1.TypeVarType.isSelf(destType)) {
|
386
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(srcType, destType)));
|
387
|
+
}
|
388
|
+
return false;
|
389
|
+
}
|
390
|
+
// Handles assignments to a TypeVarTuple or a TypeVar that does not have
|
391
|
+
// value constraints (but may have an upper bound).
|
392
|
+
function assignUnconstrainedTypeVar(evaluator, destType, srcType, diag, constraints, flags, recursionCount) {
|
393
|
+
const isInvariant = (flags & 1 /* AssignTypeFlags.Invariant */) !== 0;
|
394
|
+
const isContravariant = (flags & 2 /* AssignTypeFlags.Contravariant */) !== 0 && !isInvariant;
|
143
395
|
// Handle the unconstrained (but possibly bound) case.
|
144
|
-
const curEntry =
|
396
|
+
const curEntry = constraints === null || constraints === void 0 ? void 0 : constraints.getMainConstraintSet().getTypeVar(destType);
|
145
397
|
let curUpperBound = curEntry === null || curEntry === void 0 ? void 0 : curEntry.upperBound;
|
146
|
-
if (!curUpperBound && !
|
398
|
+
if (!curUpperBound && !types_1.TypeVarType.isSelf(destType)) {
|
147
399
|
curUpperBound = destType.shared.boundType;
|
148
400
|
}
|
149
401
|
let curLowerBound = curEntry === null || curEntry === void 0 ? void 0 : curEntry.lowerBound;
|
150
402
|
let newLowerBound = curLowerBound;
|
151
|
-
let
|
403
|
+
let newUpperBound = curUpperBound;
|
152
404
|
const diagAddendum = diag ? new diagnostic_1.DiagnosticAddendum() : undefined;
|
153
405
|
let adjSrcType = srcType;
|
154
406
|
// If the source is a class that is missing type arguments, fill
|
@@ -180,7 +432,7 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
180
432
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(adjSrcType, destType)));
|
181
433
|
return false;
|
182
434
|
}
|
183
|
-
if ((flags & 2048 /* AssignTypeFlags.
|
435
|
+
if ((flags & 2048 /* AssignTypeFlags.PopulateExpectedType */) !== 0) {
|
184
436
|
if ((flags & 4096 /* AssignTypeFlags.SkipPopulateUnknownExpectedType */) !== 0 && (0, types_1.isUnknown)(adjSrcType)) {
|
185
437
|
return true;
|
186
438
|
}
|
@@ -190,31 +442,29 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
190
442
|
if (!curEntry) {
|
191
443
|
if (isInvariant) {
|
192
444
|
newLowerBound = adjSrcType;
|
193
|
-
|
445
|
+
newUpperBound = adjSrcType;
|
194
446
|
}
|
195
447
|
else if (isContravariant) {
|
196
448
|
newLowerBound = adjSrcType;
|
197
449
|
}
|
198
450
|
else {
|
199
|
-
|
451
|
+
newUpperBound = adjSrcType;
|
200
452
|
}
|
201
453
|
}
|
202
454
|
}
|
203
455
|
else if (isContravariant) {
|
204
456
|
// Update the upper bound.
|
205
457
|
if (!curUpperBound || (0, types_1.isTypeSame)(destType, curUpperBound)) {
|
206
|
-
|
458
|
+
newUpperBound = adjSrcType;
|
207
459
|
}
|
208
460
|
else if (!(0, types_1.isTypeSame)(curUpperBound, adjSrcType, {}, recursionCount)) {
|
209
461
|
if (evaluator.assignType(curUpperBound, evaluator.makeTopLevelTypeVarsConcrete(adjSrcType), diagAddendum,
|
210
|
-
/*
|
211
|
-
/* srcTypeVarContext */ undefined, flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
462
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
212
463
|
// The srcType is narrower than the current upper bound, so replace it.
|
213
|
-
|
464
|
+
newUpperBound = adjSrcType;
|
214
465
|
}
|
215
466
|
else if (!evaluator.assignType(adjSrcType, curUpperBound, diagAddendum,
|
216
|
-
/*
|
217
|
-
/* srcTypeVarContext */ undefined, flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
467
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
218
468
|
if (diag && diagAddendum) {
|
219
469
|
diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(curUpperBound, adjSrcType)));
|
220
470
|
diag.addAddendum(diagAddendum);
|
@@ -224,12 +474,11 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
224
474
|
}
|
225
475
|
// Make sure we haven't narrowed it beyond the current lower bound.
|
226
476
|
if (curLowerBound) {
|
227
|
-
if (!evaluator.assignType(
|
477
|
+
if (!evaluator.assignType(newUpperBound, curLowerBound,
|
228
478
|
/* diag */ undefined,
|
229
|
-
/*
|
230
|
-
/* srcTypeVarContext */ undefined, flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
479
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
231
480
|
if (diag && diagAddendum) {
|
232
|
-
diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(curLowerBound,
|
481
|
+
diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(curLowerBound, newUpperBound)));
|
233
482
|
diag.addAddendum(diagAddendum);
|
234
483
|
}
|
235
484
|
return false;
|
@@ -245,31 +494,31 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
245
494
|
// If this is an invariant context and there is currently no upper bound
|
246
495
|
// established, use the "no literals" version of the lower bound rather
|
247
496
|
// than a version that has literals.
|
248
|
-
if (!
|
249
|
-
newLowerBound =
|
497
|
+
if (!newUpperBound && isInvariant && curEntry && !curEntry.retainLiterals) {
|
498
|
+
newLowerBound = stripLiteralsForLowerBound(evaluator, destType, curLowerBound);
|
250
499
|
}
|
251
500
|
}
|
252
501
|
else {
|
253
|
-
if (evaluator.assignType(curLowerBound, adjSrcType, diagAddendum,
|
254
|
-
/* srcTypeVarContext */ undefined, flags, recursionCount)) {
|
502
|
+
if (evaluator.assignType(curLowerBound, adjSrcType, diagAddendum, constraints, flags, recursionCount)) {
|
255
503
|
// No need to widen. Stick with the existing type unless it's unknown
|
256
504
|
// or partly unknown, in which case we'll replace it with a known type
|
257
505
|
// as long as it doesn't violate the current lower bound.
|
258
506
|
if ((0, typeUtils_1.isPartlyUnknown)(curLowerBound) &&
|
259
507
|
!(0, types_1.isUnknown)(adjSrcType) &&
|
260
508
|
evaluator.assignType(adjSrcType, curLowerBound,
|
261
|
-
/* diag */ undefined,
|
262
|
-
/* srcTypeVarContext */ undefined, flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
509
|
+
/* diag */ undefined, constraints, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
263
510
|
newLowerBound = adjSrcType;
|
264
511
|
}
|
265
512
|
else {
|
266
|
-
newLowerBound =
|
513
|
+
newLowerBound = curLowerBound;
|
514
|
+
if (constraints) {
|
515
|
+
newLowerBound = evaluator.solveAndApplyConstraints(newLowerBound, constraints);
|
516
|
+
}
|
267
517
|
}
|
268
518
|
}
|
269
519
|
else if ((0, types_1.isTypeVar)(curLowerBound) &&
|
270
520
|
!(0, types_1.isTypeVar)(adjSrcType) &&
|
271
|
-
evaluator.assignType(evaluator.makeTopLevelTypeVarsConcrete(curLowerBound), adjSrcType, diagAddendum,
|
272
|
-
/* srcTypeVarContext */ undefined, flags, recursionCount)) {
|
521
|
+
evaluator.assignType(evaluator.makeTopLevelTypeVarsConcrete(curLowerBound), adjSrcType, diagAddendum, constraints, flags, recursionCount)) {
|
273
522
|
// If the existing lower bound was a TypeVar that is not
|
274
523
|
// part of the current context we can replace it with the new
|
275
524
|
// source type.
|
@@ -277,13 +526,12 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
277
526
|
}
|
278
527
|
else {
|
279
528
|
// We need to widen the type.
|
280
|
-
if (
|
529
|
+
if (constraints === null || constraints === void 0 ? void 0 : constraints.isLocked()) {
|
281
530
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(adjSrcType, curLowerBound)));
|
282
531
|
return false;
|
283
532
|
}
|
284
533
|
if (evaluator.assignType(adjSrcType, curLowerBound,
|
285
|
-
/* diag */ undefined,
|
286
|
-
/* srcTypeVarContext */ undefined, flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
534
|
+
/* diag */ undefined, constraints, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
287
535
|
newLowerBound = adjSrcType;
|
288
536
|
}
|
289
537
|
else if ((0, types_1.isTypeVarTuple)(destType)) {
|
@@ -299,10 +547,13 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
299
547
|
// If this is an invariant context and there is currently no upper bound
|
300
548
|
// established, use the "no literals" version of the lower bound rather
|
301
549
|
// than a version that has literals.
|
302
|
-
if (!
|
303
|
-
curLowerBound =
|
550
|
+
if (!newUpperBound && isInvariant && curEntry && !curEntry.retainLiterals) {
|
551
|
+
curLowerBound = stripLiteralsForLowerBound(evaluator, destType, curLowerBound);
|
552
|
+
}
|
553
|
+
let curSolvedLowerBound = curLowerBound;
|
554
|
+
if (constraints) {
|
555
|
+
curSolvedLowerBound = evaluator.solveAndApplyConstraints(curLowerBound, constraints);
|
304
556
|
}
|
305
|
-
const curSolvedLowerBound = (0, typeUtils_1.applySolvedTypeVars)(curLowerBound, typeVarContext);
|
306
557
|
// In some extreme edge cases, the lower bound can become
|
307
558
|
// a union with so many subtypes that performance grinds to a
|
308
559
|
// halt. We'll detect this case and widen the resulting type
|
@@ -310,7 +561,7 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
310
561
|
// is still a valid solution to the TypeVar.
|
311
562
|
if ((0, types_1.isUnion)(curSolvedLowerBound) &&
|
312
563
|
curSolvedLowerBound.priv.subtypes.length > typeEvaluatorTypes_1.maxSubtypesForInferredType &&
|
313
|
-
|
564
|
+
types_1.TypeVarType.hasBound(destType) &&
|
314
565
|
(0, types_1.isClassInstance)(objectType)) {
|
315
566
|
newLowerBound = (0, types_1.combineTypes)([curSolvedLowerBound, objectType], {
|
316
567
|
maxSubtypeCount: maxSubtypeCountForTypeVarLowerBound,
|
@@ -328,8 +579,7 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
328
579
|
// isn't too wide.
|
329
580
|
if (isInvariant && newLowerBound) {
|
330
581
|
if (!evaluator.assignType(adjSrcType, newLowerBound, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
331
|
-
/*
|
332
|
-
/* srcTypeVarContext */ undefined, 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
582
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
333
583
|
if (diag && diagAddendum) {
|
334
584
|
diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(newLowerBound, adjSrcType)));
|
335
585
|
}
|
@@ -339,44 +589,33 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
339
589
|
// Make sure we don't exceed the upper bound.
|
340
590
|
if (curUpperBound && newLowerBound) {
|
341
591
|
if (!(0, types_1.isTypeSame)(curUpperBound, newLowerBound, {}, recursionCount)) {
|
342
|
-
|
343
|
-
/*
|
344
|
-
// Convert any remaining (non-top-level) TypeVars in the upper
|
345
|
-
// bound to in-scope placeholders.
|
346
|
-
adjUpperBound = (0, typeUtils_1.transformExpectedType)(adjUpperBound,
|
347
|
-
/* liveTypeVarScopes */ [],
|
348
|
-
/* usageOffset */ undefined);
|
349
|
-
if (!evaluator.assignType(adjUpperBound, newLowerBound, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
350
|
-
/* destTypeVarContext */ undefined,
|
351
|
-
/* srcTypeVarContext */ undefined, 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
592
|
+
if (!evaluator.assignType(curUpperBound, newLowerBound, diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
593
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
352
594
|
if (diag && diagAddendum) {
|
353
|
-
diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(newLowerBound,
|
595
|
+
diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(newLowerBound, curUpperBound)));
|
354
596
|
}
|
355
597
|
return false;
|
356
598
|
}
|
357
599
|
}
|
358
600
|
}
|
359
601
|
}
|
360
|
-
if (!
|
361
|
-
|
602
|
+
if (!newUpperBound && isInvariant) {
|
603
|
+
newUpperBound = newLowerBound;
|
362
604
|
}
|
363
605
|
// If there's a bound type, make sure the source is assignable to it.
|
364
606
|
if (destType.shared.boundType) {
|
365
|
-
const updatedType = (newLowerBound ||
|
607
|
+
const updatedType = (newLowerBound || newUpperBound);
|
366
608
|
// If the dest is a Type[T] but the source is not a valid Type,
|
367
609
|
// skip the assignType check and the diagnostic addendum, which will
|
368
610
|
// be confusing and inaccurate.
|
369
|
-
if (types_1.TypeBase.isInstantiable(destType) && !
|
611
|
+
if (types_1.TypeBase.isInstantiable(destType) && !(0, typeUtils_1.isEffectivelyInstantiable)(srcType)) {
|
370
612
|
return false;
|
371
613
|
}
|
372
614
|
// In general, bound types cannot be generic, but the "Self" type is an
|
373
|
-
// exception. In this case, we need to use the original
|
615
|
+
// exception. In this case, we need to use the original constraints
|
374
616
|
// to solve for the generic type variable(s) in the bound type.
|
375
|
-
const
|
376
|
-
|
377
|
-
: new typeVarContext_1.TypeVarContext(destType.priv.scopeId);
|
378
|
-
if (!evaluator.assignType(destType.shared.boundType, evaluator.makeTopLevelTypeVarsConcrete(updatedType), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), effectiveTypeVarContext,
|
379
|
-
/* srcTypeVarContext */ undefined, flags & 1024 /* AssignTypeFlags.IgnoreTypeVarScope */, recursionCount)) {
|
617
|
+
const effectiveConstraints = types_1.TypeVarType.isSelf(destType) ? constraints : undefined;
|
618
|
+
if (!evaluator.assignType(destType.shared.boundType, evaluator.makeTopLevelTypeVarsConcrete(updatedType), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), effectiveConstraints, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
380
619
|
// Avoid adding a message that will confuse users if the TypeVar was
|
381
620
|
// synthesized for internal purposes.
|
382
621
|
if (!destType.shared.isSynthesized) {
|
@@ -389,50 +628,23 @@ function assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext,
|
|
389
628
|
return false;
|
390
629
|
}
|
391
630
|
}
|
392
|
-
if (!
|
393
|
-
|
394
|
-
}
|
395
|
-
if (logTypeVarContextUpdates) {
|
396
|
-
const indent = ' '.repeat(recursionCount * 2);
|
397
|
-
console.log(`${indent}`);
|
398
|
-
logTypeVarContext(evaluator, typeVarContext, indent);
|
631
|
+
if (constraints && !constraints.isLocked()) {
|
632
|
+
constraints.setBounds(destType, newLowerBound, newUpperBound, (flags & (2048 /* AssignTypeFlags.PopulateExpectedType */ | 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */)) !== 0);
|
399
633
|
}
|
400
634
|
return true;
|
401
635
|
}
|
402
|
-
|
403
|
-
|
404
|
-
// lowerBoundNoLiterals, which is a variant of the lower bound that has
|
405
|
-
// literals stripped. By default, the constraint solver always uses the "no literals"
|
406
|
-
// type in its solutions unless the version with literals is required to satisfy
|
407
|
-
// the upper bound.
|
408
|
-
function updateTypeVarType(evaluator, typeVarContext, destType, lowerBound, upperBound, forceRetainLiterals = false) {
|
409
|
-
let lowerBoundNoLiterals;
|
410
|
-
if (lowerBound && !forceRetainLiterals) {
|
411
|
-
const strippedLiteral = (0, types_1.isTypeVarTuple)(destType)
|
412
|
-
? stripLiteralValueForUnpackedTuple(evaluator, lowerBound)
|
413
|
-
: evaluator.stripLiteralValue(lowerBound);
|
414
|
-
// Strip the literals from the lower bound and see if it is still
|
415
|
-
// narrower than the upper bound.
|
416
|
-
if (strippedLiteral !== lowerBound) {
|
417
|
-
if (!upperBound || evaluator.assignType(upperBound, strippedLiteral)) {
|
418
|
-
lowerBoundNoLiterals = strippedLiteral;
|
419
|
-
}
|
420
|
-
}
|
421
|
-
}
|
422
|
-
typeVarContext.setTypeVarType(destType, lowerBound, lowerBoundNoLiterals, upperBound); //, tupleTypes);
|
423
|
-
}
|
424
|
-
exports.updateTypeVarType = updateTypeVarType;
|
425
|
-
function assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, typeVarContext, flags, isTypeVarInScope, recursionCount) {
|
636
|
+
// Handles assignments to a TypeVar with value constraints.
|
637
|
+
function assignConstrainedTypeVar(evaluator, destType, srcType, diag, constraints, flags, recursionCount) {
|
426
638
|
let constrainedType;
|
427
639
|
const concreteSrcType = evaluator.makeTopLevelTypeVarsConcrete(srcType);
|
428
|
-
const curEntry =
|
640
|
+
const curEntry = constraints === null || constraints === void 0 ? void 0 : constraints.getMainConstraintSet().getTypeVar(destType);
|
429
641
|
const curUpperBound = curEntry === null || curEntry === void 0 ? void 0 : curEntry.upperBound;
|
430
642
|
const curLowerBound = curEntry === null || curEntry === void 0 ? void 0 : curEntry.lowerBound;
|
431
|
-
let
|
643
|
+
let retainLiterals = false;
|
432
644
|
if ((0, types_1.isTypeVar)(srcType)) {
|
433
645
|
if (evaluator.assignType(destType, concreteSrcType,
|
434
|
-
/* diag */ undefined,
|
435
|
-
/*
|
646
|
+
/* diag */ undefined,
|
647
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
436
648
|
constrainedType = srcType;
|
437
649
|
// If the source and dest are both instantiables (type[T]), then
|
438
650
|
// we need to convert to an instance (T).
|
@@ -460,15 +672,13 @@ function assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, type
|
|
460
672
|
: constraint;
|
461
673
|
if (evaluator.assignType(adjustedConstraint, srcSubtype,
|
462
674
|
/* diag */ undefined,
|
463
|
-
/*
|
464
|
-
/* srcTypeVarContext */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
675
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
465
676
|
if (!constrainedSubtype ||
|
466
677
|
evaluator.assignType(types_1.TypeBase.isInstantiable(destType)
|
467
678
|
? (0, typeUtils_1.convertToInstantiable)(constrainedSubtype)
|
468
679
|
: constrainedSubtype, adjustedConstraint,
|
469
680
|
/* diag */ undefined,
|
470
|
-
/*
|
471
|
-
/* srcTypeVarContext */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
681
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
472
682
|
constrainedSubtype = (0, typeUtils_1.addConditionToType)(constraint, (0, typeUtils_1.getTypeCondition)(srcSubtype));
|
473
683
|
constraintIndexUsed = i;
|
474
684
|
}
|
@@ -478,7 +688,7 @@ function assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, type
|
|
478
688
|
// We found a source subtype that is not compatible with the dest.
|
479
689
|
// This is OK if we're handling the contravariant case because only
|
480
690
|
// one subtype needs to be assignable in that case.
|
481
|
-
if ((flags & 2 /* AssignTypeFlags.
|
691
|
+
if ((flags & 2 /* AssignTypeFlags.Contravariant */) === 0) {
|
482
692
|
isCompatible = false;
|
483
693
|
}
|
484
694
|
}
|
@@ -505,8 +715,7 @@ function assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, type
|
|
505
715
|
: constraint;
|
506
716
|
return evaluator.assignType(adjustedConstraint, concreteSrcType,
|
507
717
|
/* diag */ undefined,
|
508
|
-
/*
|
509
|
-
/* srcTypeVarContext */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount);
|
718
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount);
|
510
719
|
});
|
511
720
|
}
|
512
721
|
}
|
@@ -521,22 +730,20 @@ function assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, type
|
|
521
730
|
return false;
|
522
731
|
}
|
523
732
|
else if ((0, typeUtils_1.isLiteralTypeOrUnion)(constrainedType)) {
|
524
|
-
|
733
|
+
retainLiterals = true;
|
525
734
|
}
|
526
735
|
if (curLowerBound && !(0, types_1.isAnyOrUnknown)(curLowerBound)) {
|
527
736
|
if (!evaluator.assignType(curLowerBound, constrainedType,
|
528
737
|
/* diag */ undefined,
|
529
|
-
/*
|
530
|
-
/* srcTypeVarContext */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
738
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
531
739
|
// Handle the case where one of the constrained types is a wider
|
532
740
|
// version of another constrained type that was previously assigned
|
533
741
|
// to the type variable.
|
534
742
|
if (evaluator.assignType(constrainedType, curLowerBound,
|
535
743
|
/* diag */ undefined,
|
536
|
-
/*
|
537
|
-
|
538
|
-
|
539
|
-
updateTypeVarType(evaluator, typeVarContext, destType, constrainedType, curUpperBound);
|
744
|
+
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
|
745
|
+
if (constraints && !constraints.isLocked()) {
|
746
|
+
constraints.setBounds(destType, constrainedType, curUpperBound);
|
540
747
|
}
|
541
748
|
}
|
542
749
|
else {
|
@@ -550,21 +757,32 @@ function assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, type
|
|
550
757
|
}
|
551
758
|
else {
|
552
759
|
// Assign the type to the type var.
|
553
|
-
if (!
|
554
|
-
|
760
|
+
if (constraints && !constraints.isLocked()) {
|
761
|
+
constraints.setBounds(destType, constrainedType, curUpperBound, retainLiterals);
|
555
762
|
}
|
556
763
|
}
|
557
764
|
return true;
|
558
765
|
}
|
559
|
-
|
766
|
+
// Handles assignments to a ParamSpec.
|
767
|
+
function assignParamSpec(evaluator, destType, srcType, diag, constraints, recursionCount = 0) {
|
768
|
+
// If there is no constraint tracker, there's nothing to do because
|
769
|
+
// param specs have no upper bounds or constraints.
|
770
|
+
if (!constraints) {
|
771
|
+
return true;
|
772
|
+
}
|
560
773
|
let isAssignable = true;
|
561
|
-
|
562
|
-
|
774
|
+
let adjSrcType = (0, types_1.isParamSpec)(srcType) ? srcType : (0, typeUtils_1.convertTypeToParamSpecValue)(srcType);
|
775
|
+
if ((0, types_1.isFunction)(adjSrcType)) {
|
776
|
+
adjSrcType = (0, typeUtils_1.simplifyFunctionToParamSpec)(adjSrcType);
|
777
|
+
}
|
778
|
+
constraints.doForEachConstraintSet((constraintSet) => {
|
779
|
+
var _a, _b;
|
563
780
|
if ((0, types_1.isParamSpec)(adjSrcType)) {
|
564
|
-
const existingType =
|
781
|
+
const existingType = (_a = constraintSet.getTypeVar(destType)) === null || _a === void 0 ? void 0 : _a.lowerBound;
|
565
782
|
if (existingType) {
|
566
|
-
const
|
567
|
-
const
|
783
|
+
const paramSpecValue = (0, typeUtils_1.convertTypeToParamSpecValue)(existingType);
|
784
|
+
const existingTypeParamSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(paramSpecValue);
|
785
|
+
const existingTypeWithoutArgsKwargs = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(paramSpecValue);
|
568
786
|
if (existingTypeWithoutArgsKwargs.shared.parameters.length === 0 && existingTypeParamSpec) {
|
569
787
|
// If there's an existing entry that matches, that's fine.
|
570
788
|
if ((0, types_1.isTypeSame)(existingTypeParamSpec, adjSrcType, {}, recursionCount)) {
|
@@ -573,8 +791,8 @@ function assignTypeToParamSpec(evaluator, destType, srcType, diag, typeVarContex
|
|
573
791
|
}
|
574
792
|
}
|
575
793
|
else {
|
576
|
-
if (!
|
577
|
-
|
794
|
+
if (!constraints.isLocked()) {
|
795
|
+
constraintSet.setBounds(destType, adjSrcType);
|
578
796
|
}
|
579
797
|
return;
|
580
798
|
}
|
@@ -582,19 +800,17 @@ function assignTypeToParamSpec(evaluator, destType, srcType, diag, typeVarContex
|
|
582
800
|
else if ((0, types_1.isFunction)(adjSrcType)) {
|
583
801
|
const newFunction = adjSrcType;
|
584
802
|
let updateContextWithNewFunction = false;
|
585
|
-
const existingType =
|
803
|
+
const existingType = (_b = constraintSet.getTypeVar(destType)) === null || _b === void 0 ? void 0 : _b.lowerBound;
|
586
804
|
if (existingType) {
|
587
805
|
// Convert the remaining portion of the signature to a function
|
588
806
|
// for comparison purposes.
|
589
|
-
const existingFunction = (0, typeUtils_1.
|
807
|
+
const existingFunction = (0, typeUtils_1.simplifyFunctionToParamSpec)((0, typeUtils_1.convertTypeToParamSpecValue)(existingType));
|
590
808
|
const isNewNarrower = evaluator.assignType(existingFunction, newFunction,
|
591
809
|
/* diag */ undefined,
|
592
|
-
/*
|
593
|
-
/* srcTypeVarContext */ undefined, 64 /* AssignTypeFlags.SkipReturnTypeCheck */, recursionCount);
|
810
|
+
/* constraints */ undefined, 64 /* AssignTypeFlags.SkipReturnTypeCheck */, recursionCount);
|
594
811
|
const isNewWider = evaluator.assignType(newFunction, existingFunction,
|
595
812
|
/* diag */ undefined,
|
596
|
-
/*
|
597
|
-
/* srcTypeVarContext */ undefined, 64 /* AssignTypeFlags.SkipReturnTypeCheck */, recursionCount);
|
813
|
+
/* constraints */ undefined, 64 /* AssignTypeFlags.SkipReturnTypeCheck */, recursionCount);
|
598
814
|
// Should we widen the type?
|
599
815
|
if (isNewNarrower && isNewWider) {
|
600
816
|
// The new type is both a supertype and a subtype of the existing type.
|
@@ -622,8 +838,8 @@ function assignTypeToParamSpec(evaluator, destType, srcType, diag, typeVarContex
|
|
622
838
|
updateContextWithNewFunction = true;
|
623
839
|
}
|
624
840
|
if (updateContextWithNewFunction) {
|
625
|
-
if (!
|
626
|
-
|
841
|
+
if (!constraints.isLocked()) {
|
842
|
+
constraintSet.setBounds(destType, newFunction);
|
627
843
|
}
|
628
844
|
return;
|
629
845
|
}
|
@@ -637,149 +853,8 @@ function assignTypeToParamSpec(evaluator, destType, srcType, diag, typeVarContex
|
|
637
853
|
}));
|
638
854
|
isAssignable = false;
|
639
855
|
});
|
640
|
-
if (logTypeVarContextUpdates) {
|
641
|
-
const indent = ' '.repeat(recursionCount * 2);
|
642
|
-
console.log(`${indent}`);
|
643
|
-
console.log(`${indent}post-call typeVarContext: `);
|
644
|
-
logTypeVarContext(evaluator, typeVarContext, indent);
|
645
|
-
}
|
646
856
|
return isAssignable;
|
647
857
|
}
|
648
|
-
// In cases where the expected type is a specialized base class of the
|
649
|
-
// source type, we need to determine which type arguments in the derived
|
650
|
-
// class will make it compatible with the specialized base class. This method
|
651
|
-
// performs this reverse mapping of type arguments and populates the type var
|
652
|
-
// map for the target type. If the type is not assignable to the expected type,
|
653
|
-
// it returns false.
|
654
|
-
function addConstraintsForExpectedType(evaluator, type, expectedType, typeVarContext, liveTypeVarScopes, usageOffset = undefined) {
|
655
|
-
if ((0, types_1.isAny)(expectedType)) {
|
656
|
-
type.shared.typeParams.forEach((typeParam) => {
|
657
|
-
updateTypeVarType(evaluator, typeVarContext, typeParam, expectedType, expectedType);
|
658
|
-
});
|
659
|
-
return true;
|
660
|
-
}
|
661
|
-
if ((0, types_1.isTypeVar)(expectedType) && expectedType.shared.isSynthesizedSelf && expectedType.shared.boundType) {
|
662
|
-
expectedType = expectedType.shared.boundType;
|
663
|
-
}
|
664
|
-
if (!(0, types_1.isClass)(expectedType)) {
|
665
|
-
return false;
|
666
|
-
}
|
667
|
-
// If the expected type is generic (but not specialized), we can't proceed.
|
668
|
-
const expectedTypeArgs = expectedType.priv.typeArgs;
|
669
|
-
if (!expectedTypeArgs) {
|
670
|
-
return evaluator.assignType(type, expectedType,
|
671
|
-
/* diag */ undefined, typeVarContext,
|
672
|
-
/* srcTypeVarContext */ undefined, 2048 /* AssignTypeFlags.PopulatingExpectedType */);
|
673
|
-
}
|
674
|
-
evaluator.inferVarianceForClass(type);
|
675
|
-
// If the expected type is the same as the target type (commonly the case),
|
676
|
-
// we can use a faster method.
|
677
|
-
if (types_1.ClassType.isSameGenericClass(expectedType, type)) {
|
678
|
-
const sameClassTypeVarContext = (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(expectedType);
|
679
|
-
sameClassTypeVarContext
|
680
|
-
.getMainSolutionSet()
|
681
|
-
.getTypeVars()
|
682
|
-
.forEach((entry) => {
|
683
|
-
let typeArgValue = sameClassTypeVarContext.getMainSolutionSet().getTypeVarType(entry.typeVar);
|
684
|
-
if (typeArgValue && liveTypeVarScopes) {
|
685
|
-
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes, usageOffset);
|
686
|
-
}
|
687
|
-
if (typeArgValue) {
|
688
|
-
const variance = types_1.TypeVarType.getVariance(entry.typeVar);
|
689
|
-
updateTypeVarType(evaluator, typeVarContext, entry.typeVar, variance === 3 /* Variance.Covariant */ ? undefined : typeArgValue, variance === 4 /* Variance.Contravariant */ ? undefined : typeArgValue);
|
690
|
-
}
|
691
|
-
});
|
692
|
-
return true;
|
693
|
-
}
|
694
|
-
// Create a generic version of the expected type.
|
695
|
-
const expectedTypeScopeId = (0, typeUtils_1.getTypeVarScopeId)(expectedType);
|
696
|
-
const synthExpectedTypeArgs = types_1.ClassType.getTypeParams(expectedType).map((typeParam, index) => {
|
697
|
-
const typeVar = types_1.TypeVarType.createInstance(`__dest${index}`, (0, types_1.isParamSpec)(typeParam) ? types_1.TypeVarKind.ParamSpec : types_1.TypeVarKind.TypeVar);
|
698
|
-
typeVar.shared.isSynthesized = true;
|
699
|
-
// Use invariance here so we set the lower and upper bound on the TypeVar.
|
700
|
-
typeVar.shared.declaredVariance = 2 /* Variance.Invariant */;
|
701
|
-
typeVar.priv.scopeId = expectedTypeScopeId;
|
702
|
-
return typeVar;
|
703
|
-
});
|
704
|
-
const genericExpectedType = types_1.ClassType.specialize(expectedType, synthExpectedTypeArgs);
|
705
|
-
// For each type param in the target type, create a placeholder type variable.
|
706
|
-
const typeArgs = types_1.ClassType.getTypeParams(type).map((typeParam, index) => {
|
707
|
-
const typeVar = types_1.TypeVarType.createInstance(`__source${index}`, (0, types_1.isParamSpec)(typeParam) ? types_1.TypeVarKind.ParamSpec : types_1.TypeVarKind.TypeVar);
|
708
|
-
typeVar.shared.isSynthesized = true;
|
709
|
-
typeVar.shared.synthesizedIndex = index;
|
710
|
-
typeVar.shared.isExemptFromBoundCheck = true;
|
711
|
-
return types_1.TypeVarType.cloneAsInScopePlaceholder(typeVar);
|
712
|
-
});
|
713
|
-
const specializedType = types_1.ClassType.specialize(type, typeArgs);
|
714
|
-
const syntheticTypeVarContext = new typeVarContext_1.TypeVarContext(expectedTypeScopeId);
|
715
|
-
if (evaluator.assignType(genericExpectedType, specializedType,
|
716
|
-
/* diag */ undefined, syntheticTypeVarContext,
|
717
|
-
/* srcTypeVarContext */ undefined, 2048 /* AssignTypeFlags.PopulatingExpectedType */)) {
|
718
|
-
let isResultValid = true;
|
719
|
-
synthExpectedTypeArgs.forEach((typeVar, index) => {
|
720
|
-
let synthTypeVar = syntheticTypeVarContext.getMainSolutionSet().getTypeVarType(typeVar);
|
721
|
-
const otherSubtypes = [];
|
722
|
-
// If the resulting type is a union, try to find a matching type var and move
|
723
|
-
// the remaining subtypes to the "otherSubtypes" array.
|
724
|
-
if (synthTypeVar) {
|
725
|
-
if ((0, types_1.isParamSpec)(typeVar) && (0, types_1.isFunction)(synthTypeVar)) {
|
726
|
-
synthTypeVar = (0, typeUtils_1.convertParamSpecValueToType)(synthTypeVar);
|
727
|
-
}
|
728
|
-
if ((0, types_1.isUnion)(synthTypeVar)) {
|
729
|
-
let foundSynthTypeVar;
|
730
|
-
(0, typeUtils_1.sortTypes)(synthTypeVar.priv.subtypes).forEach((subtype) => {
|
731
|
-
if ((0, types_1.isTypeVar)(subtype) &&
|
732
|
-
subtype.shared.isSynthesized &&
|
733
|
-
subtype.shared.synthesizedIndex !== undefined &&
|
734
|
-
!foundSynthTypeVar) {
|
735
|
-
foundSynthTypeVar = subtype;
|
736
|
-
}
|
737
|
-
else {
|
738
|
-
otherSubtypes.push(subtype);
|
739
|
-
}
|
740
|
-
});
|
741
|
-
if (foundSynthTypeVar) {
|
742
|
-
synthTypeVar = foundSynthTypeVar;
|
743
|
-
}
|
744
|
-
}
|
745
|
-
}
|
746
|
-
// Is this one of the synthesized type vars we allocated above? If so,
|
747
|
-
// the type arg that corresponds to this type var maps back to the target type.
|
748
|
-
if (synthTypeVar &&
|
749
|
-
(0, types_1.isTypeVar)(synthTypeVar) &&
|
750
|
-
synthTypeVar.shared.isSynthesized &&
|
751
|
-
synthTypeVar.shared.synthesizedIndex !== undefined) {
|
752
|
-
const targetTypeVar = types_1.ClassType.getTypeParams(specializedType)[synthTypeVar.shared.synthesizedIndex];
|
753
|
-
if (index < expectedTypeArgs.length) {
|
754
|
-
let typeArgValue = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expectedTypeArgs[index]);
|
755
|
-
if (otherSubtypes.length > 0) {
|
756
|
-
typeArgValue = (0, types_1.combineTypes)([typeArgValue, ...otherSubtypes]);
|
757
|
-
}
|
758
|
-
if (liveTypeVarScopes) {
|
759
|
-
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes, usageOffset);
|
760
|
-
}
|
761
|
-
if (typeArgValue) {
|
762
|
-
const variance = types_1.TypeVarType.getVariance(typeVar);
|
763
|
-
// If this type variable already has a type, don't overwrite it. This can
|
764
|
-
// happen if a single type variable in the derived class is used multiple times
|
765
|
-
// in the specialized base class type (e.g. Mapping[T, T]).
|
766
|
-
if (typeVarContext.getMainSolutionSet().getTypeVarType(targetTypeVar)) {
|
767
|
-
isResultValid = false;
|
768
|
-
typeArgValue = types_1.UnknownType.create();
|
769
|
-
}
|
770
|
-
updateTypeVarType(evaluator, typeVarContext, targetTypeVar, variance === 3 /* Variance.Covariant */ ? undefined : typeArgValue, variance === 4 /* Variance.Contravariant */ ? undefined : typeArgValue);
|
771
|
-
}
|
772
|
-
else {
|
773
|
-
isResultValid = false;
|
774
|
-
}
|
775
|
-
}
|
776
|
-
}
|
777
|
-
});
|
778
|
-
return isResultValid;
|
779
|
-
}
|
780
|
-
return false;
|
781
|
-
}
|
782
|
-
exports.addConstraintsForExpectedType = addConstraintsForExpectedType;
|
783
858
|
// For normal TypeVars, the constraint solver can widen a type by combining
|
784
859
|
// two otherwise incompatible types into a union. For TypeVarTuples, we need
|
785
860
|
// to do the equivalent operation for unpacked tuples.
|
@@ -829,28 +904,27 @@ function stripLiteralValueForUnpackedTuple(evaluator, type) {
|
|
829
904
|
return (0, typeUtils_1.specializeTupleClass)(type, tupleTypeArgs, /* isTypeArgExplicit */ true, /* isUnpackedTuple */ true);
|
830
905
|
}
|
831
906
|
// This function is used for debugging only. It dumps the current contents of
|
832
|
-
// the
|
833
|
-
function
|
834
|
-
const
|
835
|
-
if (
|
907
|
+
// the constraints to the console.
|
908
|
+
function logConstraints(evaluator, constraints, indent) {
|
909
|
+
const constraintSetCount = constraints.getConstraintSets().length;
|
910
|
+
if (constraintSetCount === 0) {
|
836
911
|
console.log(`${indent} no signatures`);
|
837
912
|
}
|
838
|
-
else if (
|
839
|
-
|
913
|
+
else if (constraintSetCount === 1) {
|
914
|
+
logTypeVarConstraintSet(evaluator, constraints.getConstraintSets()[0], `${indent} `);
|
840
915
|
}
|
841
916
|
else {
|
842
|
-
|
917
|
+
constraints.doForEachConstraintSet((set, index) => {
|
843
918
|
console.log(`${indent} signature ${index}`);
|
844
|
-
|
919
|
+
logTypeVarConstraintSet(evaluator, set, `${indent} `);
|
845
920
|
});
|
846
921
|
}
|
847
922
|
}
|
848
|
-
function
|
923
|
+
function logTypeVarConstraintSet(evaluator, context, indent) {
|
849
924
|
let loggedConstraint = false;
|
850
925
|
context.getTypeVars().forEach((entry) => {
|
851
|
-
var _a;
|
852
926
|
const typeVarName = `${indent}${entry.typeVar.shared.name}`;
|
853
|
-
const lowerBound =
|
927
|
+
const lowerBound = entry.lowerBound;
|
854
928
|
const upperBound = entry.upperBound;
|
855
929
|
// Log the lower and upper bounds.
|
856
930
|
if (lowerBound && upperBound && (0, types_1.isTypeSame)(lowerBound, upperBound)) {
|