@zzzen/pyright-internal 1.2.0-dev.20231112 → 1.2.0-dev.20231126
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.d.ts +1 -1
- package/dist/analyzer/analysis.js +5 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.d.ts +1 -1
- package/dist/analyzer/analyzerNodeInfo.d.ts +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +1 -1
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +198 -194
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.js +1 -1
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +286 -256
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +1 -1
- package/dist/analyzer/codeFlowEngine.js +26 -26
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +1 -1
- package/dist/analyzer/codeFlowTypes.js +23 -23
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +39 -37
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +48 -45
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +8 -8
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +33 -31
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +67 -63
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +2 -2
- package/dist/analyzer/declaration.js +10 -10
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +44 -41
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +51 -51
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +1 -1
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/docStringUtils.js +1 -1
- package/dist/analyzer/enums.js +27 -27
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +4 -4
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +27 -18
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.js +1 -1
- package/dist/analyzer/importResult.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +31 -27
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +36 -32
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +78 -78
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeReport.d.ts +1 -1
- package/dist/analyzer/packageTypeReport.js +2 -2
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +90 -90
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +14 -14
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.d.ts +2 -2
- package/dist/analyzer/parseTreeCleaner.js +5 -1
- package/dist/analyzer/parseTreeCleaner.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -1
- package/dist/analyzer/parseTreeUtils.js +383 -379
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +161 -157
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.d.ts +1 -1
- package/dist/analyzer/patternMatching.js +71 -64
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -1
- package/dist/analyzer/program.js +20 -17
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +53 -44
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +14 -14
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +5 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/regions.js +3 -3
- package/dist/analyzer/regions.js.map +1 -1
- package/dist/analyzer/scope.js +8 -8
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js +1 -1
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.js +5 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +25 -21
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +2 -2
- package/dist/analyzer/sourceMapper.js +15 -8
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +40 -40
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/symbol.d.ts +1 -1
- package/dist/analyzer/symbol.js +26 -26
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/symbolUtils.js +1 -1
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/testWalker.js +5 -5
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +1 -1
- package/dist/analyzer/tracePrinter.js +35 -31
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +5 -1
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +13 -9
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +1272 -1176
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +3 -1
- package/dist/analyzer/typeEvaluatorTypes.js +3 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +1 -1
- package/dist/analyzer/typeGuards.js +95 -67
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.d.ts +1 -1
- package/dist/analyzer/typePrinter.js +80 -76
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +26 -22
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +163 -123
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.d.ts +1 -0
- package/dist/analyzer/typeVarContext.js +12 -9
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.js +10 -10
- package/dist/analyzer/typedDicts.js +74 -70
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +17 -12
- package/dist/analyzer/types.js +191 -181
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +2 -2
- package/dist/backgroundAnalysisBase.js +5 -1
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +5 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/commandController.js +7 -7
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/commandResult.js +1 -1
- package/dist/commands/commandResult.js.map +1 -1
- package/dist/commands/commands.js +1 -1
- package/dist/commands/commands.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +196 -196
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/charCodes.js +1 -1
- package/dist/common/charCodes.js.map +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +5 -1
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/collectionUtils.d.ts +3 -3
- package/dist/common/collectionUtils.js +3 -3
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -1
- package/dist/common/commandLineOptions.js +5 -5
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -1
- package/dist/common/configOptions.js +11 -7
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +7 -3
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.d.ts +2 -2
- package/dist/common/core.js +6 -6
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.js +6 -6
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticRules.js +1 -1
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/diagnosticSink.js +12 -12
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/editAction.d.ts +1 -1
- package/dist/common/editAction.js +2 -2
- package/dist/common/editAction.js.map +1 -1
- package/dist/common/envVarUtils.js +5 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.js +1 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js +5 -1
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js +2 -2
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fileWatcher.d.ts +2 -2
- package/dist/common/fullAccessHost.js +10 -6
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.d.ts +1 -1
- package/dist/common/host.js +2 -2
- package/dist/common/host.js.map +1 -1
- package/dist/common/lspUtils.js +7 -7
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/memUtils.d.ts +1 -1
- package/dist/common/pathUtils.js +12 -8
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/pythonVersion.js +1 -1
- package/dist/common/pythonVersion.js.map +1 -1
- package/dist/common/realFileSystem.js +5 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.d.ts +1 -1
- package/dist/common/serviceProvider.js +5 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +1 -1
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/stringUtils.js +5 -5
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.js +11 -7
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.js +3 -3
- package/dist/common/textRange.js.map +1 -1
- package/dist/languageServerBase.d.ts +3 -3
- package/dist/languageServerBase.js +19 -19
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +3 -3
- package/dist/languageService/autoImporter.js +12 -8
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +27 -23
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js +8 -8
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +171 -173
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +9 -9
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +14 -10
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js +7 -3
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +1 -1
- package/dist/languageService/documentSymbolCollector.js +21 -17
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/hoverProvider.js +30 -26
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js +1 -1
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/quickActions.js +10 -6
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +1 -1
- package/dist/languageService/referencesProvider.js +24 -20
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +8 -4
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.js +8 -4
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +20 -16
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +5 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +10 -12
- package/dist/localization/localize.js +8 -5
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +5 -8
- package/dist/localization/package.nls.de.json +5 -8
- package/dist/localization/package.nls.en-us.json +12 -9
- package/dist/localization/package.nls.es.json +5 -8
- package/dist/localization/package.nls.fr.json +5 -8
- package/dist/localization/package.nls.it.json +5 -8
- package/dist/localization/package.nls.ja.json +5 -8
- package/dist/localization/package.nls.ko.json +5 -8
- package/dist/localization/package.nls.pl.json +5 -8
- package/dist/localization/package.nls.pt-br.json +5 -8
- package/dist/localization/package.nls.qps-ploc.json +2 -5
- package/dist/localization/package.nls.ru.json +5 -8
- package/dist/localization/package.nls.tr.json +5 -8
- package/dist/localization/package.nls.zh-cn.json +5 -8
- package/dist/localization/package.nls.zh-tw.json +5 -8
- package/dist/parser/characterStream.js +3 -3
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/characters.js +13 -9
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +12 -12
- package/dist/parser/parseNodes.js +193 -193
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +563 -559
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +47 -47
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizer.js +288 -288
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/tokenizerTypes.js +35 -35
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/parser/unicode.d.ts +3 -3
- package/dist/pyright.js +38 -18
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +1 -0
- package/dist/pyrightFileSystem.js +1 -1
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +1 -0
- package/dist/tests/chainedSourceFiles.test.js +5 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +5 -1
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/collectionUtils.test.js +5 -1
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/common.test.js +5 -1
- package/dist/tests/common.test.js.map +1 -1
- package/dist/tests/config.test.js +7 -5
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js +8 -4
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/deferred.test.js +5 -1
- package/dist/tests/deferred.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js +5 -1
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +0 -22
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/docStringUtils.test.js +5 -1
- package/dist/tests/docStringUtils.test.js.map +1 -1
- package/dist/tests/filesystem.test.js +5 -1
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js +5 -1
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourSlashRunner.test.js +5 -1
- package/dist/tests/fourSlashRunner.test.js.map +1 -1
- package/dist/tests/fourslash/completions.params.fourslash.js +11 -0
- package/dist/tests/fourslash/completions.params.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js +10 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +13 -13
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js +11 -7
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/runner.d.ts +1 -1
- package/dist/tests/harness/fourslash/runner.js +5 -1
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +5 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.js +6 -2
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +17 -13
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +9 -5
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +5 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testHost.js +5 -1
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/utils.d.ts +13 -12
- package/dist/tests/harness/utils.js.map +1 -1
- package/dist/tests/harness/vfs/factory.js +6 -2
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +4 -3
- package/dist/tests/harness/vfs/filesystem.js +11 -7
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +30 -26
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +25 -25
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +6 -6
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/localizer.test.js +5 -1
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/logger.test.js +5 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +10 -10
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +13 -9
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +5 -1
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +5 -1
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +5 -1
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/stringUtils.test.js +10 -6
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symbolNameUtils.test.js +5 -1
- package/dist/tests/symbolNameUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +5 -1
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testUtils.js +11 -7
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textRange.test.js +5 -1
- package/dist/tests/textRange.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js +463 -459
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +18 -2
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +19 -3
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +11 -3
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +11 -3
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +5 -1
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +44 -40
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +5 -1
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +5 -1
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.js +2 -2
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -2
@@ -54,7 +54,7 @@ var MemberAccessFlags;
|
|
54
54
|
// (__getattr__, etc.) may provide the missing attribute type.
|
55
55
|
// This disables this check.
|
56
56
|
MemberAccessFlags[MemberAccessFlags["SkipAttributeAccessOverride"] = 512] = "SkipAttributeAccessOverride";
|
57
|
-
})(MemberAccessFlags
|
57
|
+
})(MemberAccessFlags || (exports.MemberAccessFlags = MemberAccessFlags = {}));
|
58
58
|
var ClassIteratorFlags;
|
59
59
|
(function (ClassIteratorFlags) {
|
60
60
|
ClassIteratorFlags[ClassIteratorFlags["Default"] = 0] = "Default";
|
@@ -66,7 +66,7 @@ var ClassIteratorFlags;
|
|
66
66
|
ClassIteratorFlags[ClassIteratorFlags["SkipObjectBaseClass"] = 2] = "SkipObjectBaseClass";
|
67
67
|
// Skip the 'type' base class in particular.
|
68
68
|
ClassIteratorFlags[ClassIteratorFlags["SkipTypeBaseClass"] = 4] = "SkipTypeBaseClass";
|
69
|
-
})(ClassIteratorFlags
|
69
|
+
})(ClassIteratorFlags || (exports.ClassIteratorFlags = ClassIteratorFlags = {}));
|
70
70
|
var AssignTypeFlags;
|
71
71
|
(function (AssignTypeFlags) {
|
72
72
|
AssignTypeFlags[AssignTypeFlags["Default"] = 0] = "Default";
|
@@ -119,7 +119,7 @@ var AssignTypeFlags;
|
|
119
119
|
// the source must be a "concrete" (non-protocol) class. This
|
120
120
|
// flag skips this check.
|
121
121
|
AssignTypeFlags[AssignTypeFlags["IgnoreProtocolAssignmentCheck"] = 4096] = "IgnoreProtocolAssignmentCheck";
|
122
|
-
})(AssignTypeFlags
|
122
|
+
})(AssignTypeFlags || (exports.AssignTypeFlags = AssignTypeFlags = {}));
|
123
123
|
// Tracks whether a function signature has been seen before within
|
124
124
|
// an expression. For example, in the expression "foo(foo, foo)", the
|
125
125
|
// signature for "foo" will be seen three times at three different
|
@@ -252,7 +252,7 @@ function mapSubtypes(type, callback, sortSubtypes = false) {
|
|
252
252
|
}
|
253
253
|
const newType = (0, types_1.combineTypes)(typesToCombine);
|
254
254
|
// Do our best to retain type aliases.
|
255
|
-
if (newType.category === 8 /* Union */) {
|
255
|
+
if (newType.category === 8 /* TypeCategory.Union */) {
|
256
256
|
types_1.UnionType.addTypeAliasSource(newType, type);
|
257
257
|
}
|
258
258
|
return newType;
|
@@ -363,14 +363,14 @@ function compareTypes(a, b, recursionCount = 0) {
|
|
363
363
|
return b.category - a.category;
|
364
364
|
}
|
365
365
|
switch (a.category) {
|
366
|
-
case 0 /* Unbound */:
|
367
|
-
case 1 /* Unknown */:
|
368
|
-
case 2 /* Any */:
|
369
|
-
case 3 /* Never */:
|
370
|
-
case 8 /* Union */: {
|
366
|
+
case 0 /* TypeCategory.Unbound */:
|
367
|
+
case 1 /* TypeCategory.Unknown */:
|
368
|
+
case 2 /* TypeCategory.Any */:
|
369
|
+
case 3 /* TypeCategory.Never */:
|
370
|
+
case 8 /* TypeCategory.Union */: {
|
371
371
|
return 0;
|
372
372
|
}
|
373
|
-
case 4 /* Function */: {
|
373
|
+
case 4 /* TypeCategory.Function */: {
|
374
374
|
const bFunc = b;
|
375
375
|
const aParamCount = a.details.parameters.length;
|
376
376
|
const bParamCount = bFunc.details.parameters.length;
|
@@ -402,7 +402,7 @@ function compareTypes(a, b, recursionCount = 0) {
|
|
402
402
|
}
|
403
403
|
return 0;
|
404
404
|
}
|
405
|
-
case 5 /* OverloadedFunction */: {
|
405
|
+
case 5 /* TypeCategory.OverloadedFunction */: {
|
406
406
|
const bOver = b;
|
407
407
|
const aOverloadCount = a.overloads.length;
|
408
408
|
const bOverloadCount = bOver.overloads.length;
|
@@ -417,7 +417,7 @@ function compareTypes(a, b, recursionCount = 0) {
|
|
417
417
|
}
|
418
418
|
return 0;
|
419
419
|
}
|
420
|
-
case 6 /* Class */: {
|
420
|
+
case 6 /* TypeCategory.Class */: {
|
421
421
|
const bClass = b;
|
422
422
|
// Sort instances before instantiables.
|
423
423
|
if ((0, types_1.isClassInstance)(a) && (0, types_1.isInstantiableClass)(bClass)) {
|
@@ -478,12 +478,12 @@ function compareTypes(a, b, recursionCount = 0) {
|
|
478
478
|
}
|
479
479
|
return 0;
|
480
480
|
}
|
481
|
-
case 7 /* Module */: {
|
481
|
+
case 7 /* TypeCategory.Module */: {
|
482
482
|
const aName = a.moduleName;
|
483
483
|
const bName = b.moduleName;
|
484
484
|
return aName < bName ? -1 : aName === bName ? 0 : 1;
|
485
485
|
}
|
486
|
-
case 9 /* TypeVar */: {
|
486
|
+
case 9 /* TypeCategory.TypeVar */: {
|
487
487
|
const aName = a.details.name;
|
488
488
|
const bName = b.details.name;
|
489
489
|
return aName < bName ? -1 : aName === bName ? 0 : 1;
|
@@ -548,7 +548,7 @@ exports.preserveUnknown = preserveUnknown;
|
|
548
548
|
// Determines whether the specified type is a type that can be
|
549
549
|
// combined with other types for a union.
|
550
550
|
function isUnionableType(subtypes) {
|
551
|
-
let typeFlags = 2 /* Instance */ | 1 /* Instantiable */;
|
551
|
+
let typeFlags = 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */;
|
552
552
|
for (const subtype of subtypes) {
|
553
553
|
typeFlags &= subtype.flags;
|
554
554
|
}
|
@@ -556,7 +556,7 @@ function isUnionableType(subtypes) {
|
|
556
556
|
// and None) are both instances and instantiable. It's OK to
|
557
557
|
// include some of these, but at least one subtype needs to
|
558
558
|
// be definitively instantiable (not an instance).
|
559
|
-
return (typeFlags & 1 /* Instantiable */) !== 0 && (typeFlags & 2 /* Instance */) === 0;
|
559
|
+
return (typeFlags & 1 /* TypeFlags.Instantiable */) !== 0 && (typeFlags & 2 /* TypeFlags.Instance */) === 0;
|
560
560
|
}
|
561
561
|
exports.isUnionableType = isUnionableType;
|
562
562
|
function derivesFromAnyOrUnknown(type) {
|
@@ -585,16 +585,16 @@ function getFullNameOfType(type) {
|
|
585
585
|
return type.typeAliasInfo.fullName;
|
586
586
|
}
|
587
587
|
switch (type.category) {
|
588
|
-
case 2 /* Any */:
|
589
|
-
case 1 /* Unknown */:
|
588
|
+
case 2 /* TypeCategory.Any */:
|
589
|
+
case 1 /* TypeCategory.Unknown */:
|
590
590
|
return 'typing.Any';
|
591
|
-
case 6 /* Class */:
|
591
|
+
case 6 /* TypeCategory.Class */:
|
592
592
|
return type.details.fullName;
|
593
|
-
case 4 /* Function */:
|
593
|
+
case 4 /* TypeCategory.Function */:
|
594
594
|
return type.details.fullName;
|
595
|
-
case 7 /* Module */:
|
595
|
+
case 7 /* TypeCategory.Module */:
|
596
596
|
return type.moduleName;
|
597
|
-
case 5 /* OverloadedFunction */:
|
597
|
+
case 5 /* TypeCategory.OverloadedFunction */:
|
598
598
|
return type.overloads[0].details.fullName;
|
599
599
|
}
|
600
600
|
return undefined;
|
@@ -605,37 +605,37 @@ function addConditionToType(type, condition) {
|
|
605
605
|
return type;
|
606
606
|
}
|
607
607
|
switch (type.category) {
|
608
|
-
case 0 /* Unbound */:
|
609
|
-
case 1 /* Unknown */:
|
610
|
-
case 2 /* Any */:
|
611
|
-
case 3 /* Never */:
|
612
|
-
case 7 /* Module */:
|
613
|
-
case 9 /* TypeVar */:
|
608
|
+
case 0 /* TypeCategory.Unbound */:
|
609
|
+
case 1 /* TypeCategory.Unknown */:
|
610
|
+
case 2 /* TypeCategory.Any */:
|
611
|
+
case 3 /* TypeCategory.Never */:
|
612
|
+
case 7 /* TypeCategory.Module */:
|
613
|
+
case 9 /* TypeCategory.TypeVar */:
|
614
614
|
return type;
|
615
|
-
case 4 /* Function */:
|
615
|
+
case 4 /* TypeCategory.Function */:
|
616
616
|
return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.condition, condition));
|
617
|
-
case 5 /* OverloadedFunction */:
|
617
|
+
case 5 /* TypeCategory.OverloadedFunction */:
|
618
618
|
return types_1.OverloadedFunctionType.create(type.overloads.map((t) => addConditionToType(t, condition)));
|
619
|
-
case 6 /* Class */:
|
619
|
+
case 6 /* TypeCategory.Class */:
|
620
620
|
return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.condition, condition));
|
621
|
-
case 8 /* Union */:
|
621
|
+
case 8 /* TypeCategory.Union */:
|
622
622
|
return (0, types_1.combineTypes)(type.subtypes.map((t) => addConditionToType(t, condition)));
|
623
623
|
}
|
624
624
|
}
|
625
625
|
exports.addConditionToType = addConditionToType;
|
626
626
|
function getTypeCondition(type) {
|
627
627
|
switch (type.category) {
|
628
|
-
case 0 /* Unbound */:
|
629
|
-
case 1 /* Unknown */:
|
630
|
-
case 2 /* Any */:
|
631
|
-
case 3 /* Never */:
|
632
|
-
case 7 /* Module */:
|
633
|
-
case 9 /* TypeVar */:
|
634
|
-
case 5 /* OverloadedFunction */:
|
635
|
-
case 8 /* Union */:
|
628
|
+
case 0 /* TypeCategory.Unbound */:
|
629
|
+
case 1 /* TypeCategory.Unknown */:
|
630
|
+
case 2 /* TypeCategory.Any */:
|
631
|
+
case 3 /* TypeCategory.Never */:
|
632
|
+
case 7 /* TypeCategory.Module */:
|
633
|
+
case 9 /* TypeCategory.TypeVar */:
|
634
|
+
case 5 /* TypeCategory.OverloadedFunction */:
|
635
|
+
case 8 /* TypeCategory.Union */:
|
636
636
|
return undefined;
|
637
|
-
case 6 /* Class */:
|
638
|
-
case 4 /* Function */:
|
637
|
+
case 6 /* TypeCategory.Class */:
|
638
|
+
case 4 /* TypeCategory.Function */:
|
639
639
|
return type.condition;
|
640
640
|
}
|
641
641
|
}
|
@@ -650,7 +650,7 @@ exports.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
|
|
650
650
|
// within the specified type. It's OK if it's used indirectly as
|
651
651
|
// a type argument.
|
652
652
|
function isTypeAliasRecursive(typeAliasPlaceholder, type) {
|
653
|
-
if (type.category !== 8 /* Union */) {
|
653
|
+
if (type.category !== 8 /* TypeCategory.Union */) {
|
654
654
|
if (type === typeAliasPlaceholder) {
|
655
655
|
return true;
|
656
656
|
}
|
@@ -754,7 +754,7 @@ function getUnknownTypeForTypeVar(typeVar) {
|
|
754
754
|
exports.getUnknownTypeForTypeVar = getUnknownTypeForTypeVar;
|
755
755
|
// Returns the "Unknown" equivalent for a ParamSpec.
|
756
756
|
function getUnknownTypeForParamSpec() {
|
757
|
-
const newFunction = types_1.FunctionType.createInstance('', '', '', 65536 /* ParamSpecValue */ | 32768 /* SkipArgsKwargsCompatibilityCheck */);
|
757
|
+
const newFunction = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | 32768 /* FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck */);
|
758
758
|
types_1.FunctionType.addDefaultParameters(newFunction);
|
759
759
|
return newFunction;
|
760
760
|
}
|
@@ -887,7 +887,7 @@ function isCallableType(type) {
|
|
887
887
|
if (types_1.TypeBase.isInstantiable(type)) {
|
888
888
|
return true;
|
889
889
|
}
|
890
|
-
const callMember = lookUpObjectMember(type, '__call__', 16 /* SkipInstanceMembers */);
|
890
|
+
const callMember = lookUpObjectMember(type, '__call__', 16 /* MemberAccessFlags.SkipInstanceMembers */);
|
891
891
|
return !!callMember;
|
892
892
|
}
|
893
893
|
if ((0, types_1.isUnion)(type)) {
|
@@ -1097,13 +1097,13 @@ exports.transformExpectedType = transformExpectedType;
|
|
1097
1097
|
// appears in a parent and a child, the child overrides the parent.
|
1098
1098
|
function getProtocolSymbols(classType) {
|
1099
1099
|
const symbolMap = new Map();
|
1100
|
-
if ((classType.details.flags & 8192 /* ProtocolClass */) !== 0) {
|
1101
|
-
getProtocolSymbolsRecursive(classType, symbolMap, 8192 /* ProtocolClass */);
|
1100
|
+
if ((classType.details.flags & 8192 /* ClassTypeFlags.ProtocolClass */) !== 0) {
|
1101
|
+
getProtocolSymbolsRecursive(classType, symbolMap, 8192 /* ClassTypeFlags.ProtocolClass */);
|
1102
1102
|
}
|
1103
1103
|
return symbolMap;
|
1104
1104
|
}
|
1105
1105
|
exports.getProtocolSymbols = getProtocolSymbols;
|
1106
|
-
function getProtocolSymbolsRecursive(classType, symbolMap, classFlags = 8192 /* ProtocolClass */, recursionCount = 0) {
|
1106
|
+
function getProtocolSymbolsRecursive(classType, symbolMap, classFlags = 8192 /* ClassTypeFlags.ProtocolClass */, recursionCount = 0) {
|
1107
1107
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
1108
1108
|
return;
|
1109
1109
|
}
|
@@ -1160,7 +1160,7 @@ function getContainerDepth(type, recursionCount = 0) {
|
|
1160
1160
|
return 1 + maxChildDepth;
|
1161
1161
|
}
|
1162
1162
|
exports.getContainerDepth = getContainerDepth;
|
1163
|
-
function lookUpObjectMember(objectType, memberName, flags = 0 /* Default */, skipMroClass) {
|
1163
|
+
function lookUpObjectMember(objectType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
|
1164
1164
|
if ((0, types_1.isClassInstance)(objectType)) {
|
1165
1165
|
return lookUpClassMember(objectType, memberName, flags, skipMroClass);
|
1166
1166
|
}
|
@@ -1169,7 +1169,7 @@ function lookUpObjectMember(objectType, memberName, flags = 0 /* Default */, ski
|
|
1169
1169
|
exports.lookUpObjectMember = lookUpObjectMember;
|
1170
1170
|
// Looks up a member in a class using the multiple-inheritance rules
|
1171
1171
|
// defined by Python.
|
1172
|
-
function lookUpClassMember(classType, memberName, flags = 0 /* Default */, skipMroClass) {
|
1172
|
+
function lookUpClassMember(classType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
|
1173
1173
|
var _a;
|
1174
1174
|
const memberItr = getClassMemberIterator(classType, memberName, flags, skipMroClass);
|
1175
1175
|
return (_a = memberItr.next()) === null || _a === void 0 ? void 0 : _a.value;
|
@@ -1185,24 +1185,24 @@ exports.lookUpClassMember = lookUpClassMember;
|
|
1185
1185
|
// (self) -> Iterator[str].
|
1186
1186
|
// If skipMroClass is defined, all MRO classes up to and including that class
|
1187
1187
|
// are skipped.
|
1188
|
-
function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */, skipMroClass) {
|
1189
|
-
const declaredTypesOnly = (flags & 64 /* DeclaredTypesOnly */) !== 0;
|
1188
|
+
function* getClassMemberIterator(classType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
|
1189
|
+
const declaredTypesOnly = (flags & 64 /* MemberAccessFlags.DeclaredTypesOnly */) !== 0;
|
1190
1190
|
let skippedUndeclaredType = false;
|
1191
1191
|
if ((0, types_1.isClass)(classType)) {
|
1192
|
-
let classFlags = 0 /* Default */;
|
1193
|
-
if (flags & 1 /* SkipOriginalClass */) {
|
1192
|
+
let classFlags = 0 /* ClassIteratorFlags.Default */;
|
1193
|
+
if (flags & 1 /* MemberAccessFlags.SkipOriginalClass */) {
|
1194
1194
|
if ((0, types_1.isClass)(classType)) {
|
1195
1195
|
skipMroClass = classType;
|
1196
1196
|
}
|
1197
1197
|
}
|
1198
|
-
if (flags & 2 /* SkipBaseClasses */) {
|
1199
|
-
classFlags = classFlags | 1 /* SkipBaseClasses */;
|
1198
|
+
if (flags & 2 /* MemberAccessFlags.SkipBaseClasses */) {
|
1199
|
+
classFlags = classFlags | 1 /* ClassIteratorFlags.SkipBaseClasses */;
|
1200
1200
|
}
|
1201
|
-
if (flags & 4 /* SkipObjectBaseClass */) {
|
1202
|
-
classFlags = classFlags | 2 /* SkipObjectBaseClass */;
|
1201
|
+
if (flags & 4 /* MemberAccessFlags.SkipObjectBaseClass */) {
|
1202
|
+
classFlags = classFlags | 2 /* ClassIteratorFlags.SkipObjectBaseClass */;
|
1203
1203
|
}
|
1204
|
-
if (flags & 8 /* SkipTypeBaseClass */) {
|
1205
|
-
classFlags = classFlags | 4 /* SkipTypeBaseClass */;
|
1204
|
+
if (flags & 8 /* MemberAccessFlags.SkipTypeBaseClass */) {
|
1205
|
+
classFlags = classFlags | 4 /* ClassIteratorFlags.SkipTypeBaseClass */;
|
1206
1206
|
}
|
1207
1207
|
const classItr = getClassIterator(classType, classFlags, skipMroClass);
|
1208
1208
|
for (const [mroClass, specializedMroClass] of classItr) {
|
@@ -1211,7 +1211,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1211
1211
|
// The class derives from an unknown type, so all bets are off
|
1212
1212
|
// when trying to find a member. Return an unknown symbol.
|
1213
1213
|
const cm = {
|
1214
|
-
symbol: symbol_1.Symbol.createWithType(0 /* None */, mroClass),
|
1214
|
+
symbol: symbol_1.Symbol.createWithType(0 /* SymbolFlags.None */, mroClass),
|
1215
1215
|
isInstanceMember: false,
|
1216
1216
|
isClassMember: true,
|
1217
1217
|
isClassVar: false,
|
@@ -1228,7 +1228,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1228
1228
|
}
|
1229
1229
|
const memberFields = specializedMroClass.details.fields;
|
1230
1230
|
// Look at instance members first if requested.
|
1231
|
-
if ((flags & 16 /* SkipInstanceMembers */) === 0) {
|
1231
|
+
if ((flags & 16 /* MemberAccessFlags.SkipInstanceMembers */) === 0) {
|
1232
1232
|
const symbol = memberFields.get(memberName);
|
1233
1233
|
if (symbol && symbol.isInstanceMember()) {
|
1234
1234
|
const hasDeclaredType = symbol.hasTypedDeclarations();
|
@@ -1250,7 +1250,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1250
1250
|
}
|
1251
1251
|
}
|
1252
1252
|
// Next look at class members.
|
1253
|
-
if ((flags & 32 /* SkipClassMembers */) === 0) {
|
1253
|
+
if ((flags & 32 /* MemberAccessFlags.SkipClassMembers */) === 0) {
|
1254
1254
|
const symbol = memberFields.get(memberName);
|
1255
1255
|
if (symbol && symbol.isClassMember()) {
|
1256
1256
|
const hasDeclaredType = symbol.hasTypedDeclarations();
|
@@ -1266,7 +1266,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1266
1266
|
const isTypedDict = types_1.ClassType.isTypedDictClass(specializedMroClass);
|
1267
1267
|
if (hasDeclaredType && (isDataclass || isTypedDict)) {
|
1268
1268
|
const decls = symbol.getDeclarations();
|
1269
|
-
if (decls.length > 0 && decls[0].type === 1 /* Variable */) {
|
1269
|
+
if (decls.length > 0 && decls[0].type === 1 /* DeclarationType.Variable */) {
|
1270
1270
|
isInstanceMember = true;
|
1271
1271
|
isClassMember = isDataclass;
|
1272
1272
|
}
|
@@ -1293,7 +1293,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1293
1293
|
// The class derives from an unknown type, so all bets are off
|
1294
1294
|
// when trying to find a member. Return an Any or Unknown symbol.
|
1295
1295
|
const cm = {
|
1296
|
-
symbol: symbol_1.Symbol.createWithType(0 /* None */, classType),
|
1296
|
+
symbol: symbol_1.Symbol.createWithType(0 /* SymbolFlags.None */, classType),
|
1297
1297
|
isInstanceMember: false,
|
1298
1298
|
isClassMember: true,
|
1299
1299
|
isClassVar: false,
|
@@ -1306,7 +1306,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1306
1306
|
return undefined;
|
1307
1307
|
}
|
1308
1308
|
exports.getClassMemberIterator = getClassMemberIterator;
|
1309
|
-
function* getClassIterator(classType, flags = 0 /* Default */, skipMroClass) {
|
1309
|
+
function* getClassIterator(classType, flags = 0 /* ClassIteratorFlags.Default */, skipMroClass) {
|
1310
1310
|
if ((0, types_1.isClass)(classType)) {
|
1311
1311
|
let foundSkipMroClass = skipMroClass === undefined;
|
1312
1312
|
for (const mroClass of classType.details.mro) {
|
@@ -1327,7 +1327,7 @@ function* getClassIterator(classType, flags = 0 /* Default */, skipMroClass) {
|
|
1327
1327
|
// it in the context of classType.
|
1328
1328
|
const specializedMroClass = partiallySpecializeType(mroClass, classType);
|
1329
1329
|
// Should we ignore members on the 'object' base class?
|
1330
|
-
if (flags & 2 /* SkipObjectBaseClass */) {
|
1330
|
+
if (flags & 2 /* ClassIteratorFlags.SkipObjectBaseClass */) {
|
1331
1331
|
if ((0, types_1.isInstantiableClass)(specializedMroClass)) {
|
1332
1332
|
if (types_1.ClassType.isBuiltIn(specializedMroClass, 'object')) {
|
1333
1333
|
break;
|
@@ -1335,7 +1335,7 @@ function* getClassIterator(classType, flags = 0 /* Default */, skipMroClass) {
|
|
1335
1335
|
}
|
1336
1336
|
}
|
1337
1337
|
// Should we ignore members on the 'type' base class?
|
1338
|
-
if (flags & 4 /* SkipTypeBaseClass */) {
|
1338
|
+
if (flags & 4 /* ClassIteratorFlags.SkipTypeBaseClass */) {
|
1339
1339
|
if ((0, types_1.isInstantiableClass)(specializedMroClass)) {
|
1340
1340
|
if (types_1.ClassType.isBuiltIn(specializedMroClass, 'type')) {
|
1341
1341
|
break;
|
@@ -1343,7 +1343,7 @@ function* getClassIterator(classType, flags = 0 /* Default */, skipMroClass) {
|
|
1343
1343
|
}
|
1344
1344
|
}
|
1345
1345
|
yield [mroClass, specializedMroClass];
|
1346
|
-
if ((flags & 1 /* SkipBaseClasses */) !== 0) {
|
1346
|
+
if ((flags & 1 /* ClassIteratorFlags.SkipBaseClasses */) !== 0) {
|
1347
1347
|
break;
|
1348
1348
|
}
|
1349
1349
|
}
|
@@ -1549,12 +1549,12 @@ function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionC
|
|
1549
1549
|
return;
|
1550
1550
|
}
|
1551
1551
|
switch (destType.category) {
|
1552
|
-
case 8 /* Union */:
|
1552
|
+
case 8 /* TypeCategory.Union */:
|
1553
1553
|
doForEachSubtype(destType, (subtype) => {
|
1554
1554
|
setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
|
1555
1555
|
});
|
1556
1556
|
break;
|
1557
|
-
case 6 /* Class */:
|
1557
|
+
case 6 /* TypeCategory.Class */:
|
1558
1558
|
if (destType.typeArguments) {
|
1559
1559
|
destType.typeArguments.forEach((typeArg) => {
|
1560
1560
|
setTypeArgumentsRecursive(typeArg, srcType, typeVarContext, recursionCount);
|
@@ -1566,7 +1566,7 @@ function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionC
|
|
1566
1566
|
});
|
1567
1567
|
}
|
1568
1568
|
break;
|
1569
|
-
case 4 /* Function */:
|
1569
|
+
case 4 /* TypeCategory.Function */:
|
1570
1570
|
if (destType.specializedTypes) {
|
1571
1571
|
destType.specializedTypes.parameterTypes.forEach((paramType) => {
|
1572
1572
|
setTypeArgumentsRecursive(paramType, srcType, typeVarContext, recursionCount);
|
@@ -1590,12 +1590,12 @@ function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionC
|
|
1590
1590
|
}
|
1591
1591
|
}
|
1592
1592
|
break;
|
1593
|
-
case 5 /* OverloadedFunction */:
|
1593
|
+
case 5 /* TypeCategory.OverloadedFunction */:
|
1594
1594
|
destType.overloads.forEach((subtype) => {
|
1595
1595
|
setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
|
1596
1596
|
});
|
1597
1597
|
break;
|
1598
|
-
case 9 /* TypeVar */:
|
1598
|
+
case 9 /* TypeCategory.TypeVar */:
|
1599
1599
|
if (!typeVarContext.getPrimarySignature().getTypeVar(destType)) {
|
1600
1600
|
typeVarContext.setTypeVarType(destType, srcType);
|
1601
1601
|
}
|
@@ -1788,7 +1788,7 @@ function convertToInstance(type, includeSubclasses = true) {
|
|
1788
1788
|
}
|
1789
1789
|
let result = mapSubtypes(type, (subtype) => {
|
1790
1790
|
switch (subtype.category) {
|
1791
|
-
case 6 /* Class */: {
|
1791
|
+
case 6 /* TypeCategory.Class */: {
|
1792
1792
|
// Handle type[x] as a special case.
|
1793
1793
|
if (types_1.ClassType.isBuiltIn(subtype, 'type')) {
|
1794
1794
|
if (types_1.TypeBase.isInstance(subtype)) {
|
@@ -1809,19 +1809,19 @@ function convertToInstance(type, includeSubclasses = true) {
|
|
1809
1809
|
}
|
1810
1810
|
return types_1.ClassType.cloneAsInstance(subtype, includeSubclasses);
|
1811
1811
|
}
|
1812
|
-
case 4 /* Function */: {
|
1812
|
+
case 4 /* TypeCategory.Function */: {
|
1813
1813
|
if (types_1.TypeBase.isInstantiable(subtype)) {
|
1814
1814
|
return types_1.FunctionType.cloneAsInstance(subtype);
|
1815
1815
|
}
|
1816
1816
|
break;
|
1817
1817
|
}
|
1818
|
-
case 9 /* TypeVar */: {
|
1818
|
+
case 9 /* TypeCategory.TypeVar */: {
|
1819
1819
|
if (types_1.TypeBase.isInstantiable(subtype)) {
|
1820
1820
|
return types_1.TypeVarType.cloneAsInstance(subtype);
|
1821
1821
|
}
|
1822
1822
|
break;
|
1823
1823
|
}
|
1824
|
-
case 2 /* Any */: {
|
1824
|
+
case 2 /* TypeCategory.Any */: {
|
1825
1825
|
return types_1.AnyType.convertToInstance(subtype);
|
1826
1826
|
}
|
1827
1827
|
}
|
@@ -1849,13 +1849,13 @@ function convertToInstantiable(type, includeSubclasses = true) {
|
|
1849
1849
|
}
|
1850
1850
|
let result = mapSubtypes(type, (subtype) => {
|
1851
1851
|
switch (subtype.category) {
|
1852
|
-
case 6 /* Class */: {
|
1852
|
+
case 6 /* TypeCategory.Class */: {
|
1853
1853
|
return types_1.ClassType.cloneAsInstantiable(subtype, includeSubclasses);
|
1854
1854
|
}
|
1855
|
-
case 4 /* Function */: {
|
1855
|
+
case 4 /* TypeCategory.Function */: {
|
1856
1856
|
return types_1.FunctionType.cloneAsInstantiable(subtype);
|
1857
1857
|
}
|
1858
|
-
case 9 /* TypeVar */: {
|
1858
|
+
case 9 /* TypeCategory.TypeVar */: {
|
1859
1859
|
return types_1.TypeVarType.cloneAsInstantiable(subtype);
|
1860
1860
|
}
|
1861
1861
|
}
|
@@ -2173,8 +2173,8 @@ function removeParamSpecVariadicsFromFunction(type) {
|
|
2173
2173
|
}
|
2174
2174
|
const argsParam = type.details.parameters[paramCount - 2];
|
2175
2175
|
const kwargsParam = type.details.parameters[paramCount - 1];
|
2176
|
-
if (argsParam.category !== 1 /* ArgsList */ ||
|
2177
|
-
kwargsParam.category !== 2 /* KwargsDict */ ||
|
2176
|
+
if (argsParam.category !== 1 /* ParameterCategory.ArgsList */ ||
|
2177
|
+
kwargsParam.category !== 2 /* ParameterCategory.KwargsDict */ ||
|
2178
2178
|
!(0, types_1.isParamSpec)(argsParam.type) ||
|
2179
2179
|
!(0, types_1.isParamSpec)(kwargsParam.type) ||
|
2180
2180
|
!(0, types_1.isTypeSame)(argsParam.type, kwargsParam.type)) {
|
@@ -2266,8 +2266,12 @@ function requiresSpecialization(type, options, recursionCount = 0) {
|
|
2266
2266
|
exports.requiresSpecialization = requiresSpecialization;
|
2267
2267
|
function _requiresSpecialization(type, options, recursionCount = 0) {
|
2268
2268
|
var _a;
|
2269
|
+
// If the type is conditioned on a TypeVar, it may need to be specialized.
|
2270
|
+
if (type.condition) {
|
2271
|
+
return true;
|
2272
|
+
}
|
2269
2273
|
switch (type.category) {
|
2270
|
-
case 6 /* Class */: {
|
2274
|
+
case 6 /* TypeCategory.Class */: {
|
2271
2275
|
if (types_1.ClassType.isPseudoGenericClass(type) && (options === null || options === void 0 ? void 0 : options.ignorePseudoGeneric)) {
|
2272
2276
|
return false;
|
2273
2277
|
}
|
@@ -2279,7 +2283,7 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
|
|
2279
2283
|
}
|
2280
2284
|
return types_1.ClassType.getTypeParameters(type).length > 0;
|
2281
2285
|
}
|
2282
|
-
case 4 /* Function */: {
|
2286
|
+
case 4 /* TypeCategory.Function */: {
|
2283
2287
|
if (type.details.paramSpec) {
|
2284
2288
|
return true;
|
2285
2289
|
}
|
@@ -2303,13 +2307,13 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
|
|
2303
2307
|
}
|
2304
2308
|
return false;
|
2305
2309
|
}
|
2306
|
-
case 5 /* OverloadedFunction */: {
|
2310
|
+
case 5 /* TypeCategory.OverloadedFunction */: {
|
2307
2311
|
return type.overloads.some((overload) => requiresSpecialization(overload, options, recursionCount));
|
2308
2312
|
}
|
2309
|
-
case 8 /* Union */: {
|
2313
|
+
case 8 /* TypeCategory.Union */: {
|
2310
2314
|
return type.subtypes.some((subtype) => requiresSpecialization(subtype, options, recursionCount));
|
2311
2315
|
}
|
2312
|
-
case 9 /* TypeVar */: {
|
2316
|
+
case 9 /* TypeCategory.TypeVar */: {
|
2313
2317
|
// Most TypeVar types need to be specialized.
|
2314
2318
|
if (!type.details.recursiveTypeAliasName) {
|
2315
2319
|
if (type.details.isSynthesizedSelf && (options === null || options === void 0 ? void 0 : options.ignoreSelf)) {
|
@@ -2328,13 +2332,13 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
|
|
2328
2332
|
}
|
2329
2333
|
// Combines two variances to produce a resulting variance.
|
2330
2334
|
function combineVariances(variance1, variance2) {
|
2331
|
-
if (variance1 === 1 /* Unknown */) {
|
2335
|
+
if (variance1 === 1 /* Variance.Unknown */) {
|
2332
2336
|
return variance2;
|
2333
2337
|
}
|
2334
|
-
if (variance2 === 2 /* Invariant */ ||
|
2335
|
-
(variance2 === 3 /* Covariant */ && variance1 === 4 /* Contravariant */) ||
|
2336
|
-
(variance2 === 4 /* Contravariant */ && variance1 === 3 /* Covariant */)) {
|
2337
|
-
return 2 /* Invariant */;
|
2338
|
+
if (variance2 === 2 /* Variance.Invariant */ ||
|
2339
|
+
(variance2 === 3 /* Variance.Covariant */ && variance1 === 4 /* Variance.Contravariant */) ||
|
2340
|
+
(variance2 === 4 /* Variance.Contravariant */ && variance1 === 3 /* Variance.Covariant */)) {
|
2341
|
+
return 2 /* Variance.Invariant */;
|
2338
2342
|
}
|
2339
2343
|
return variance1;
|
2340
2344
|
}
|
@@ -2342,12 +2346,12 @@ exports.combineVariances = combineVariances;
|
|
2342
2346
|
// Determines if the variance of the type argument for a generic class is compatible
|
2343
2347
|
// With the declared variance of the corresponding type parameter.
|
2344
2348
|
function isVarianceOfTypeArgumentCompatible(type, typeParamVariance) {
|
2345
|
-
if (typeParamVariance === 1 /* Unknown */ || typeParamVariance === 0 /* Auto */) {
|
2349
|
+
if (typeParamVariance === 1 /* Variance.Unknown */ || typeParamVariance === 0 /* Variance.Auto */) {
|
2346
2350
|
return true;
|
2347
2351
|
}
|
2348
2352
|
if ((0, types_1.isTypeVar)(type) && !type.details.isParamSpec && !type.details.isVariadic) {
|
2349
2353
|
const typeArgVariance = type.details.declaredVariance;
|
2350
|
-
if (typeArgVariance === 4 /* Contravariant */ || typeArgVariance === 3 /* Covariant */) {
|
2354
|
+
if (typeArgVariance === 4 /* Variance.Contravariant */ || typeArgVariance === 3 /* Variance.Covariant */) {
|
2351
2355
|
return typeArgVariance === typeParamVariance;
|
2352
2356
|
}
|
2353
2357
|
}
|
@@ -2362,23 +2366,23 @@ function isVarianceOfTypeArgumentCompatible(type, typeParamVariance) {
|
|
2362
2366
|
typeArgType = type.typeArguments[index];
|
2363
2367
|
}
|
2364
2368
|
const declaredVariance = typeParam.details.declaredVariance;
|
2365
|
-
if (declaredVariance === 0 /* Auto */) {
|
2369
|
+
if (declaredVariance === 0 /* Variance.Auto */) {
|
2366
2370
|
return true;
|
2367
2371
|
}
|
2368
|
-
let effectiveVariance = 2 /* Invariant */;
|
2369
|
-
if (declaredVariance === 3 /* Covariant */) {
|
2372
|
+
let effectiveVariance = 2 /* Variance.Invariant */;
|
2373
|
+
if (declaredVariance === 3 /* Variance.Covariant */) {
|
2370
2374
|
// If the declared variance is covariant, the effective variance
|
2371
2375
|
// is simply copied from the type param variance.
|
2372
2376
|
effectiveVariance = typeParamVariance;
|
2373
2377
|
}
|
2374
|
-
else if (declaredVariance === 4 /* Contravariant */) {
|
2378
|
+
else if (declaredVariance === 4 /* Variance.Contravariant */) {
|
2375
2379
|
// If the declared variance is contravariant, it flips the
|
2376
2380
|
// effective variance from contravariant to covariant or vice versa.
|
2377
|
-
if (typeParamVariance === 3 /* Covariant */) {
|
2378
|
-
effectiveVariance = 4 /* Contravariant */;
|
2381
|
+
if (typeParamVariance === 3 /* Variance.Covariant */) {
|
2382
|
+
effectiveVariance = 4 /* Variance.Contravariant */;
|
2379
2383
|
}
|
2380
|
-
else if (typeParamVariance === 4 /* Contravariant */) {
|
2381
|
-
effectiveVariance = 3 /* Covariant */;
|
2384
|
+
else if (typeParamVariance === 4 /* Variance.Contravariant */) {
|
2385
|
+
effectiveVariance = 3 /* Variance.Covariant */;
|
2382
2386
|
}
|
2383
2387
|
}
|
2384
2388
|
return isVarianceOfTypeArgumentCompatible(typeArgType !== null && typeArgType !== void 0 ? typeArgType : types_1.UnknownType.create(), effectiveVariance);
|
@@ -2526,27 +2530,27 @@ function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
|
|
2526
2530
|
}
|
2527
2531
|
};
|
2528
2532
|
switch (type.category) {
|
2529
|
-
case 6 /* Class */: {
|
2533
|
+
case 6 /* TypeCategory.Class */: {
|
2530
2534
|
addIfUnique(type.details.moduleName);
|
2531
2535
|
break;
|
2532
2536
|
}
|
2533
|
-
case 4 /* Function */: {
|
2537
|
+
case 4 /* TypeCategory.Function */: {
|
2534
2538
|
addIfUnique(type.details.moduleName);
|
2535
2539
|
break;
|
2536
2540
|
}
|
2537
|
-
case 5 /* OverloadedFunction */: {
|
2541
|
+
case 5 /* TypeCategory.OverloadedFunction */: {
|
2538
2542
|
type.overloads.forEach((overload) => {
|
2539
2543
|
addDeclaringModuleNamesForType(overload, moduleList, recursionCount);
|
2540
2544
|
});
|
2541
2545
|
break;
|
2542
2546
|
}
|
2543
|
-
case 8 /* Union */: {
|
2547
|
+
case 8 /* TypeCategory.Union */: {
|
2544
2548
|
doForEachSubtype(type, (subtype) => {
|
2545
2549
|
addDeclaringModuleNamesForType(subtype, moduleList, recursionCount);
|
2546
2550
|
});
|
2547
2551
|
break;
|
2548
2552
|
}
|
2549
|
-
case 7 /* Module */: {
|
2553
|
+
case 7 /* TypeCategory.Module */: {
|
2550
2554
|
addIfUnique(type.moduleName);
|
2551
2555
|
break;
|
2552
2556
|
}
|
@@ -2554,13 +2558,13 @@ function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
|
|
2554
2558
|
}
|
2555
2559
|
function convertTypeToParamSpecValue(type) {
|
2556
2560
|
if ((0, types_1.isParamSpec)(type)) {
|
2557
|
-
const newFunction = types_1.FunctionType.createInstance('', '', '', 65536 /* ParamSpecValue */);
|
2561
|
+
const newFunction = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */);
|
2558
2562
|
newFunction.details.paramSpec = type;
|
2559
2563
|
newFunction.details.typeVarScopeId = getTypeVarScopeId(type);
|
2560
2564
|
return newFunction;
|
2561
2565
|
}
|
2562
2566
|
if ((0, types_1.isFunction)(type)) {
|
2563
|
-
const newFunction = types_1.FunctionType.createInstance('', '', '', type.details.flags | 65536 /* ParamSpecValue */, type.details.docString);
|
2567
|
+
const newFunction = types_1.FunctionType.createInstance('', '', '', type.details.flags | 65536 /* FunctionTypeFlags.ParamSpecValue */, type.details.docString);
|
2564
2568
|
type.details.parameters.forEach((param, index) => {
|
2565
2569
|
types_1.FunctionType.addParameter(newFunction, {
|
2566
2570
|
category: param.category,
|
@@ -2590,7 +2594,7 @@ function convertParamSpecValueToType(paramSpecValue, omitParamSpec = false) {
|
|
2590
2594
|
}
|
2591
2595
|
if (hasParameters || !paramSpecValue.details.paramSpec || omitParamSpec) {
|
2592
2596
|
// Create a function type from the param spec entries.
|
2593
|
-
const functionType = types_1.FunctionType.createInstance('', '', '', 65536 /* ParamSpecValue */ | paramSpecValue.details.flags);
|
2597
|
+
const functionType = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | paramSpecValue.details.flags);
|
2594
2598
|
functionType.details.paramSpecTypeVarScopeId = paramSpecValue.details.typeVarScopeId;
|
2595
2599
|
paramSpecValue.details.parameters.forEach((entry) => {
|
2596
2600
|
types_1.FunctionType.addParameter(functionType, {
|
@@ -2627,6 +2631,11 @@ class TypeVarTransformer {
|
|
2627
2631
|
}
|
2628
2632
|
recursionCount++;
|
2629
2633
|
type = this.transformGenericTypeAlias(type, recursionCount);
|
2634
|
+
// If the type is conditioned on a type variable, see if the condition
|
2635
|
+
// still applies.
|
2636
|
+
if (type.condition) {
|
2637
|
+
type = this.transformConditionalType(type, recursionCount);
|
2638
|
+
}
|
2630
2639
|
// Shortcut the operation if possible.
|
2631
2640
|
if (!requiresSpecialization(type)) {
|
2632
2641
|
return type;
|
@@ -2796,6 +2805,10 @@ class TypeVarTransformer {
|
|
2796
2805
|
? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, newTypeArgs)
|
2797
2806
|
: type;
|
2798
2807
|
}
|
2808
|
+
transformConditionalType(type, recursionCount) {
|
2809
|
+
// By default, do not perform any transform.
|
2810
|
+
return type;
|
2811
|
+
}
|
2799
2812
|
transformTypeVarsInClassType(classType, recursionCount) {
|
2800
2813
|
const typeParams = types_1.ClassType.getTypeParameters(classType);
|
2801
2814
|
// Handle the common case where the class has no type parameters.
|
@@ -2947,8 +2960,8 @@ class TypeVarTransformer {
|
|
2947
2960
|
const kwargsParam = functionType.details.parameters[functionType.details.parameters.length - 1];
|
2948
2961
|
const argsParamType = types_1.FunctionType.getEffectiveParameterType(functionType, functionType.details.parameters.length - 2);
|
2949
2962
|
const kwargsParamType = types_1.FunctionType.getEffectiveParameterType(functionType, functionType.details.parameters.length - 1);
|
2950
|
-
if (argsParam.category === 1 /* ArgsList */ &&
|
2951
|
-
kwargsParam.category === 2 /* KwargsDict */ &&
|
2963
|
+
if (argsParam.category === 1 /* ParameterCategory.ArgsList */ &&
|
2964
|
+
kwargsParam.category === 2 /* ParameterCategory.KwargsDict */ &&
|
2952
2965
|
(0, types_1.isParamSpec)(argsParamType) &&
|
2953
2966
|
(0, types_1.isParamSpec)(kwargsParamType) &&
|
2954
2967
|
(0, types_1.isTypeSame)(argsParamType, kwargsParamType)) {
|
@@ -2983,7 +2996,7 @@ class TypeVarTransformer {
|
|
2983
2996
|
specializedDefaultArgs.push(defaultArgType);
|
2984
2997
|
if (variadicParamIndex === undefined &&
|
2985
2998
|
(0, types_1.isVariadicTypeVar)(paramType) &&
|
2986
|
-
functionType.details.parameters[i].category === 1 /* ArgsList */) {
|
2999
|
+
functionType.details.parameters[i].category === 1 /* ParameterCategory.ArgsList */) {
|
2987
3000
|
variadicParamIndex = i;
|
2988
3001
|
if ((0, types_1.isClassInstance)(specializedType) &&
|
2989
3002
|
isTupleClass(specializedType) &&
|
@@ -3015,7 +3028,7 @@ class TypeVarTransformer {
|
|
3015
3028
|
}
|
3016
3029
|
// Unpack the tuple and synthesize a new function in the process.
|
3017
3030
|
const newFunctionType = types_1.TypeBase.isInstantiable(functionType)
|
3018
|
-
? types_1.FunctionType.createInstantiable(functionType.details.flags | 64 /* SynthesizedMethod */)
|
3031
|
+
? types_1.FunctionType.createInstantiable(functionType.details.flags | 64 /* FunctionTypeFlags.SynthesizedMethod */)
|
3019
3032
|
: types_1.FunctionType.createSynthesizedInstance('', functionType.details.flags);
|
3020
3033
|
let insertKeywordOnlySeparator = false;
|
3021
3034
|
let swallowPositionOnlySeparator = false;
|
@@ -3026,8 +3039,8 @@ class TypeVarTransformer {
|
|
3026
3039
|
variadicTypesToUnpack.forEach((unpackedType) => {
|
3027
3040
|
types_1.FunctionType.addParameter(newFunctionType, {
|
3028
3041
|
category: unpackedType.isUnbounded || (0, types_1.isVariadicTypeVar)(unpackedType.type)
|
3029
|
-
? 1 /* ArgsList */
|
3030
|
-
: 0 /* Simple */,
|
3042
|
+
? 1 /* ParameterCategory.ArgsList */
|
3043
|
+
: 0 /* ParameterCategory.Simple */,
|
3031
3044
|
name: `__p${newFunctionType.details.parameters.length}`,
|
3032
3045
|
isNameSynthesized: true,
|
3033
3046
|
type: unpackedType.type,
|
@@ -3049,14 +3062,14 @@ class TypeVarTransformer {
|
|
3049
3062
|
if ((0, types_1.isKeywordOnlySeparator)(param)) {
|
3050
3063
|
insertKeywordOnlySeparator = false;
|
3051
3064
|
}
|
3052
|
-
else if (param.category === 2 /* KwargsDict */) {
|
3065
|
+
else if (param.category === 2 /* ParameterCategory.KwargsDict */) {
|
3053
3066
|
insertKeywordOnlySeparator = false;
|
3054
3067
|
}
|
3055
3068
|
// Insert a keyword-only separator parameter if we previously
|
3056
3069
|
// unpacked a variadic TypeVar.
|
3057
|
-
if (param.category === 0 /* Simple */ && param.name && insertKeywordOnlySeparator) {
|
3070
|
+
if (param.category === 0 /* ParameterCategory.Simple */ && param.name && insertKeywordOnlySeparator) {
|
3058
3071
|
types_1.FunctionType.addParameter(newFunctionType, {
|
3059
|
-
category: 1 /* ArgsList */,
|
3072
|
+
category: 1 /* ParameterCategory.ArgsList */,
|
3060
3073
|
type: types_1.UnknownType.create(),
|
3061
3074
|
});
|
3062
3075
|
insertKeywordOnlySeparator = false;
|
@@ -3065,7 +3078,7 @@ class TypeVarTransformer {
|
|
3065
3078
|
if (param.name && param.isNameSynthesized) {
|
3066
3079
|
param.name = `__p${newFunctionType.details.parameters.length}`;
|
3067
3080
|
}
|
3068
|
-
if (param.category !== 0 /* Simple */ || param.name || !swallowPositionOnlySeparator) {
|
3081
|
+
if (param.category !== 0 /* ParameterCategory.Simple */ || param.name || !swallowPositionOnlySeparator) {
|
3069
3082
|
types_1.FunctionType.addParameter(newFunctionType, param);
|
3070
3083
|
}
|
3071
3084
|
}
|
@@ -3147,7 +3160,7 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
|
|
3147
3160
|
// Create new type variables with the same scope but with
|
3148
3161
|
// different (unique) names.
|
3149
3162
|
sourceType.details.typeParameters.forEach((typeParam) => {
|
3150
|
-
if (typeParam.scopeType === 1 /* Function */) {
|
3163
|
+
if (typeParam.scopeType === 1 /* TypeVarScopeType.Function */) {
|
3151
3164
|
let replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.details.name}(${offsetIndex})`);
|
3152
3165
|
if (replacement.details.isParamSpec) {
|
3153
3166
|
replacement = convertTypeToParamSpecValue(replacement);
|
@@ -3346,6 +3359,33 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3346
3359
|
}
|
3347
3360
|
return undefined;
|
3348
3361
|
}
|
3362
|
+
transformConditionalType(type, recursionCount) {
|
3363
|
+
var _a;
|
3364
|
+
if (!type.condition) {
|
3365
|
+
return type;
|
3366
|
+
}
|
3367
|
+
const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
|
3368
|
+
for (const condition of type.condition) {
|
3369
|
+
// This doesn't apply to bound type variables.
|
3370
|
+
if (!condition.isConstrainedTypeVar) {
|
3371
|
+
continue;
|
3372
|
+
}
|
3373
|
+
const typeVarEntry = signatureContext.getTypeVarByName(condition.typeVarName);
|
3374
|
+
if (!typeVarEntry || condition.constraintIndex >= typeVarEntry.typeVar.details.constraints.length) {
|
3375
|
+
continue;
|
3376
|
+
}
|
3377
|
+
const value = signatureContext.getTypeVarType(typeVarEntry.typeVar);
|
3378
|
+
if (!value) {
|
3379
|
+
continue;
|
3380
|
+
}
|
3381
|
+
const constraintType = typeVarEntry.typeVar.details.constraints[condition.constraintIndex];
|
3382
|
+
// If this violates the constraint, substitute a Never type.
|
3383
|
+
if (!(0, types_1.isTypeSame)(constraintType, value)) {
|
3384
|
+
return types_1.NeverType.createNever();
|
3385
|
+
}
|
3386
|
+
}
|
3387
|
+
return type;
|
3388
|
+
}
|
3349
3389
|
doForEachSignatureContext(callback) {
|
3350
3390
|
const signatureContexts = this._typeVarContext.getSignatureContexts();
|
3351
3391
|
// Handle the common case where there are not multiple signature contexts.
|
@@ -3362,7 +3402,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
3362
3402
|
const filteredOverloads = [];
|
3363
3403
|
doForEachSubtype((0, types_1.combineTypes)(overloadTypes), (subtype) => {
|
3364
3404
|
(0, debug_1.assert)((0, types_1.isFunction)(subtype));
|
3365
|
-
subtype = types_1.FunctionType.cloneWithNewFlags(subtype, subtype.details.flags | 256 /* Overloaded */);
|
3405
|
+
subtype = types_1.FunctionType.cloneWithNewFlags(subtype, subtype.details.flags | 256 /* FunctionTypeFlags.Overloaded */);
|
3366
3406
|
filteredOverloads.push(subtype);
|
3367
3407
|
});
|
3368
3408
|
if (filteredOverloads.length === 1) {
|