@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.
Files changed (748) hide show
  1. package/dist/analyzer/analysis.js +2 -2
  2. package/dist/analyzer/analysis.js.map +1 -1
  3. package/dist/analyzer/analyzerFileInfo.js +1 -2
  4. package/dist/analyzer/analyzerFileInfo.js.map +1 -1
  5. package/dist/analyzer/analyzerNodeInfo.js +20 -21
  6. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  7. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  8. package/dist/analyzer/binder.js +8 -5
  9. package/dist/analyzer/binder.js.map +1 -1
  10. package/dist/analyzer/cacheManager.d.ts +0 -1
  11. package/dist/analyzer/cacheManager.js.map +1 -1
  12. package/dist/analyzer/checker.d.ts +4 -1
  13. package/dist/analyzer/checker.js +371 -254
  14. package/dist/analyzer/checker.js.map +1 -1
  15. package/dist/analyzer/circularDependency.js.map +1 -1
  16. package/dist/analyzer/codeFlowEngine.js +10 -10
  17. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  18. package/dist/analyzer/codeFlowTypes.d.ts +17 -17
  19. package/dist/analyzer/codeFlowTypes.js +5 -5
  20. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  21. package/dist/analyzer/codeFlowUtils.js +1 -2
  22. package/dist/analyzer/codeFlowUtils.js.map +1 -1
  23. package/dist/analyzer/commentUtils.js +1 -2
  24. package/dist/analyzer/commentUtils.js.map +1 -1
  25. package/dist/analyzer/constraintSolution.d.ts +22 -0
  26. package/dist/analyzer/constraintSolution.js +77 -0
  27. package/dist/analyzer/constraintSolution.js.map +1 -0
  28. package/dist/analyzer/constraintSolver.d.ts +8 -5
  29. package/dist/analyzer/constraintSolver.js +427 -353
  30. package/dist/analyzer/constraintSolver.js.map +1 -1
  31. package/dist/analyzer/constraintTracker.d.ts +45 -0
  32. package/dist/analyzer/constraintTracker.js +235 -0
  33. package/dist/analyzer/constraintTracker.js.map +1 -0
  34. package/dist/analyzer/constructorTransform.js +23 -23
  35. package/dist/analyzer/constructorTransform.js.map +1 -1
  36. package/dist/analyzer/constructors.d.ts +1 -1
  37. package/dist/analyzer/constructors.js +71 -51
  38. package/dist/analyzer/constructors.js.map +1 -1
  39. package/dist/analyzer/dataClasses.js +72 -58
  40. package/dist/analyzer/dataClasses.js.map +1 -1
  41. package/dist/analyzer/declaration.js +11 -11
  42. package/dist/analyzer/declaration.js.map +1 -1
  43. package/dist/analyzer/declarationUtils.js +8 -9
  44. package/dist/analyzer/declarationUtils.js.map +1 -1
  45. package/dist/analyzer/decorators.d.ts +1 -1
  46. package/dist/analyzer/decorators.js +34 -30
  47. package/dist/analyzer/decorators.js.map +1 -1
  48. package/dist/analyzer/docStringConversion.js +2 -3
  49. package/dist/analyzer/docStringConversion.js.map +1 -1
  50. package/dist/analyzer/docStringUtils.js +2 -3
  51. package/dist/analyzer/docStringUtils.js.map +1 -1
  52. package/dist/analyzer/enums.js +17 -14
  53. package/dist/analyzer/enums.js.map +1 -1
  54. package/dist/analyzer/functionTransform.d.ts +2 -2
  55. package/dist/analyzer/functionTransform.js +2 -3
  56. package/dist/analyzer/functionTransform.js.map +1 -1
  57. package/dist/analyzer/importResolver.d.ts +0 -1
  58. package/dist/analyzer/importResolver.js +5 -5
  59. package/dist/analyzer/importResolver.js.map +1 -1
  60. package/dist/analyzer/importStatementUtils.js +15 -15
  61. package/dist/analyzer/importStatementUtils.js.map +1 -1
  62. package/dist/analyzer/namedTuples.js +2 -3
  63. package/dist/analyzer/namedTuples.js.map +1 -1
  64. package/dist/analyzer/operations.d.ts +1 -2
  65. package/dist/analyzer/operations.js +101 -79
  66. package/dist/analyzer/operations.js.map +1 -1
  67. package/dist/analyzer/packageTypeReport.d.ts +3 -3
  68. package/dist/analyzer/packageTypeReport.js +2 -2
  69. package/dist/analyzer/packageTypeReport.js.map +1 -1
  70. package/dist/analyzer/packageTypeVerifier.js +17 -13
  71. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  72. package/dist/analyzer/parameterUtils.d.ts +3 -3
  73. package/dist/analyzer/parameterUtils.js +23 -25
  74. package/dist/analyzer/parameterUtils.js.map +1 -1
  75. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  76. package/dist/analyzer/parseTreeUtils.js +94 -92
  77. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  78. package/dist/analyzer/parseTreeWalker.js +2 -2
  79. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  80. package/dist/analyzer/patternMatching.js +39 -41
  81. package/dist/analyzer/patternMatching.js.map +1 -1
  82. package/dist/analyzer/program.js +5 -1
  83. package/dist/analyzer/program.js.map +1 -1
  84. package/dist/analyzer/properties.d.ts +3 -2
  85. package/dist/analyzer/properties.js +16 -18
  86. package/dist/analyzer/properties.js.map +1 -1
  87. package/dist/analyzer/protocols.d.ts +3 -3
  88. package/dist/analyzer/protocols.js +58 -60
  89. package/dist/analyzer/protocols.js.map +1 -1
  90. package/dist/analyzer/pyTypedUtils.js +2 -3
  91. package/dist/analyzer/pyTypedUtils.js.map +1 -1
  92. package/dist/analyzer/pythonPathUtils.js +6 -6
  93. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  94. package/dist/analyzer/scope.js.map +1 -1
  95. package/dist/analyzer/scopeUtils.js +5 -6
  96. package/dist/analyzer/scopeUtils.js.map +1 -1
  97. package/dist/analyzer/service.d.ts +3 -0
  98. package/dist/analyzer/service.js +173 -103
  99. package/dist/analyzer/service.js.map +1 -1
  100. package/dist/analyzer/serviceUtils.js +5 -5
  101. package/dist/analyzer/serviceUtils.js.map +1 -1
  102. package/dist/analyzer/sourceFile.js.map +1 -1
  103. package/dist/analyzer/sourceFileInfo.js.map +1 -1
  104. package/dist/analyzer/sourceFileInfoUtils.js +4 -5
  105. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  106. package/dist/analyzer/sourceMapper.js +5 -4
  107. package/dist/analyzer/sourceMapper.js.map +1 -1
  108. package/dist/analyzer/sourceMapperUtils.js +1 -2
  109. package/dist/analyzer/sourceMapperUtils.js.map +1 -1
  110. package/dist/analyzer/staticExpressions.js +2 -3
  111. package/dist/analyzer/staticExpressions.js.map +1 -1
  112. package/dist/analyzer/symbol.js.map +1 -1
  113. package/dist/analyzer/symbolNameUtils.js +8 -9
  114. package/dist/analyzer/symbolNameUtils.js.map +1 -1
  115. package/dist/analyzer/symbolUtils.js +4 -5
  116. package/dist/analyzer/symbolUtils.js.map +1 -1
  117. package/dist/analyzer/testWalker.js.map +1 -1
  118. package/dist/analyzer/tracePrinter.js +5 -4
  119. package/dist/analyzer/tracePrinter.js.map +1 -1
  120. package/dist/analyzer/tuples.d.ts +2 -2
  121. package/dist/analyzer/tuples.js +14 -14
  122. package/dist/analyzer/tuples.js.map +1 -1
  123. package/dist/analyzer/typeCacheUtils.js.map +1 -1
  124. package/dist/analyzer/typeComplexity.js +14 -7
  125. package/dist/analyzer/typeComplexity.js.map +1 -1
  126. package/dist/analyzer/typeDocStringUtils.d.ts +2 -2
  127. package/dist/analyzer/typeDocStringUtils.js +34 -25
  128. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  129. package/dist/analyzer/typeEvaluator.js +1021 -993
  130. package/dist/analyzer/typeEvaluator.js.map +1 -1
  131. package/dist/analyzer/typeEvaluatorTypes.d.ts +31 -13
  132. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  133. package/dist/analyzer/typeEvaluatorWithTracker.js +1 -2
  134. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  135. package/dist/analyzer/typeGuards.js +72 -64
  136. package/dist/analyzer/typeGuards.js.map +1 -1
  137. package/dist/analyzer/typePrinter.js +28 -26
  138. package/dist/analyzer/typePrinter.js.map +1 -1
  139. package/dist/analyzer/typeStubWriter.js.map +1 -1
  140. package/dist/analyzer/typeUtils.d.ts +36 -38
  141. package/dist/analyzer/typeUtils.js +465 -746
  142. package/dist/analyzer/typeUtils.js.map +1 -1
  143. package/dist/analyzer/typeWalker.d.ts +2 -2
  144. package/dist/analyzer/typeWalker.js +10 -5
  145. package/dist/analyzer/typeWalker.js.map +1 -1
  146. package/dist/analyzer/typedDicts.d.ts +2 -2
  147. package/dist/analyzer/typedDicts.js +52 -52
  148. package/dist/analyzer/typedDicts.js.map +1 -1
  149. package/dist/analyzer/types.d.ts +41 -36
  150. package/dist/analyzer/types.js +178 -184
  151. package/dist/analyzer/types.js.map +1 -1
  152. package/dist/backgroundAnalysisBase.d.ts +0 -1
  153. package/dist/backgroundAnalysisBase.js.map +1 -1
  154. package/dist/backgroundThreadBase.d.ts +0 -1
  155. package/dist/backgroundThreadBase.js +7 -7
  156. package/dist/backgroundThreadBase.js.map +1 -1
  157. package/dist/commands/commandController.js.map +1 -1
  158. package/dist/commands/createTypeStub.js.map +1 -1
  159. package/dist/commands/dumpFileDebugInfoCommand.js +2 -2
  160. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  161. package/dist/commands/quickActionCommand.js.map +1 -1
  162. package/dist/common/cancellationUtils.js +9 -9
  163. package/dist/common/cancellationUtils.js.map +1 -1
  164. package/dist/common/chokidarFileWatcherProvider.js +3 -3
  165. package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
  166. package/dist/common/collectionUtils.js +23 -23
  167. package/dist/common/collectionUtils.js.map +1 -1
  168. package/dist/common/commandLineOptions.d.ts +19 -12
  169. package/dist/common/commandLineOptions.js +26 -9
  170. package/dist/common/commandLineOptions.js.map +1 -1
  171. package/dist/common/commandUtils.js +1 -2
  172. package/dist/common/commandUtils.js.map +1 -1
  173. package/dist/common/configOptions.d.ts +2 -2
  174. package/dist/common/configOptions.js +30 -40
  175. package/dist/common/configOptions.js.map +1 -1
  176. package/dist/common/console.js +4 -4
  177. package/dist/common/console.js.map +1 -1
  178. package/dist/common/core.js +21 -21
  179. package/dist/common/core.js.map +1 -1
  180. package/dist/common/crypto.js +1 -2
  181. package/dist/common/crypto.js.map +1 -1
  182. package/dist/common/debug.js +9 -10
  183. package/dist/common/debug.js.map +1 -1
  184. package/dist/common/deferred.js +3 -4
  185. package/dist/common/deferred.js.map +1 -1
  186. package/dist/common/diagnostic.js +3 -3
  187. package/dist/common/diagnostic.js.map +1 -1
  188. package/dist/common/diagnosticSink.js.map +1 -1
  189. package/dist/common/envVarUtils.js +2 -3
  190. package/dist/common/envVarUtils.js.map +1 -1
  191. package/dist/common/fileBasedCancellationUtils.js +4 -4
  192. package/dist/common/fileBasedCancellationUtils.js.map +1 -1
  193. package/dist/common/fileSystem.d.ts +0 -2
  194. package/dist/common/fileWatcher.js +2 -2
  195. package/dist/common/fileWatcher.js.map +1 -1
  196. package/dist/common/fullAccessHost.js.map +1 -1
  197. package/dist/common/logTracker.js +2 -2
  198. package/dist/common/logTracker.js.map +1 -1
  199. package/dist/common/lspUtils.d.ts +1 -1
  200. package/dist/common/lspUtils.js +3 -4
  201. package/dist/common/lspUtils.js.map +1 -1
  202. package/dist/common/memUtils.js +2 -2
  203. package/dist/common/memUtils.js.map +1 -1
  204. package/dist/common/pathUtils.js +32 -32
  205. package/dist/common/pathUtils.js.map +1 -1
  206. package/dist/common/positionUtils.js +7 -8
  207. package/dist/common/positionUtils.js.map +1 -1
  208. package/dist/common/progressReporter.js.map +1 -1
  209. package/dist/common/pythonVersion.js.map +1 -1
  210. package/dist/common/realFileSystem.d.ts +0 -2
  211. package/dist/common/realFileSystem.js +2 -2
  212. package/dist/common/realFileSystem.js.map +1 -1
  213. package/dist/common/serviceProvider.js.map +1 -1
  214. package/dist/common/serviceProviderExtensions.js +1 -2
  215. package/dist/common/serviceProviderExtensions.js.map +1 -1
  216. package/dist/common/stringUtils.js +12 -13
  217. package/dist/common/stringUtils.js.map +1 -1
  218. package/dist/common/textEditTracker.js.map +1 -1
  219. package/dist/common/textRange.js +13 -13
  220. package/dist/common/textRange.js.map +1 -1
  221. package/dist/common/textRangeCollection.js +2 -2
  222. package/dist/common/textRangeCollection.js.map +1 -1
  223. package/dist/common/timing.js.map +1 -1
  224. package/dist/common/uri/baseUri.js.map +1 -1
  225. package/dist/common/uri/fileUri.js.map +1 -1
  226. package/dist/common/uri/memoization.js +3 -4
  227. package/dist/common/uri/memoization.js.map +1 -1
  228. package/dist/common/uri/uri.js.map +1 -1
  229. package/dist/common/uri/uriUtils.d.ts +0 -1
  230. package/dist/common/uri/uriUtils.js +20 -20
  231. package/dist/common/uri/uriUtils.js.map +1 -1
  232. package/dist/common/uri/webUri.js.map +1 -1
  233. package/dist/common/workspaceEditUtils.js +8 -9
  234. package/dist/common/workspaceEditUtils.js.map +1 -1
  235. package/dist/languageServerBase.d.ts +2 -2
  236. package/dist/languageServerBase.js +5 -2
  237. package/dist/languageServerBase.js.map +1 -1
  238. package/dist/languageService/analyzerServiceExecutor.js +30 -29
  239. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  240. package/dist/languageService/autoImporter.js +4 -4
  241. package/dist/languageService/autoImporter.js.map +1 -1
  242. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  243. package/dist/languageService/codeActionProvider.js.map +1 -1
  244. package/dist/languageService/completionProvider.js +4 -4
  245. package/dist/languageService/completionProvider.js.map +1 -1
  246. package/dist/languageService/completionProviderUtils.js +4 -5
  247. package/dist/languageService/completionProviderUtils.js.map +1 -1
  248. package/dist/languageService/definitionProvider.js +5 -5
  249. package/dist/languageService/definitionProvider.js.map +1 -1
  250. package/dist/languageService/documentHighlightProvider.js.map +1 -1
  251. package/dist/languageService/documentSymbolCollector.js +3 -3
  252. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  253. package/dist/languageService/documentSymbolProvider.js +2 -2
  254. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  255. package/dist/languageService/dynamicFeature.js.map +1 -1
  256. package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
  257. package/dist/languageService/hoverProvider.js +6 -6
  258. package/dist/languageService/hoverProvider.js.map +1 -1
  259. package/dist/languageService/importSorter.js.map +1 -1
  260. package/dist/languageService/navigationUtils.js +3 -4
  261. package/dist/languageService/navigationUtils.js.map +1 -1
  262. package/dist/languageService/quickActions.js +1 -2
  263. package/dist/languageService/quickActions.js.map +1 -1
  264. package/dist/languageService/referencesProvider.js.map +1 -1
  265. package/dist/languageService/renameProvider.js.map +1 -1
  266. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  267. package/dist/languageService/symbolIndexer.js.map +1 -1
  268. package/dist/languageService/tooltipUtils.d.ts +5 -5
  269. package/dist/languageService/tooltipUtils.js +31 -31
  270. package/dist/languageService/tooltipUtils.js.map +1 -1
  271. package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
  272. package/dist/localization/localize.d.ts +3 -0
  273. package/dist/localization/localize.js +7 -6
  274. package/dist/localization/localize.js.map +1 -1
  275. package/dist/localization/package.nls.en-us.json +2 -1
  276. package/dist/nodeMain.js +1 -2
  277. package/dist/nodeMain.js.map +1 -1
  278. package/dist/nodeServer.js +2 -3
  279. package/dist/nodeServer.js.map +1 -1
  280. package/dist/parser/characterStream.js.map +1 -1
  281. package/dist/parser/characters.js +10 -11
  282. package/dist/parser/characters.js.map +1 -1
  283. package/dist/parser/parseNodes.d.ts +8 -8
  284. package/dist/parser/parseNodes.js +5 -5
  285. package/dist/parser/parseNodes.js.map +1 -1
  286. package/dist/parser/parser.js.map +1 -1
  287. package/dist/parser/stringTokenUtils.js +2 -2
  288. package/dist/parser/stringTokenUtils.js.map +1 -1
  289. package/dist/parser/tokenizer.js.map +1 -1
  290. package/dist/parser/unicode.js +468 -468
  291. package/dist/parser/unicode.js.map +1 -1
  292. package/dist/pprof/profiler.js +2 -3
  293. package/dist/pprof/profiler.js.map +1 -1
  294. package/dist/pyright.js +22 -23
  295. package/dist/pyright.js.map +1 -1
  296. package/dist/pyrightFileSystem.d.ts +0 -2
  297. package/dist/pyrightFileSystem.js.map +1 -1
  298. package/dist/readonlyAugmentedFileSystem.d.ts +0 -2
  299. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  300. package/dist/server.js.map +1 -1
  301. package/dist/tests/cacheManager.test.js.map +1 -1
  302. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  303. package/dist/tests/checker.test.js +13 -5
  304. package/dist/tests/checker.test.js.map +1 -1
  305. package/dist/tests/classDeclaration.test.js.map +1 -1
  306. package/dist/tests/config.test.js +160 -24
  307. package/dist/tests/config.test.js.map +1 -1
  308. package/dist/tests/debug.test.js.map +1 -1
  309. package/dist/tests/diagnosticOverrides.test.js.map +1 -1
  310. package/dist/tests/docStringConversion.test.js +1 -2
  311. package/dist/tests/docStringConversion.test.js.map +1 -1
  312. package/dist/tests/documentSymbolCollector.test.js.map +1 -1
  313. package/dist/tests/filesystem.test.js.map +1 -1
  314. package/dist/tests/fourSlashParser.test.js.map +1 -1
  315. package/dist/tests/fourSlashRunner.test.js.map +1 -1
  316. package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.d.ts +0 -1
  317. package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -1
  318. package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.d.ts +0 -1
  319. package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -1
  320. package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.d.ts +0 -1
  321. package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.d.ts +0 -1
  322. package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.d.ts +0 -1
  323. package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -1
  324. package/dist/tests/fourslash/completions.autoimport.fourslash.d.ts +0 -1
  325. package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -1
  326. package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.d.ts +0 -1
  327. package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -1
  328. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.d.ts +0 -1
  329. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -1
  330. package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.d.ts +0 -1
  331. package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -1
  332. package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.d.ts +0 -1
  333. package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
  334. package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.d.ts +0 -1
  335. package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -1
  336. package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.d.ts +0 -1
  337. package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -1
  338. package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.d.ts +0 -1
  339. package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
  340. package/dist/tests/fourslash/completions.builtinOverride.fourslash.d.ts +0 -1
  341. package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.d.ts +0 -1
  342. package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -1
  343. package/dist/tests/fourslash/completions.call.typedDict.fourslash.d.ts +0 -1
  344. package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
  345. package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.d.ts +0 -1
  346. package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
  347. package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.d.ts +0 -1
  348. package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
  349. package/dist/tests/fourslash/completions.classVariable.fourslash.d.ts +0 -1
  350. package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
  351. package/dist/tests/fourslash/completions.comment.fourslash.d.ts +0 -1
  352. package/dist/tests/fourslash/completions.declNames.class.fourslash.d.ts +0 -1
  353. package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -1
  354. package/dist/tests/fourslash/completions.declNames.exception.fourslash.d.ts +0 -1
  355. package/dist/tests/fourslash/completions.declNames.for.fourslash.d.ts +0 -1
  356. package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -1
  357. package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.d.ts +0 -1
  358. package/dist/tests/fourslash/completions.declNames.lambda.fourslash.d.ts +0 -1
  359. package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -1
  360. package/dist/tests/fourslash/completions.declNames.method.fourslash.d.ts +0 -1
  361. package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -1
  362. package/dist/tests/fourslash/completions.declNames.overload.fourslash.d.ts +0 -1
  363. package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -1
  364. package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.d.ts +0 -1
  365. package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -1
  366. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.d.ts +0 -1
  367. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
  368. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.d.ts +0 -1
  369. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
  370. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.d.ts +0 -1
  371. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
  372. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.d.ts +0 -1
  373. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
  374. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.d.ts +0 -1
  375. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
  376. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.d.ts +0 -1
  377. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
  378. package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.d.ts +0 -1
  379. package/dist/tests/fourslash/completions.dunderNew.fourslash.d.ts +0 -1
  380. package/dist/tests/fourslash/completions.enums.members.fourslash.d.ts +0 -1
  381. package/dist/tests/fourslash/completions.errorNodes.fourslash.d.ts +0 -1
  382. package/dist/tests/fourslash/completions.excluded.fourslash.d.ts +0 -1
  383. package/dist/tests/fourslash/completions.fourslash.d.ts +0 -1
  384. package/dist/tests/fourslash/completions.fstring.fourslash.d.ts +0 -1
  385. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.d.ts +0 -1
  386. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
  387. package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.d.ts +0 -1
  388. package/dist/tests/fourslash/completions.import.dunderNames.fourslash.d.ts +0 -1
  389. package/dist/tests/fourslash/completions.import.exactMatch.fourslash.d.ts +0 -1
  390. package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.d.ts +0 -1
  391. package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.d.ts +0 -1
  392. package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.js.map +1 -1
  393. package/dist/tests/fourslash/completions.import.submodule.fourslash.d.ts +0 -1
  394. package/dist/tests/fourslash/completions.inList.fourslash.d.ts +0 -1
  395. package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -1
  396. package/dist/tests/fourslash/completions.included.fourslash.d.ts +0 -1
  397. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.d.ts +0 -1
  398. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
  399. package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.d.ts +0 -1
  400. package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.d.ts +0 -1
  401. package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.d.ts +0 -1
  402. package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.d.ts +0 -1
  403. package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.d.ts +0 -1
  404. package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.d.ts +0 -1
  405. package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -1
  406. package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.d.ts +0 -1
  407. package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.d.ts +0 -1
  408. package/dist/tests/fourslash/completions.libStub.fourslash.d.ts +0 -1
  409. package/dist/tests/fourslash/completions.literals.fourslash.d.ts +0 -1
  410. package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -1
  411. package/dist/tests/fourslash/completions.localCode.fourslash.d.ts +0 -1
  412. package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.d.ts +0 -1
  413. package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.d.ts +0 -1
  414. package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.d.ts +0 -1
  415. package/dist/tests/fourslash/completions.overloads.fourslash.d.ts +0 -1
  416. package/dist/tests/fourslash/completions.override.default.fourslash.d.ts +0 -1
  417. package/dist/tests/fourslash/completions.override.default.importStub.d.ts +0 -1
  418. package/dist/tests/fourslash/completions.override.default.imported.fourslash.d.ts +0 -1
  419. package/dist/tests/fourslash/completions.override.default.stub.fourslash.d.ts +0 -1
  420. package/dist/tests/fourslash/completions.override.fourslash.d.ts +0 -1
  421. package/dist/tests/fourslash/completions.override.property.fourslash.d.ts +0 -1
  422. package/dist/tests/fourslash/completions.override.property.stub.fourslash.d.ts +0 -1
  423. package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.d.ts +0 -1
  424. package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -1
  425. package/dist/tests/fourslash/completions.override.stub.fourslash.d.ts +0 -1
  426. package/dist/tests/fourslash/completions.override2.fourslash.d.ts +0 -1
  427. package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
  428. package/dist/tests/fourslash/completions.parameters.fourslash.d.ts +0 -1
  429. package/dist/tests/fourslash/completions.params.fourslash.d.ts +0 -1
  430. package/dist/tests/fourslash/completions.parentFolder.fourslash.d.ts +0 -1
  431. package/dist/tests/fourslash/completions.parentFolders.fourslash.d.ts +0 -1
  432. package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -1
  433. package/dist/tests/fourslash/completions.plainText.fourslash.d.ts +0 -1
  434. package/dist/tests/fourslash/completions.private.fourslash.d.ts +0 -1
  435. package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -1
  436. package/dist/tests/fourslash/completions.property.fourslash.d.ts +0 -1
  437. package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.d.ts +0 -1
  438. package/dist/tests/fourslash/completions.self.fourslash.d.ts +0 -1
  439. package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.d.ts +0 -1
  440. package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -1
  441. package/dist/tests/fourslash/completions.stringLiteral.fourslash.d.ts +0 -1
  442. package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
  443. package/dist/tests/fourslash/completions.triggers.fourslash.d.ts +0 -1
  444. package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -1
  445. package/dist/tests/fourslash/completions.typeAlias.fourslash.d.ts +0 -1
  446. package/dist/tests/fourslash/completions.typeshed.fourslash.d.ts +0 -1
  447. package/dist/tests/fourslash/completions.vardecls.fourslash.d.ts +0 -1
  448. package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -1
  449. package/dist/tests/fourslash/completions.variableDocStrings.fourslash.d.ts +0 -1
  450. package/dist/tests/fourslash/completions.wildcardimports.fourslash.d.ts +0 -1
  451. package/dist/tests/fourslash/completions.with.fourslash.d.ts +0 -1
  452. package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.d.ts +0 -1
  453. package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -1
  454. package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.d.ts +0 -1
  455. package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -1
  456. package/dist/tests/fourslash/findDefinitions.classes.fourslash.d.ts +0 -1
  457. package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -1
  458. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.d.ts +0 -1
  459. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -1
  460. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.d.ts +0 -1
  461. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -1
  462. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.d.ts +0 -1
  463. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -1
  464. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.d.ts +0 -1
  465. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -1
  466. package/dist/tests/fourslash/findDefinitions.fields.fourslash.d.ts +0 -1
  467. package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -1
  468. package/dist/tests/fourslash/findDefinitions.functions.fourslash.d.ts +0 -1
  469. package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -1
  470. package/dist/tests/fourslash/findDefinitions.methods.fourslash.d.ts +0 -1
  471. package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -1
  472. package/dist/tests/fourslash/findDefinitions.modules.fourslash.d.ts +0 -1
  473. package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -1
  474. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.d.ts +0 -1
  475. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
  476. package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.d.ts +0 -1
  477. package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -1
  478. package/dist/tests/fourslash/findDefinitions.overloads.fourslash.d.ts +0 -1
  479. package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -1
  480. package/dist/tests/fourslash/findDefinitions.parameters.fourslash.d.ts +0 -1
  481. package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -1
  482. package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.d.ts +0 -1
  483. package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -1
  484. package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.d.ts +0 -1
  485. package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -1
  486. package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.d.ts +0 -1
  487. package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -1
  488. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.d.ts +0 -1
  489. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -1
  490. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.d.ts +0 -1
  491. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -1
  492. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.d.ts +0 -1
  493. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -1
  494. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.d.ts +0 -1
  495. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -1
  496. package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.d.ts +0 -1
  497. package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -1
  498. package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.d.ts +0 -1
  499. package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -1
  500. package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.d.ts +0 -1
  501. package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -1
  502. package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.d.ts +0 -1
  503. package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -1
  504. package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.d.ts +0 -1
  505. package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -1
  506. package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.d.ts +0 -1
  507. package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -1
  508. package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.d.ts +0 -1
  509. package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -1
  510. package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.d.ts +0 -1
  511. package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -1
  512. package/dist/tests/fourslash/findDefinitions.variables.fourslash.d.ts +0 -1
  513. package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -1
  514. package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.d.ts +0 -1
  515. package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -1
  516. package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.d.ts +0 -1
  517. package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -1
  518. package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.d.ts +0 -1
  519. package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -1
  520. package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.d.ts +0 -1
  521. package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -1
  522. package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.d.ts +0 -1
  523. package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -1
  524. package/dist/tests/fourslash/findallreferences.fourslash.d.ts +0 -1
  525. package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -1
  526. package/dist/tests/fourslash/findallreferences.importalias.fourslash.d.ts +0 -1
  527. package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -1
  528. package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.d.ts +0 -1
  529. package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -1
  530. package/dist/tests/fourslash/findallreferences.module.nested.fourslash.d.ts +0 -1
  531. package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -1
  532. package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.d.ts +0 -1
  533. package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -1
  534. package/dist/tests/fourslash/findallreferences.modules.fourslash.d.ts +0 -1
  535. package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -1
  536. package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.d.ts +0 -1
  537. package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -1
  538. package/dist/tests/fourslash/findallreferences.openFiles.fourslash.d.ts +0 -1
  539. package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -1
  540. package/dist/tests/fourslash/findallreferences.parameter.fourslash.d.ts +0 -1
  541. package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -1
  542. package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.d.ts +0 -1
  543. package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -1
  544. package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.d.ts +0 -1
  545. package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -1
  546. package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.d.ts +0 -1
  547. package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -1
  548. package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.d.ts +0 -1
  549. package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -1
  550. package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.d.ts +0 -1
  551. package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -1
  552. package/dist/tests/fourslash/findallreferences.variable.fourslash.d.ts +0 -1
  553. package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -1
  554. package/dist/tests/fourslash/highlightreferences.attributes.fourslash.d.ts +0 -1
  555. package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -1
  556. package/dist/tests/fourslash/hover.async.fourslash.d.ts +0 -1
  557. package/dist/tests/fourslash/hover.builtinDocstrings.builtinInheritedByBuiltin.fourslash.d.ts +0 -1
  558. package/dist/tests/fourslash/hover.builtinDocstrings.builtinInheritedByUserCode.fourslash.d.ts +0 -1
  559. package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.d.ts +0 -1
  560. package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
  561. package/dist/tests/fourslash/hover.class.docString.fourslash.d.ts +0 -1
  562. package/dist/tests/fourslash/hover.classNoInit.fourslash.d.ts +0 -1
  563. package/dist/tests/fourslash/hover.docFromSrc.fourslash.d.ts +0 -1
  564. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.d.ts +0 -1
  565. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.d.ts +0 -1
  566. package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.d.ts +0 -1
  567. package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.d.ts +0 -1
  568. package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.d.ts +0 -1
  569. package/dist/tests/fourslash/hover.docFromSrc.stringFormat.fourslash.d.ts +0 -1
  570. package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.d.ts +0 -1
  571. package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.d.ts +0 -1
  572. package/dist/tests/fourslash/hover.docstring.alias.fourslash.d.ts +0 -1
  573. package/dist/tests/fourslash/hover.docstring.links.fourslash.d.ts +0 -1
  574. package/dist/tests/fourslash/hover.docstring.overloads.fourslash.d.ts +0 -1
  575. package/dist/tests/fourslash/hover.docstring.parameter.fourslash.d.ts +0 -1
  576. package/dist/tests/fourslash/hover.docstring.split.fourslash.d.ts +0 -1
  577. package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.d.ts +0 -1
  578. package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.d.ts +0 -1
  579. package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.d.ts +0 -1
  580. package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.d.ts +0 -1
  581. package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.d.ts +0 -1
  582. package/dist/tests/fourslash/hover.formatted.fourslash.d.ts +0 -1
  583. package/dist/tests/fourslash/hover.fourslash.d.ts +0 -1
  584. package/dist/tests/fourslash/hover.import.django.view.fourslash.d.ts +0 -1
  585. package/dist/tests/fourslash/hover.import.fourslash.d.ts +0 -1
  586. package/dist/tests/fourslash/hover.inferred.fourslash.d.ts +0 -1
  587. package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.d.ts +0 -1
  588. package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.d.ts +0 -1
  589. package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.d.ts +0 -1
  590. package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.d.ts +0 -1
  591. package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.d.ts +0 -1
  592. package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.d.ts +0 -1
  593. package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.d.ts +0 -1
  594. package/dist/tests/fourslash/hover.init.fourslash.d.ts +0 -1
  595. package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.d.ts +0 -1
  596. package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.d.ts +0 -1
  597. package/dist/tests/fourslash/hover.libStub.fourslash.d.ts +0 -1
  598. package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.d.ts +0 -1
  599. package/dist/tests/fourslash/hover.overloadedFunction.fourslash.d.ts +0 -1
  600. package/dist/tests/fourslash/hover.plainText.fourslash.d.ts +0 -1
  601. package/dist/tests/fourslash/hover.slots.fourslash.d.ts +0 -1
  602. package/dist/tests/fourslash/hover.typedDict.key.fourslash.d.ts +0 -1
  603. package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.d.ts +0 -1
  604. package/dist/tests/fourslash/hover.variable.docString.fourslash.d.ts +0 -1
  605. package/dist/tests/fourslash/hover.wildcardimports.fourslash.d.ts +0 -1
  606. package/dist/tests/fourslash/import.multipart.fourslash.d.ts +0 -1
  607. package/dist/tests/fourslash/import.nameconflict.fourslash.d.ts +0 -1
  608. package/dist/tests/fourslash/import.publicSymbols.fourslash.d.ts +0 -1
  609. package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -1
  610. package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.d.ts +0 -1
  611. package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.d.ts +0 -1
  612. package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.d.ts +0 -1
  613. package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.d.ts +0 -1
  614. package/dist/tests/fourslash/import.wildcard.fourslash.d.ts +0 -1
  615. package/dist/tests/fourslash/importnotresolved.fourslash.d.ts +0 -1
  616. package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.d.ts +0 -1
  617. package/dist/tests/fourslash/missingModuleSource.fourslash.d.ts +0 -1
  618. package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.d.ts +0 -1
  619. package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.d.ts +0 -1
  620. package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.d.ts +0 -1
  621. package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.d.ts +0 -1
  622. package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.d.ts +0 -1
  623. package/dist/tests/fourslash/missingTypeStub.fourslash.d.ts +0 -1
  624. package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.d.ts +0 -1
  625. package/dist/tests/fourslash/noerrors.fourslash.d.ts +0 -1
  626. package/dist/tests/fourslash/orderImports1.command.fourslash.d.ts +0 -1
  627. package/dist/tests/fourslash/orderImports2.command.fourslash.d.ts +0 -1
  628. package/dist/tests/fourslash/rename.args.fourslash.d.ts +0 -1
  629. package/dist/tests/fourslash/rename.args.fourslash.js.map +1 -1
  630. package/dist/tests/fourslash/rename.externallyHidden.fourslash.d.ts +0 -1
  631. package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.d.ts +0 -1
  632. package/dist/tests/fourslash/rename.fourslash.d.ts +0 -1
  633. package/dist/tests/fourslash/rename.fourslash.js.map +1 -1
  634. package/dist/tests/fourslash/rename.function.untitledFile.fourslash.d.ts +0 -1
  635. package/dist/tests/fourslash/rename.function.untitledFile.fourslash.js.map +1 -1
  636. package/dist/tests/fourslash/rename.init.fourslash.d.ts +0 -1
  637. package/dist/tests/fourslash/rename.init.fourslash.js.map +1 -1
  638. package/dist/tests/fourslash/rename.library.fourslash.d.ts +0 -1
  639. package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.d.ts +0 -1
  640. package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +0 -1
  641. package/dist/tests/fourslash/rename.parens.fourslash.d.ts +0 -1
  642. package/dist/tests/fourslash/rename.parens.fourslash.js.map +1 -1
  643. package/dist/tests/fourslash/rename.sourceAndStub.fourslash.d.ts +0 -1
  644. package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -1
  645. package/dist/tests/fourslash/rename.string.excluded.fourslash.d.ts +0 -1
  646. package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -1
  647. package/dist/tests/fourslash/rename.string.fourslash.d.ts +0 -1
  648. package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -1
  649. package/dist/tests/fourslash/shadowedImports.fourslash.d.ts +0 -1
  650. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.d.ts +0 -1
  651. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
  652. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.d.ts +0 -1
  653. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -1
  654. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.d.ts +0 -1
  655. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
  656. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.d.ts +0 -1
  657. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js.map +1 -1
  658. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.d.ts +0 -1
  659. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js.map +1 -1
  660. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.d.ts +0 -1
  661. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js.map +1 -1
  662. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.d.ts +0 -1
  663. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
  664. package/dist/tests/fourslash/signature.complicated.fourslash.d.ts +0 -1
  665. package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
  666. package/dist/tests/fourslash/signature.cornercases.fourslash.d.ts +0 -1
  667. package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -1
  668. package/dist/tests/fourslash/signature.docstrings.fourslash.d.ts +0 -1
  669. package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -1
  670. package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.d.ts +0 -1
  671. package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
  672. package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.d.ts +0 -1
  673. package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -1
  674. package/dist/tests/fourslash/signature.dunderNew.fourslash.d.ts +0 -1
  675. package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -1
  676. package/dist/tests/fourslash/signature.overload.fourslash.d.ts +0 -1
  677. package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -1
  678. package/dist/tests/fourslash/signature.simple.fourslash.d.ts +0 -1
  679. package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -1
  680. package/dist/tests/fourslash/typeVerifier.fourslash.d.ts +0 -1
  681. package/dist/tests/fourslash/typeVerifier.fourslash.js.map +1 -1
  682. package/dist/tests/harness/fourslash/fourSlashParser.js +1 -2
  683. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  684. package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
  685. package/dist/tests/harness/fourslash/runner.d.ts +0 -1
  686. package/dist/tests/harness/fourslash/runner.js +2 -3
  687. package/dist/tests/harness/fourslash/runner.js.map +1 -1
  688. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  689. package/dist/tests/harness/fourslash/testState.js +7 -7
  690. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  691. package/dist/tests/harness/fourslash/testStateUtils.js +4 -5
  692. package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
  693. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +7 -8
  694. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
  695. package/dist/tests/harness/testHost.js.map +1 -1
  696. package/dist/tests/harness/utils.d.ts +0 -2
  697. package/dist/tests/harness/utils.js +7 -7
  698. package/dist/tests/harness/utils.js.map +1 -1
  699. package/dist/tests/harness/vfs/factory.js +3 -3
  700. package/dist/tests/harness/vfs/factory.js.map +1 -1
  701. package/dist/tests/harness/vfs/filesystem.d.ts +0 -2
  702. package/dist/tests/harness/vfs/filesystem.js +2 -2
  703. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  704. package/dist/tests/harness/vfs/pathValidation.js +2 -2
  705. package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
  706. package/dist/tests/importResolver.test.js.map +1 -1
  707. package/dist/tests/importStatementUtils.test.js.map +1 -1
  708. package/dist/tests/ipythonMode.test.js.map +1 -1
  709. package/dist/tests/languageServer.test.js.map +1 -1
  710. package/dist/tests/localizer.test.js.map +1 -1
  711. package/dist/tests/lsp/languageServer.js +1 -2
  712. package/dist/tests/lsp/languageServer.js.map +1 -1
  713. package/dist/tests/lsp/languageServerTestUtils.js +14 -14
  714. package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
  715. package/dist/tests/lsp/webpack.testserver.config.d.ts +2 -2
  716. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  717. package/dist/tests/pathUtils.test.js.map +1 -1
  718. package/dist/tests/pyrightFileSystem.test.js.map +1 -1
  719. package/dist/tests/serialization.test.js +1 -2
  720. package/dist/tests/serialization.test.js.map +1 -1
  721. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  722. package/dist/tests/testStateUtils.js +5 -6
  723. package/dist/tests/testStateUtils.js.map +1 -1
  724. package/dist/tests/testUtils.js +8 -9
  725. package/dist/tests/testUtils.js.map +1 -1
  726. package/dist/tests/textEditUtil.test.js.map +1 -1
  727. package/dist/tests/tokenizer.test.js.map +1 -1
  728. package/dist/tests/typeEvaluator1.test.js +7 -7
  729. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  730. package/dist/tests/typeEvaluator2.test.js +20 -0
  731. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  732. package/dist/tests/typeEvaluator3.test.js +6 -2
  733. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  734. package/dist/tests/typeEvaluator4.test.js +3 -3
  735. package/dist/tests/typeEvaluator5.test.js +1 -1
  736. package/dist/tests/typeEvaluator6.test.js +17 -9
  737. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  738. package/dist/tests/typeEvaluator7.test.js +4 -0
  739. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  740. package/dist/tests/typeEvaluator8.test.js +4 -0
  741. package/dist/tests/typeEvaluator8.test.js.map +1 -1
  742. package/dist/tests/uri.test.js.map +1 -1
  743. package/dist/workspaceFactory.js +3 -3
  744. package/dist/workspaceFactory.js.map +1 -1
  745. package/package.json +2 -2
  746. package/dist/analyzer/typeVarContext.d.ts +0 -48
  747. package/dist/analyzer/typeVarContext.js +0 -288
  748. 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.addConstraintsForExpectedType = exports.updateTypeVarType = exports.assignTypeToTypeVar = void 0;
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 TypeVarContext before and
29
+ // This debugging switch enables logging of the constraints before and
25
30
  // after it is updated by the constraint solver.
26
- const logTypeVarContextUpdates = false;
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 assignTypeToTypeVar(evaluator, destType, srcType, diag, typeVarContext, flags = 0 /* AssignTypeFlags.Default */, recursionCount = 0) {
34
- if (logTypeVarContextUpdates) {
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}assignTypeToTypeVar called with`);
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
- console.log(`${indent}scopes: ${(typeVarContext.getSolveForScopes() || []).join(', ')}`);
42
- logTypeVarContext(evaluator, typeVarContext, indent);
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
- // Verify that we are solving for the scope associated with this
60
- // type variable.
61
- if (!typeVarContext.hasSolveForScope(destType.priv.scopeId)) {
62
- // Handle Any as a source.
63
- if ((0, types_1.isAnyOrUnknown)(srcType) || ((0, types_1.isClass)(srcType) && types_1.ClassType.derivesFromAnyOrUnknown(srcType))) {
64
- return true;
65
- }
66
- // Handle a type[Any] as a source.
67
- if ((0, types_1.isClassInstance)(srcType) && types_1.ClassType.isBuiltIn(srcType, 'type')) {
68
- if (!srcType.priv.typeArgs ||
69
- srcType.priv.typeArgs.length < 1 ||
70
- (0, types_1.isAnyOrUnknown)(srcType.priv.typeArgs[0])) {
71
- if (types_1.TypeBase.isInstantiable(destType)) {
72
- return true;
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
- // Is this the equivalent of an "Unknown" for a ParamSpec?
77
- if ((0, types_1.isParamSpec)(destType) &&
78
- (0, types_1.isFunction)(srcType) &&
79
- types_1.FunctionType.isParamSpecValue(srcType) &&
80
- types_1.FunctionType.isGradualCallableForm(srcType)) {
81
- return true;
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
- // Never or NoReturn is always assignable to all type variables unless
84
- // we're enforcing invariance.
85
- if ((0, types_1.isNever)(srcType) && !isInvariant) {
86
- return true;
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
- // If we're in "ignore type var scope" mode, don't generate
89
- // an error in this path.
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
- isTypeVarInScope = false;
94
- // Emit an error unless this is a synthesized type variable used
95
- // for pseudo-generic classes.
96
- if (!destType.shared.isSynthesized || destType.shared.isSynthesizedSelf) {
97
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(evaluator.printSrcDestTypes(srcType, destType)));
98
- return false;
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
- // An in-scope placeholder TypeVar can always be assigned to itself,
102
- // but we won't record this in the typeVarContext.
103
- if ((0, types_1.isTypeSame)(destType, srcType) && destType.priv.isInScopePlaceholder) {
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 ((flags & 8 /* AssignTypeFlags.SkipSolveTypeVars */) !== 0) {
107
- return evaluator.assignType(evaluator.makeTopLevelTypeVarsConcrete(destType), evaluator.makeTopLevelTypeVarsConcrete(srcType), diag,
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.isParamSpec)(destType)) {
112
- return assignTypeToParamSpec(evaluator, destType, srcType, diag, typeVarContext, recursionCount);
195
+ if (!(0, types_1.isClass)(expectedType)) {
196
+ return false;
113
197
  }
114
- if ((0, types_1.isTypeVarTuple)(destType) && !destType.priv.isVariadicInUnion) {
115
- if (!(0, types_1.isUnpacked)(srcType)) {
116
- const tupleClassType = evaluator.getTupleClassType();
117
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
118
- // Package up the type into a tuple.
119
- srcType = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: srcType, isUnbounded: false }],
120
- /* isTypeArgExplicit */ true,
121
- /* isUnpackedTuple */ true));
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
- else {
124
- srcType = types_1.UnknownType.create();
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
- // If we're assigning an unpacked TypeVarTuple to a regular TypeVar,
129
- // we need to treat it as a union of the unpacked TypeVarTuple.
130
- if ((0, types_1.isTypeVarTuple)(srcType) &&
131
- srcType.priv.isVariadicUnpacked &&
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 the constrained case. This case needs to be handled specially
137
- // because type narrowing isn't used in this case. For example, if the
138
- // source type is "Literal[1]" and the constraint list includes the type
139
- // "float", the resulting type is float.
140
- if (destType.shared.constraints.length > 0) {
141
- return assignTypeToConstrainedTypeVar(evaluator, destType, srcType, diag, typeVarContext, flags, isTypeVarInScope, recursionCount);
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 = typeVarContext.getMainSolutionSet().getTypeVar(destType);
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 && !destType.shared.isSynthesizedSelf) {
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 newUpperTypeBound = curUpperBound;
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.PopulatingExpectedType */) !== 0) {
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
- newUpperTypeBound = adjSrcType;
445
+ newUpperBound = adjSrcType;
194
446
  }
195
447
  else if (isContravariant) {
196
448
  newLowerBound = adjSrcType;
197
449
  }
198
450
  else {
199
- newUpperTypeBound = adjSrcType;
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
- newUpperTypeBound = adjSrcType;
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
- /* destTypeVarContext */ undefined,
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
- newUpperTypeBound = adjSrcType;
464
+ newUpperBound = adjSrcType;
214
465
  }
215
466
  else if (!evaluator.assignType(adjSrcType, curUpperBound, diagAddendum,
216
- /* destTypeVarContext */ undefined,
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(newUpperTypeBound, curLowerBound,
477
+ if (!evaluator.assignType(newUpperBound, curLowerBound,
228
478
  /* diag */ undefined,
229
- /* destTypeVarContext */ undefined,
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, newUpperTypeBound)));
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 (!newUpperTypeBound && isInvariant && (curEntry === null || curEntry === void 0 ? void 0 : curEntry.lowerBoundNoLiterals)) {
249
- newLowerBound = curEntry.lowerBoundNoLiterals;
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, typeVarContext,
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, typeVarContext,
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 = (0, typeUtils_1.applySolvedTypeVars)(curLowerBound, typeVarContext);
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, typeVarContext,
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 (typeVarContext.isLocked()) {
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, typeVarContext,
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 (!newUpperTypeBound && isInvariant && (curEntry === null || curEntry === void 0 ? void 0 : curEntry.lowerBoundNoLiterals)) {
303
- curLowerBound = curEntry.lowerBoundNoLiterals;
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
- destType.shared.boundType !== undefined &&
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
- /* destTypeVarContext */ undefined,
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
- let adjUpperBound = evaluator.makeTopLevelTypeVarsConcrete(curUpperBound,
343
- /* makeParamSpecsConcrete */ true);
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, adjUpperBound)));
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 (!newUpperTypeBound && isInvariant) {
361
- newUpperTypeBound = newLowerBound;
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 || newUpperTypeBound);
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) && !types_1.TypeBase.isInstantiable(srcType)) {
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 TypeVarContext
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 effectiveTypeVarContext = destType.shared.isSynthesizedSelf
376
- ? typeVarContext
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 (!typeVarContext.isLocked() && isTypeVarInScope) {
393
- updateTypeVarType(evaluator, typeVarContext, destType, newLowerBound, newUpperTypeBound, (flags & (2048 /* AssignTypeFlags.PopulatingExpectedType */ | 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */)) !== 0);
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
- exports.assignTypeToTypeVar = assignTypeToTypeVar;
403
- // Updates the lower and upper bounds for a type variable. It also calculates the
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 = typeVarContext.getMainSolutionSet().getTypeVar(destType);
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 forceRetainLiterals = false;
643
+ let retainLiterals = false;
432
644
  if ((0, types_1.isTypeVar)(srcType)) {
433
645
  if (evaluator.assignType(destType, concreteSrcType,
434
- /* diag */ undefined, new typeVarContext_1.TypeVarContext(destType.priv.scopeId),
435
- /* srcTypeVarContext */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
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
- /* destTypeVarContext */ undefined,
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
- /* destTypeVarContext */ undefined,
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.ReverseTypeVarMatching */) === 0) {
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
- /* destTypeVarContext */ undefined,
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
- forceRetainLiterals = true;
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
- /* destTypeVarContext */ undefined,
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
- /* destTypeVarContext */ undefined,
537
- /* srcTypeVarContext */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount)) {
538
- if (!typeVarContext.isLocked() && isTypeVarInScope) {
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 (!typeVarContext.isLocked() && isTypeVarInScope) {
554
- updateTypeVarType(evaluator, typeVarContext, destType, constrainedType, curUpperBound, forceRetainLiterals);
760
+ if (constraints && !constraints.isLocked()) {
761
+ constraints.setBounds(destType, constrainedType, curUpperBound, retainLiterals);
555
762
  }
556
763
  }
557
764
  return true;
558
765
  }
559
- function assignTypeToParamSpec(evaluator, destType, srcType, diag, typeVarContext, recursionCount = 0) {
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
- const adjSrcType = (0, types_1.isFunction)(srcType) ? (0, typeUtils_1.convertParamSpecValueToType)(srcType) : srcType;
562
- typeVarContext.doForEachSolutionSet((solutionSet) => {
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 = solutionSet.getTypeVarType(destType);
781
+ const existingType = (_a = constraintSet.getTypeVar(destType)) === null || _a === void 0 ? void 0 : _a.lowerBound;
565
782
  if (existingType) {
566
- const existingTypeParamSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(existingType);
567
- const existingTypeWithoutArgsKwargs = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(existingType);
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 (!typeVarContext.isLocked() && typeVarContext.hasSolveForScope(destType.priv.scopeId)) {
577
- solutionSet.setTypeVarType(destType, (0, typeUtils_1.convertTypeToParamSpecValue)(adjSrcType));
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 = solutionSet.getTypeVarType(destType);
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.convertParamSpecValueToType)(existingType);
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
- /* destTypeVarContext */ undefined,
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
- /* destTypeVarContext */ undefined,
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 (!typeVarContext.isLocked() && typeVarContext.hasSolveForScope(destType.priv.scopeId)) {
626
- solutionSet.setTypeVarType(destType, newFunction);
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 TypeVarContext to the console.
833
- function logTypeVarContext(evaluator, typeVarContext, indent) {
834
- const solutionSetCount = typeVarContext.getSolutionSets().length;
835
- if (solutionSetCount === 0) {
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 (solutionSetCount === 1) {
839
- logTypeVarSolutionSet(evaluator, typeVarContext.getSolutionSets()[0], `${indent} `);
913
+ else if (constraintSetCount === 1) {
914
+ logTypeVarConstraintSet(evaluator, constraints.getConstraintSets()[0], `${indent} `);
840
915
  }
841
916
  else {
842
- typeVarContext.doForEachSolutionSet((solutionSet, index) => {
917
+ constraints.doForEachConstraintSet((set, index) => {
843
918
  console.log(`${indent} signature ${index}`);
844
- logTypeVarSolutionSet(evaluator, solutionSet, `${indent} `);
919
+ logTypeVarConstraintSet(evaluator, set, `${indent} `);
845
920
  });
846
921
  }
847
922
  }
848
- function logTypeVarSolutionSet(evaluator, context, indent) {
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 = (_a = entry.lowerBoundNoLiterals) !== null && _a !== void 0 ? _a : entry.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)) {