@zzzen/pyright-internal 1.2.0-dev.20240630 → 1.2.0-dev.20240714

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 (170) hide show
  1. package/dist/analyzer/analyzerNodeInfo.js +74 -46
  2. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  3. package/dist/analyzer/binder.js +507 -513
  4. package/dist/analyzer/binder.js.map +1 -1
  5. package/dist/analyzer/checker.js +652 -633
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/codeFlowEngine.d.ts +5 -3
  8. package/dist/analyzer/codeFlowEngine.js +143 -122
  9. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  10. package/dist/analyzer/codeFlowTypes.js +30 -28
  11. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  12. package/dist/analyzer/constraintSolver.d.ts +1 -1
  13. package/dist/analyzer/constraintSolver.js +71 -67
  14. package/dist/analyzer/constraintSolver.js.map +1 -1
  15. package/dist/analyzer/constructorTransform.js +22 -22
  16. package/dist/analyzer/constructorTransform.js.map +1 -1
  17. package/dist/analyzer/constructors.js +85 -77
  18. package/dist/analyzer/constructors.js.map +1 -1
  19. package/dist/analyzer/dataClasses.js +113 -176
  20. package/dist/analyzer/dataClasses.js.map +1 -1
  21. package/dist/analyzer/declaration.d.ts +1 -1
  22. package/dist/analyzer/declarationUtils.js +14 -15
  23. package/dist/analyzer/declarationUtils.js.map +1 -1
  24. package/dist/analyzer/decorators.js +85 -85
  25. package/dist/analyzer/decorators.js.map +1 -1
  26. package/dist/analyzer/enums.js +71 -57
  27. package/dist/analyzer/enums.js.map +1 -1
  28. package/dist/analyzer/functionTransform.js +8 -18
  29. package/dist/analyzer/functionTransform.js.map +1 -1
  30. package/dist/analyzer/importResolver.d.ts +2 -1
  31. package/dist/analyzer/importResolver.js +40 -29
  32. package/dist/analyzer/importResolver.js.map +1 -1
  33. package/dist/analyzer/importStatementUtils.js +27 -27
  34. package/dist/analyzer/importStatementUtils.js.map +1 -1
  35. package/dist/analyzer/namedTuples.js +33 -59
  36. package/dist/analyzer/namedTuples.js.map +1 -1
  37. package/dist/analyzer/operations.d.ts +4 -4
  38. package/dist/analyzer/operations.js +70 -70
  39. package/dist/analyzer/operations.js.map +1 -1
  40. package/dist/analyzer/packageTypeVerifier.js +66 -62
  41. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  42. package/dist/analyzer/parameterUtils.d.ts +4 -4
  43. package/dist/analyzer/parameterUtils.js +28 -46
  44. package/dist/analyzer/parameterUtils.js.map +1 -1
  45. package/dist/analyzer/parseTreeUtils.js +268 -269
  46. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  47. package/dist/analyzer/parseTreeWalker.js +76 -76
  48. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  49. package/dist/analyzer/patternMatching.js +195 -147
  50. package/dist/analyzer/patternMatching.js.map +1 -1
  51. package/dist/analyzer/program.js +1 -1
  52. package/dist/analyzer/program.js.map +1 -1
  53. package/dist/analyzer/properties.js +78 -147
  54. package/dist/analyzer/properties.js.map +1 -1
  55. package/dist/analyzer/protocols.js +22 -22
  56. package/dist/analyzer/protocols.js.map +1 -1
  57. package/dist/analyzer/sourceFile.d.ts +3 -2
  58. package/dist/analyzer/sourceFile.js +8 -8
  59. package/dist/analyzer/sourceFile.js.map +1 -1
  60. package/dist/analyzer/sourceMapper.js +20 -19
  61. package/dist/analyzer/sourceMapper.js.map +1 -1
  62. package/dist/analyzer/staticExpressions.js +83 -84
  63. package/dist/analyzer/staticExpressions.js.map +1 -1
  64. package/dist/analyzer/testWalker.js +2 -2
  65. package/dist/analyzer/testWalker.js.map +1 -1
  66. package/dist/analyzer/tracePrinter.js +20 -20
  67. package/dist/analyzer/tracePrinter.js.map +1 -1
  68. package/dist/analyzer/typeDocStringUtils.js +25 -25
  69. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  70. package/dist/analyzer/typeEvaluator.js +2330 -2367
  71. package/dist/analyzer/typeEvaluator.js.map +1 -1
  72. package/dist/analyzer/typeEvaluatorTypes.d.ts +33 -31
  73. package/dist/analyzer/typeEvaluatorTypes.js +48 -41
  74. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  75. package/dist/analyzer/typeGuards.js +221 -217
  76. package/dist/analyzer/typeGuards.js.map +1 -1
  77. package/dist/analyzer/typePrinter.js +118 -115
  78. package/dist/analyzer/typePrinter.js.map +1 -1
  79. package/dist/analyzer/typeStubWriter.js +104 -103
  80. package/dist/analyzer/typeStubWriter.js.map +1 -1
  81. package/dist/analyzer/typeUtils.d.ts +26 -9
  82. package/dist/analyzer/typeUtils.js +460 -404
  83. package/dist/analyzer/typeUtils.js.map +1 -1
  84. package/dist/analyzer/typeVarContext.js +8 -8
  85. package/dist/analyzer/typeVarContext.js.map +1 -1
  86. package/dist/analyzer/typeWalker.js +13 -10
  87. package/dist/analyzer/typeWalker.js.map +1 -1
  88. package/dist/analyzer/typedDicts.js +96 -198
  89. package/dist/analyzer/typedDicts.js.map +1 -1
  90. package/dist/analyzer/types.d.ts +147 -103
  91. package/dist/analyzer/types.js +668 -493
  92. package/dist/analyzer/types.js.map +1 -1
  93. package/dist/commands/dumpFileDebugInfoCommand.js +33 -33
  94. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  95. package/dist/common/diagnostic.d.ts +14 -0
  96. package/dist/common/diagnostic.js +41 -1
  97. package/dist/common/diagnostic.js.map +1 -1
  98. package/dist/common/diagnosticSink.d.ts +4 -0
  99. package/dist/common/diagnosticSink.js +21 -1
  100. package/dist/common/diagnosticSink.js.map +1 -1
  101. package/dist/common/fileSystem.d.ts +1 -0
  102. package/dist/common/fileSystem.js.map +1 -1
  103. package/dist/common/fullAccessHost.js +6 -4
  104. package/dist/common/fullAccessHost.js.map +1 -1
  105. package/dist/common/realFileSystem.d.ts +1 -0
  106. package/dist/common/realFileSystem.js +4 -0
  107. package/dist/common/realFileSystem.js.map +1 -1
  108. package/dist/common/textEditTracker.js +14 -14
  109. package/dist/common/textEditTracker.js.map +1 -1
  110. package/dist/languageService/autoImporter.js +10 -10
  111. package/dist/languageService/autoImporter.js.map +1 -1
  112. package/dist/languageService/callHierarchyProvider.js +23 -23
  113. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  114. package/dist/languageService/completionProvider.d.ts +1 -1
  115. package/dist/languageService/completionProvider.js +156 -154
  116. package/dist/languageService/completionProvider.js.map +1 -1
  117. package/dist/languageService/definitionProvider.d.ts +1 -1
  118. package/dist/languageService/definitionProvider.js +3 -1
  119. package/dist/languageService/definitionProvider.js.map +1 -1
  120. package/dist/languageService/documentSymbolCollector.js +19 -19
  121. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  122. package/dist/languageService/hoverProvider.js +25 -24
  123. package/dist/languageService/hoverProvider.js.map +1 -1
  124. package/dist/languageService/importSorter.js +8 -8
  125. package/dist/languageService/importSorter.js.map +1 -1
  126. package/dist/languageService/referencesProvider.js +8 -8
  127. package/dist/languageService/referencesProvider.js.map +1 -1
  128. package/dist/languageService/signatureHelpProvider.d.ts +1 -1
  129. package/dist/languageService/signatureHelpProvider.js +6 -6
  130. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  131. package/dist/languageService/symbolIndexer.js +3 -3
  132. package/dist/languageService/symbolIndexer.js.map +1 -1
  133. package/dist/languageService/tooltipUtils.js +13 -13
  134. package/dist/languageService/tooltipUtils.js.map +1 -1
  135. package/dist/localization/localize.d.ts +3 -0
  136. package/dist/localization/localize.js +1 -0
  137. package/dist/localization/localize.js.map +1 -1
  138. package/dist/localization/package.nls.en-us.json +2 -1
  139. package/dist/parser/parseNodes.d.ts +468 -401
  140. package/dist/parser/parseNodes.js +626 -355
  141. package/dist/parser/parseNodes.js.map +1 -1
  142. package/dist/parser/parser.d.ts +1 -0
  143. package/dist/parser/parser.js +322 -297
  144. package/dist/parser/parser.js.map +1 -1
  145. package/dist/pyright.js +265 -5
  146. package/dist/pyright.js.map +1 -1
  147. package/dist/tests/classDeclaration.test.js +14 -14
  148. package/dist/tests/classDeclaration.test.js.map +1 -1
  149. package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
  150. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  151. package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
  152. package/dist/tests/harness/vfs/filesystem.js +6 -2
  153. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  154. package/dist/tests/importResolver.test.js +4 -3
  155. package/dist/tests/importResolver.test.js.map +1 -1
  156. package/dist/tests/parseTreeUtils.test.js +5 -5
  157. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  158. package/dist/tests/parser.test.js +8 -8
  159. package/dist/tests/parser.test.js.map +1 -1
  160. package/dist/tests/sourceMapperUtils.test.js +7 -7
  161. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  162. package/dist/tests/typeEvaluator2.test.js +2 -2
  163. package/dist/tests/typeEvaluator3.test.js +10 -5
  164. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  165. package/dist/tests/typeEvaluator4.test.js +1 -1
  166. package/dist/tests/typeEvaluator7.test.js +2 -2
  167. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  168. package/dist/tests/typePrinter.test.js +14 -39
  169. package/dist/tests/typePrinter.test.js.map +1 -1
  170. package/package.json +1 -1
@@ -74,9 +74,9 @@ function checkForUnusedPattern(evaluator, pattern, subjectType) {
74
74
  if ((0, types_1.isNever)(subjectType)) {
75
75
  reportUnnecessaryPattern(evaluator, pattern, subjectType);
76
76
  }
77
- else if (pattern.nodeType === 66 /* ParseNodeType.PatternAs */ && pattern.orPatterns.length > 1) {
77
+ else if (pattern.nodeType === 66 /* ParseNodeType.PatternAs */ && pattern.d.orPatterns.length > 1) {
78
78
  // Check each of the or patterns separately.
79
- pattern.orPatterns.forEach((orPattern) => {
79
+ pattern.d.orPatterns.forEach((orPattern) => {
80
80
  const subjectTypeMatch = narrowTypeBasedOnPattern(evaluator, subjectType, orPattern,
81
81
  /* isPositiveTest */ true);
82
82
  if ((0, types_1.isNever)(subjectTypeMatch)) {
@@ -118,32 +118,38 @@ function narrowTypeBasedOnSequencePattern(evaluator, type, pattern, isPositiveTe
118
118
  if (entry.isIndeterminateLength) {
119
119
  canNarrowTuple = false;
120
120
  }
121
- if ((0, types_1.isClassInstance)(entry.subtype) &&
122
- entry.subtype.tupleTypeArguments &&
123
- entry.subtype.tupleTypeArguments.some((typeArg) => typeArg.isUnbounded)) {
124
- canNarrowTuple = false;
121
+ if ((0, types_1.isClassInstance)(entry.subtype) && entry.subtype.priv.tupleTypeArguments) {
122
+ const unboundedIndex = entry.subtype.priv.tupleTypeArguments.findIndex((typeArg) => typeArg.isUnbounded);
123
+ if (unboundedIndex >= 0) {
124
+ // If the pattern includes a "star" entry that aligns exactly with
125
+ // the corresponding unbounded entry in the tuple, we can narrow
126
+ // the tuple type.
127
+ if (pattern.d.starEntryIndex === undefined || pattern.d.starEntryIndex !== unboundedIndex) {
128
+ canNarrowTuple = false;
129
+ }
130
+ }
125
131
  }
126
132
  }
127
133
  // If the subject has an indeterminate length but the pattern does not accept
128
134
  // an arbitrary number of entries or accepts at least one non-star entry,
129
135
  // we can't prove that it's a definite match.
130
136
  if (entry.isIndeterminateLength) {
131
- if (pattern.entries.length !== 1 || pattern.starEntryIndex !== 0) {
137
+ if (pattern.d.entries.length !== 1 || pattern.d.starEntryIndex !== 0) {
132
138
  isDefiniteMatch = false;
133
139
  }
134
140
  }
135
141
  let negativeEntriesNarrowed = 0;
136
- pattern.entries.forEach((sequenceEntry, index) => {
137
- const entryType = getTypeOfPatternSequenceEntry(evaluator, pattern, entry, index, pattern.entries.length, pattern.starEntryIndex,
142
+ pattern.d.entries.forEach((sequenceEntry, index) => {
143
+ const entryType = getTypeOfPatternSequenceEntry(evaluator, pattern, entry, index, pattern.d.entries.length, pattern.d.starEntryIndex,
138
144
  /* unpackStarEntry */ true);
139
145
  const narrowedEntryType = narrowTypeBasedOnPattern(evaluator, entryType, sequenceEntry, isPositiveTest);
140
146
  if (isPositiveTest) {
141
- if (index === pattern.starEntryIndex) {
147
+ if (index === pattern.d.starEntryIndex) {
142
148
  if ((0, types_1.isClassInstance)(narrowedEntryType) &&
143
- narrowedEntryType.tupleTypeArguments &&
149
+ narrowedEntryType.priv.tupleTypeArguments &&
144
150
  !(0, typeUtils_1.isUnboundedTupleClass)(narrowedEntryType) &&
145
- narrowedEntryType.tupleTypeArguments) {
146
- (0, collectionUtils_1.appendArray)(narrowedEntryTypes, narrowedEntryType.tupleTypeArguments.map((t) => t.type));
151
+ narrowedEntryType.priv.tupleTypeArguments) {
152
+ (0, collectionUtils_1.appendArray)(narrowedEntryTypes, narrowedEntryType.priv.tupleTypeArguments.map((t) => t.type));
147
153
  }
148
154
  else {
149
155
  narrowedEntryTypes.push(narrowedEntryType);
@@ -172,12 +178,12 @@ function narrowTypeBasedOnSequencePattern(evaluator, type, pattern, isPositiveTe
172
178
  else {
173
179
  narrowedEntryTypes.push(entryType);
174
180
  }
175
- if (index === pattern.starEntryIndex) {
181
+ if (index === pattern.d.starEntryIndex) {
176
182
  canNarrowTuple = false;
177
183
  }
178
184
  }
179
185
  });
180
- if (pattern.entries.length === 0) {
186
+ if (pattern.d.entries.length === 0) {
181
187
  // If the pattern is an empty sequence, use the entry types.
182
188
  if (entry.entryTypes.length > 0) {
183
189
  narrowedEntryTypes.push((0, types_1.combineTypes)(entry.entryTypes));
@@ -234,12 +240,12 @@ function narrowTypeBasedOnSequencePattern(evaluator, type, pattern, isPositiveTe
234
240
  function narrowTypeBasedOnAsPattern(evaluator, type, pattern, isPositiveTest) {
235
241
  let remainingType = type;
236
242
  if (!isPositiveTest) {
237
- pattern.orPatterns.forEach((subpattern) => {
243
+ pattern.d.orPatterns.forEach((subpattern) => {
238
244
  remainingType = narrowTypeBasedOnPattern(evaluator, remainingType, subpattern, /* isPositiveTest */ false);
239
245
  });
240
246
  return remainingType;
241
247
  }
242
- const narrowedTypes = pattern.orPatterns.map((subpattern) => {
248
+ const narrowedTypes = pattern.d.orPatterns.map((subpattern) => {
243
249
  const narrowedSubtype = narrowTypeBasedOnPattern(evaluator, remainingType, subpattern,
244
250
  /* isPositiveTest */ true);
245
251
  remainingType = narrowTypeBasedOnPattern(evaluator, remainingType, subpattern, /* isPositiveTest */ false);
@@ -250,26 +256,33 @@ function narrowTypeBasedOnAsPattern(evaluator, type, pattern, isPositiveTest) {
250
256
  function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTest) {
251
257
  type = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(type);
252
258
  if (!isPositiveTest) {
253
- // Our ability to narrow in the negative case for mapping patterns is
254
- // limited, but we can do it if the type is a union that includes a
255
- // TypedDict with a field discriminated by a literal.
256
- if (pattern.entries.length !== 1 || pattern.entries[0].nodeType !== 71 /* ParseNodeType.PatternMappingKeyEntry */) {
259
+ // Handle the case where the pattern consists only of a "**x" entry.
260
+ if (pattern.d.entries.length === 1 &&
261
+ pattern.d.entries[0].nodeType === 72 /* ParseNodeType.PatternMappingExpandEntry */) {
262
+ const mappingInfo = getMappingPatternInfo(evaluator, type, pattern);
263
+ return (0, types_1.combineTypes)(mappingInfo.filter((m) => !m.isDefinitelyMapping).map((m) => m.subtype));
264
+ }
265
+ if (pattern.d.entries.length !== 1 || pattern.d.entries[0].nodeType !== 71 /* ParseNodeType.PatternMappingKeyEntry */) {
257
266
  return type;
258
267
  }
259
- const keyPattern = pattern.entries[0].keyPattern;
260
- const valuePattern = pattern.entries[0].valuePattern;
268
+ // Handle the case where the type is a union that includes a TypedDict with
269
+ // a field discriminated by a literal.
270
+ const keyPattern = pattern.d.entries[0].d.keyPattern;
271
+ const valuePattern = pattern.d.entries[0].d.valuePattern;
261
272
  if (keyPattern.nodeType !== 67 /* ParseNodeType.PatternLiteral */ ||
262
273
  valuePattern.nodeType !== 66 /* ParseNodeType.PatternAs */ ||
263
- !valuePattern.orPatterns.every((orPattern) => orPattern.nodeType === 67 /* ParseNodeType.PatternLiteral */)) {
274
+ !valuePattern.d.orPatterns.every((orPattern) => orPattern.nodeType === 67 /* ParseNodeType.PatternLiteral */)) {
264
275
  return type;
265
276
  }
266
- const keyType = evaluator.getTypeOfExpression(keyPattern.expression).type;
277
+ const keyType = evaluator.getTypeOfExpression(keyPattern.d.expr).type;
267
278
  // The key type must be a str literal.
268
- if (!(0, types_1.isClassInstance)(keyType) || !types_1.ClassType.isBuiltIn(keyType, 'str') || keyType.literalValue === undefined) {
279
+ if (!(0, types_1.isClassInstance)(keyType) ||
280
+ !types_1.ClassType.isBuiltIn(keyType, 'str') ||
281
+ keyType.priv.literalValue === undefined) {
269
282
  return type;
270
283
  }
271
- const keyValue = keyType.literalValue;
272
- const valueTypes = valuePattern.orPatterns.map((orPattern) => evaluator.getTypeOfExpression(orPattern.expression).type);
284
+ const keyValue = keyType.priv.literalValue;
285
+ const valueTypes = valuePattern.d.orPatterns.map((orPattern) => evaluator.getTypeOfExpression(orPattern.d.expr).type);
273
286
  return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
274
287
  if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isTypedDictClass(subtype)) {
275
288
  const typedDictMembers = (0, typedDicts_1.getTypedDictMembersForClass)(evaluator, subtype, /* allowNarrowed */ true);
@@ -280,7 +293,7 @@ function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTes
280
293
  // the literal type of the member, we can eliminate this type.
281
294
  if (valueTypes.some((valueType) => (0, types_1.isClassInstance)(valueType) &&
282
295
  types_1.ClassType.isSameGenericClass(valueType, memberValueType) &&
283
- valueType.literalValue === memberValueType.literalValue)) {
296
+ valueType.priv.literalValue === memberValueType.priv.literalValue)) {
284
297
  return undefined;
285
298
  }
286
299
  }
@@ -291,11 +304,14 @@ function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTes
291
304
  let mappingInfo = getMappingPatternInfo(evaluator, type, pattern);
292
305
  // Further narrow based on pattern entry types.
293
306
  mappingInfo = mappingInfo.filter((mappingSubtypeInfo) => {
307
+ if (mappingSubtypeInfo.isDefinitelyNotMapping) {
308
+ return false;
309
+ }
294
310
  let isPlausibleMatch = true;
295
- pattern.entries.forEach((mappingEntry) => {
311
+ pattern.d.entries.forEach((mappingEntry) => {
296
312
  if (mappingSubtypeInfo.typedDict) {
297
313
  if (mappingEntry.nodeType === 71 /* ParseNodeType.PatternMappingKeyEntry */) {
298
- const narrowedKeyType = narrowTypeBasedOnPattern(evaluator, evaluator.getBuiltInObject(pattern, 'str'), mappingEntry.keyPattern, isPositiveTest);
314
+ const narrowedKeyType = narrowTypeBasedOnPattern(evaluator, evaluator.getBuiltInObject(pattern, 'str'), mappingEntry.d.keyPattern, isPositiveTest);
299
315
  if ((0, types_1.isNever)(narrowedKeyType)) {
300
316
  isPlausibleMatch = false;
301
317
  }
@@ -309,9 +325,9 @@ function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTes
309
325
  return types_1.UnknownType.create();
310
326
  }
311
327
  const tdEntries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluator, mappingSubtypeInfo.typedDict);
312
- const valueEntry = tdEntries.knownItems.get(keySubtype.literalValue);
328
+ const valueEntry = tdEntries.knownItems.get(keySubtype.priv.literalValue);
313
329
  if (valueEntry) {
314
- const narrowedValueType = narrowTypeBasedOnPattern(evaluator, valueEntry.valueType, mappingEntry.valuePattern,
330
+ const narrowedValueType = narrowTypeBasedOnPattern(evaluator, valueEntry.valueType, mappingEntry.d.valuePattern,
315
331
  /* isPositiveTest */ true);
316
332
  if (!(0, types_1.isNever)(narrowedValueType)) {
317
333
  // If this is a "NotRequired" entry that has not yet been demonstrated
@@ -319,8 +335,8 @@ function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTes
319
335
  if (!valueEntry.isRequired &&
320
336
  !valueEntry.isProvided &&
321
337
  (0, types_1.isTypeSame)(mappingSubtypeInfo.subtype, mappingSubtypeInfo.typedDict)) {
322
- const newNarrowedEntriesMap = new Map((_a = mappingSubtypeInfo.typedDict.typedDictNarrowedEntries) !== null && _a !== void 0 ? _a : []);
323
- newNarrowedEntriesMap.set(keySubtype.literalValue, {
338
+ const newNarrowedEntriesMap = new Map((_a = mappingSubtypeInfo.typedDict.priv.typedDictNarrowedEntries) !== null && _a !== void 0 ? _a : []);
339
+ newNarrowedEntriesMap.set(keySubtype.priv.literalValue, {
324
340
  valueType: valueEntry.valueType,
325
341
  isReadOnly: valueEntry.isReadOnly,
326
342
  isRequired: false,
@@ -343,8 +359,8 @@ function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTes
343
359
  }
344
360
  else if (mappingSubtypeInfo.dictTypeArgs) {
345
361
  if (mappingEntry.nodeType === 71 /* ParseNodeType.PatternMappingKeyEntry */) {
346
- const narrowedKeyType = narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.key, mappingEntry.keyPattern, isPositiveTest);
347
- const narrowedValueType = narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.value, mappingEntry.valuePattern, isPositiveTest);
362
+ const narrowedKeyType = narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.key, mappingEntry.d.keyPattern, isPositiveTest);
363
+ const narrowedValueType = narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.value, mappingEntry.d.valuePattern, isPositiveTest);
348
364
  if ((0, types_1.isNever)(narrowedKeyType) || (0, types_1.isNever)(narrowedValueType)) {
349
365
  isPlausibleMatch = false;
350
366
  }
@@ -364,18 +380,18 @@ function getPositionalMatchArgNames(evaluator, type) {
364
380
  if ((0, types_1.isClassInstance)(matchArgsType) &&
365
381
  (0, typeUtils_1.isTupleClass)(matchArgsType) &&
366
382
  !(0, typeUtils_1.isUnboundedTupleClass)(matchArgsType) &&
367
- matchArgsType.tupleTypeArguments) {
368
- const tupleArgs = matchArgsType.tupleTypeArguments;
383
+ matchArgsType.priv.tupleTypeArguments) {
384
+ const tupleArgs = matchArgsType.priv.tupleTypeArguments;
369
385
  // Are all the args string literals?
370
386
  if (tupleArgs.every((arg) => (0, types_1.isClassInstance)(arg.type) && types_1.ClassType.isBuiltIn(arg.type, 'str') && (0, typeUtils_1.isLiteralType)(arg.type))) {
371
- return tupleArgs.map((arg) => arg.type.literalValue);
387
+ return tupleArgs.map((arg) => arg.type.priv.literalValue);
372
388
  }
373
389
  }
374
390
  }
375
391
  return [];
376
392
  }
377
393
  function narrowTypeBasedOnLiteralPattern(evaluator, type, pattern, isPositiveTest) {
378
- const literalType = evaluator.getTypeOfExpression(pattern.expression).type;
394
+ const literalType = evaluator.getTypeOfExpression(pattern.d.expr).type;
379
395
  if (!isPositiveTest) {
380
396
  return evaluator.mapSubtypesExpandTypeVars(type,
381
397
  /* options */ undefined, (expandedSubtype, unexpandedSubtype) => {
@@ -392,11 +408,11 @@ function narrowTypeBasedOnLiteralPattern(evaluator, type, pattern, isPositiveTes
392
408
  // Narrow a non-literal bool based on a literal bool pattern.
393
409
  if ((0, types_1.isClassInstance)(expandedSubtype) &&
394
410
  types_1.ClassType.isBuiltIn(expandedSubtype, 'bool') &&
395
- expandedSubtype.literalValue === undefined &&
411
+ expandedSubtype.priv.literalValue === undefined &&
396
412
  (0, types_1.isClassInstance)(literalType) &&
397
413
  types_1.ClassType.isBuiltIn(literalType, 'bool') &&
398
- literalType.literalValue !== undefined) {
399
- return types_1.ClassType.cloneWithLiteral(literalType, !literalType.literalValue);
414
+ literalType.priv.literalValue !== undefined) {
415
+ return types_1.ClassType.cloneWithLiteral(literalType, !literalType.priv.literalValue);
400
416
  }
401
417
  return expandedSubtype;
402
418
  });
@@ -419,17 +435,18 @@ function narrowTypeBasedOnLiteralPattern(evaluator, type, pattern, isPositiveTes
419
435
  });
420
436
  }
421
437
  function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest) {
422
- let exprType = evaluator.getTypeOfExpression(pattern.className, 2 /* EvaluatorFlags.CallBaseDefaults */).type;
438
+ var _a;
439
+ let exprType = evaluator.getTypeOfExpression(pattern.d.className, 2 /* EvalFlags.CallBaseDefaults */).type;
423
440
  // If this is a class (but not a type alias that refers to a class),
424
441
  // specialize it with Unknown type arguments.
425
- if ((0, types_1.isClass)(exprType) && !exprType.typeAliasInfo) {
442
+ if ((0, types_1.isClass)(exprType) && !((_a = exprType.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo)) {
426
443
  exprType = types_1.ClassType.cloneRemoveTypePromotions(exprType);
427
- exprType = (0, typeUtils_1.specializeWithUnknownTypeArgs)(exprType);
444
+ exprType = (0, typeUtils_1.specializeWithUnknownTypeArgs)(exprType, evaluator.getTupleClassType());
428
445
  }
429
446
  // Are there any positional arguments? If so, try to get the mappings for
430
447
  // these arguments by fetching the __match_args__ symbol from the class.
431
448
  let positionalArgNames = [];
432
- if (pattern.arguments.some((arg) => !arg.name) && (0, types_1.isInstantiableClass)(exprType)) {
449
+ if (pattern.d.args.some((arg) => !arg.d.name) && (0, types_1.isInstantiableClass)(exprType)) {
433
450
  positionalArgNames = getPositionalMatchArgNames(evaluator, exprType);
434
451
  }
435
452
  if (!isPositiveTest) {
@@ -438,7 +455,7 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
438
455
  return type;
439
456
  }
440
457
  let classType = exprType;
441
- if (classType.details.typeParameters.length > 0) {
458
+ if (classType.shared.typeParameters.length > 0) {
442
459
  classType = types_1.ClassType.cloneForSpecialization(classType,
443
460
  /* typeArguments */ undefined,
444
461
  /* isTypeArgumentExplicit */ false);
@@ -452,7 +469,7 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
452
469
  // Handle the case where the class pattern references type() or a subtype thereof
453
470
  // and the subject type is an instantiable class itself.
454
471
  if (isPatternMetaclass && (0, types_1.isInstantiableClass)(subjectSubtypeExpanded)) {
455
- const metaclass = (_a = subjectSubtypeExpanded.details.effectiveMetaclass) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
472
+ const metaclass = (_a = subjectSubtypeExpanded.shared.effectiveMetaclass) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
456
473
  if ((0, types_1.isInstantiableClass)(classType) && evaluator.assignType(classType, metaclass)) {
457
474
  return undefined;
458
475
  }
@@ -478,7 +495,7 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
478
495
  if (!evaluator.assignType(classInstance, subjectSubtypeExpanded)) {
479
496
  return subjectSubtypeExpanded;
480
497
  }
481
- if (pattern.arguments.length === 0) {
498
+ if (pattern.d.args.length === 0) {
482
499
  if ((0, types_1.isClass)(classInstance) && (0, types_1.isClass)(subjectSubtypeExpanded)) {
483
500
  // We know that this match will always succeed, so we can
484
501
  // eliminate this subtype.
@@ -497,8 +514,8 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
497
514
  return subjectSubtypeExpanded;
498
515
  }
499
516
  }
500
- for (let index = 0; index < pattern.arguments.length; index++) {
501
- const narrowedArgType = narrowTypeOfClassPatternArgument(evaluator, pattern.arguments[index], index, positionalArgNames, subjectSubtypeExpanded, isPositiveTest);
517
+ for (let index = 0; index < pattern.d.args.length; index++) {
518
+ const narrowedArgType = narrowTypeOfClassPatternArgument(evaluator, pattern.d.args[index], index, positionalArgNames, subjectSubtypeExpanded, isPositiveTest);
502
519
  if (!(0, types_1.isNever)(narrowedArgType)) {
503
520
  return subjectSubtypeUnexpanded;
504
521
  }
@@ -508,13 +525,13 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
508
525
  });
509
526
  }
510
527
  if (!types_1.TypeBase.isInstantiable(exprType) && !(0, types_1.isNever)(exprType)) {
511
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocAddendum.typeNotClass().format({ type: evaluator.printType(exprType) }), pattern.className);
528
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocAddendum.typeNotClass().format({ type: evaluator.printType(exprType) }), pattern.d.className);
512
529
  return types_1.NeverType.createNever();
513
530
  }
514
531
  else if ((0, types_1.isInstantiableClass)(exprType) &&
515
532
  types_1.ClassType.isProtocolClass(exprType) &&
516
533
  !types_1.ClassType.isRuntimeCheckable(exprType)) {
517
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocAddendum.protocolRequiresRuntimeCheckable(), pattern.className);
534
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocAddendum.protocolRequiresRuntimeCheckable(), pattern.d.className);
518
535
  }
519
536
  return evaluator.mapSubtypesExpandTypeVars(exprType,
520
537
  /* options */ undefined, (expandedSubtype, unexpandedSubtype) => {
@@ -532,7 +549,7 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
532
549
  const unknownCallable = types_1.FunctionType.createSynthesizedInstance('', 32768 /* FunctionTypeFlags.GradualCallableForm */);
533
550
  types_1.FunctionType.addDefaultParameters(unknownCallable,
534
551
  /* useUnknown */ (0, types_1.isUnknown)(subjectSubtypeExpanded));
535
- unknownCallable.details.declaredReturnType = subjectSubtypeExpanded;
552
+ unknownCallable.shared.declaredReturnType = subjectSubtypeExpanded;
536
553
  return unknownCallable;
537
554
  }
538
555
  return (0, typeUtils_1.convertToInstance)(unexpandedSubtype);
@@ -540,7 +557,7 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
540
557
  // Handle the case where the class pattern references type() or a subtype thereof
541
558
  // and the subject type is a class itself.
542
559
  if (isPatternMetaclass && (0, types_1.isInstantiableClass)(subjectSubtypeExpanded)) {
543
- const metaclass = (_a = subjectSubtypeExpanded.details.effectiveMetaclass) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
560
+ const metaclass = (_a = subjectSubtypeExpanded.shared.effectiveMetaclass) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
544
561
  if (evaluator.assignType(expandedSubtype, metaclass) ||
545
562
  evaluator.assignType(metaclass, expandedSubtype)) {
546
563
  return subjectSubtypeExpanded;
@@ -575,17 +592,18 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
575
592
  // Try to retain the type arguments for the pattern class type.
576
593
  if ((0, types_1.isInstantiableClass)(unexpandedSubtype) && (0, types_1.isClassInstance)(subjectSubtypeExpanded)) {
577
594
  if (types_1.ClassType.isSpecialBuiltIn(unexpandedSubtype) ||
578
- unexpandedSubtype.details.typeParameters.length > 0) {
595
+ unexpandedSubtype.shared.typeParameters.length > 0) {
579
596
  const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(unexpandedSubtype));
580
597
  const unspecializedMatchType = types_1.ClassType.cloneForSpecialization(unexpandedSubtype,
581
598
  /* typeArguments */ undefined,
582
599
  /* isTypeArgumentExplicit */ false);
583
600
  const matchTypeInstance = types_1.ClassType.cloneAsInstance(unspecializedMatchType);
584
- if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, matchTypeInstance, subjectSubtypeExpanded, typeVarContext,
601
+ if ((0, constraintSolver_1.addConstraintsForExpectedType)(evaluator, matchTypeInstance, subjectSubtypeExpanded, typeVarContext,
585
602
  /* liveTypeVarScopes */ undefined,
586
603
  /* usageOffset */ undefined)) {
587
604
  resultType = (0, typeUtils_1.applySolvedTypeVars)(matchTypeInstance, typeVarContext, {
588
605
  unknownIfNotFound: true,
606
+ tupleClassType: evaluator.getTupleClassType(),
589
607
  });
590
608
  }
591
609
  }
@@ -597,11 +615,11 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
597
615
  // Are there any positional arguments? If so, try to get the mappings for
598
616
  // these arguments by fetching the __match_args__ symbol from the class.
599
617
  let positionalArgNames = [];
600
- if (pattern.arguments.some((arg) => !arg.name)) {
618
+ if (pattern.d.args.some((arg) => !arg.d.name)) {
601
619
  positionalArgNames = getPositionalMatchArgNames(evaluator, expandedSubtype);
602
620
  }
603
621
  let isMatchValid = true;
604
- pattern.arguments.forEach((arg, index) => {
622
+ pattern.d.args.forEach((arg, index) => {
605
623
  // Narrow the arg pattern. It's possible that the actual type of the object
606
624
  // being matched is a subtype of the resultType, so it might contain additional
607
625
  // attributes that we don't know about.
@@ -623,7 +641,7 @@ function narrowTypeBasedOnClassPattern(evaluator, type, pattern, isPositiveTest)
623
641
  // Some built-in classes are treated as special cases for the class pattern
624
642
  // if a positional argument is used.
625
643
  function isClassSpecialCaseForClassPattern(classType) {
626
- if (classPatternSpecialCases.some((className) => classType.details.fullName === className)) {
644
+ if (classPatternSpecialCases.some((className) => classType.shared.fullName === className)) {
627
645
  return true;
628
646
  }
629
647
  // If the class supplies its own `__match_args__`, it's not a special case.
@@ -632,9 +650,8 @@ function isClassSpecialCaseForClassPattern(classType) {
632
650
  return false;
633
651
  }
634
652
  // If the class derives from a built-in class, it is considered a special case.
635
- for (const mroClass of classType.details.mro) {
636
- if ((0, types_1.isClass)(mroClass) &&
637
- classPatternSpecialCases.some((className) => mroClass.details.fullName === className)) {
653
+ for (const mroClass of classType.shared.mro) {
654
+ if ((0, types_1.isClass)(mroClass) && classPatternSpecialCases.some((className) => mroClass.shared.fullName === className)) {
638
655
  return true;
639
656
  }
640
657
  }
@@ -644,8 +661,8 @@ function isClassSpecialCaseForClassPattern(classType) {
644
661
  function narrowTypeOfClassPatternArgument(evaluator, arg, argIndex, positionalArgNames, matchType, isPositiveTest) {
645
662
  var _a;
646
663
  let argName;
647
- if (arg.name) {
648
- argName = arg.name.value;
664
+ if (arg.d.name) {
665
+ argName = arg.d.name.d.value;
649
666
  }
650
667
  else if (argIndex < positionalArgNames.length) {
651
668
  argName = positionalArgNames[argIndex];
@@ -662,12 +679,12 @@ function narrowTypeOfClassPatternArgument(evaluator, arg, argIndex, positionalAr
662
679
  // if the subclass doesn't define its own __match_args__.
663
680
  let useSelfForPattern = false;
664
681
  let selfForPatternType = matchType;
665
- if (!arg.name && (0, types_1.isClass)(matchType) && argIndex === 0) {
682
+ if (!arg.d.name && (0, types_1.isClass)(matchType) && argIndex === 0) {
666
683
  if (isClassSpecialCaseForClassPattern(matchType)) {
667
684
  useSelfForPattern = true;
668
685
  }
669
686
  else if (positionalArgNames.length === 0) {
670
- matchType.details.mro.forEach((mroClass) => {
687
+ matchType.shared.mro.forEach((mroClass) => {
671
688
  if ((0, types_1.isClass)(mroClass) && isClassSpecialCaseForClassPattern(mroClass)) {
672
689
  selfForPatternType = mroClass;
673
690
  useSelfForPattern = true;
@@ -699,10 +716,10 @@ function narrowTypeOfClassPatternArgument(evaluator, arg, argIndex, positionalAr
699
716
  argType = types_1.UnknownType.create();
700
717
  }
701
718
  }
702
- return narrowTypeBasedOnPattern(evaluator, argType, arg.pattern, isPositiveTest);
719
+ return narrowTypeBasedOnPattern(evaluator, argType, arg.d.pattern, isPositiveTest);
703
720
  }
704
721
  function narrowTypeBasedOnValuePattern(evaluator, subjectType, pattern, isPositiveTest) {
705
- const valueType = evaluator.getTypeOfExpression(pattern.expression).type;
722
+ const valueType = evaluator.getTypeOfExpression(pattern.d.expr).type;
706
723
  const narrowedSubtypes = [];
707
724
  evaluator.mapSubtypesExpandTypeVars(valueType,
708
725
  /* options */ undefined, (valueSubtypeExpanded, valueSubtypeUnexpanded) => {
@@ -748,7 +765,7 @@ function narrowTypeBasedOnValuePattern(evaluator, subjectType, pattern, isPositi
748
765
  }
749
766
  // Determine if assignment is supported for this combination of
750
767
  // value subtype and matching subtype.
751
- const returnType = evaluator.useSpeculativeMode(pattern.expression, () => evaluator.getTypeOfMagicMethodCall(valueSubtypeExpanded, '__eq__', [{ type: subjectSubtypeExpanded }], pattern.expression,
768
+ const returnType = evaluator.useSpeculativeMode(pattern.d.expr, () => evaluator.getTypeOfMagicMethodCall(valueSubtypeExpanded, '__eq__', [{ type: subjectSubtypeExpanded }], pattern.d.expr,
752
769
  /* expectedType */ undefined));
753
770
  return returnType ? valueSubtypeUnexpanded : undefined;
754
771
  }));
@@ -765,6 +782,8 @@ function getMappingPatternInfo(evaluator, type, node) {
765
782
  if ((0, types_1.isAnyOrUnknown)(concreteSubtype)) {
766
783
  mappingInfo.push({
767
784
  subtype,
785
+ isDefinitelyMapping: false,
786
+ isDefinitelyNotMapping: false,
768
787
  dictTypeArgs: {
769
788
  key: concreteSubtype,
770
789
  value: concreteSubtype,
@@ -777,13 +796,15 @@ function getMappingPatternInfo(evaluator, type, node) {
777
796
  if (types_1.ClassType.isTypedDictClass(concreteSubtype)) {
778
797
  mappingInfo.push({
779
798
  subtype,
799
+ isDefinitelyMapping: true,
800
+ isDefinitelyNotMapping: false,
780
801
  typedDict: concreteSubtype,
781
802
  });
782
803
  return;
783
804
  }
784
805
  // Is it a subclass of Mapping?
785
806
  let mroClassToSpecialize;
786
- for (const mroClass of concreteSubtype.details.mro) {
807
+ for (const mroClass of concreteSubtype.shared.mro) {
787
808
  if ((0, types_1.isInstantiableClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'Mapping')) {
788
809
  mroClassToSpecialize = mroClass;
789
810
  break;
@@ -791,12 +812,14 @@ function getMappingPatternInfo(evaluator, type, node) {
791
812
  }
792
813
  if (mroClassToSpecialize) {
793
814
  const specializedMapping = (0, typeUtils_1.partiallySpecializeType)(mroClassToSpecialize, concreteSubtype);
794
- if (specializedMapping.typeArguments && specializedMapping.typeArguments.length >= 2) {
815
+ if (specializedMapping.priv.typeArguments && specializedMapping.priv.typeArguments.length >= 2) {
795
816
  mappingInfo.push({
796
817
  subtype,
818
+ isDefinitelyMapping: true,
819
+ isDefinitelyNotMapping: false,
797
820
  dictTypeArgs: {
798
- key: specializedMapping.typeArguments[0],
799
- value: specializedMapping.typeArguments[1],
821
+ key: specializedMapping.priv.typeArguments[0],
822
+ value: specializedMapping.priv.typeArguments[1],
800
823
  },
801
824
  });
802
825
  }
@@ -806,9 +829,11 @@ function getMappingPatternInfo(evaluator, type, node) {
806
829
  const mappingType = evaluator.getTypingType(node, 'Mapping');
807
830
  if (mappingType && (0, types_1.isInstantiableClass)(mappingType)) {
808
831
  const mappingObject = types_1.ClassType.cloneAsInstance(mappingType);
809
- if (evaluator.assignType(type, mappingObject)) {
832
+ if (evaluator.assignType(subtype, mappingObject)) {
810
833
  mappingInfo.push({
811
834
  subtype,
835
+ isDefinitelyMapping: false,
836
+ isDefinitelyNotMapping: false,
812
837
  dictTypeArgs: {
813
838
  key: types_1.UnknownType.create(),
814
839
  value: types_1.UnknownType.create(),
@@ -816,6 +841,11 @@ function getMappingPatternInfo(evaluator, type, node) {
816
841
  });
817
842
  }
818
843
  }
844
+ mappingInfo.push({
845
+ subtype,
846
+ isDefinitelyMapping: false,
847
+ isDefinitelyNotMapping: true,
848
+ });
819
849
  }
820
850
  });
821
851
  return mappingInfo;
@@ -824,8 +854,8 @@ function getMappingPatternInfo(evaluator, type, node) {
824
854
  // specified in PEP 634. For types that are not sequences or sequences that are not of
825
855
  // sufficient length, it sets definiteNoMatch to true.
826
856
  function getSequencePatternInfo(evaluator, pattern, type) {
827
- const patternEntryCount = pattern.entries.length;
828
- const patternStarEntryIndex = pattern.starEntryIndex;
857
+ const patternEntryCount = pattern.d.entries.length;
858
+ const patternStarEntryIndex = pattern.d.starEntryIndex;
829
859
  const sequenceInfo = [];
830
860
  (0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
831
861
  var _a;
@@ -833,7 +863,7 @@ function getSequencePatternInfo(evaluator, pattern, type) {
833
863
  let mroClassToSpecialize;
834
864
  let pushedEntry = false;
835
865
  if ((0, types_1.isClassInstance)(concreteSubtype)) {
836
- for (const mroClass of concreteSubtype.details.mro) {
866
+ for (const mroClass of concreteSubtype.shared.mro) {
837
867
  if (!(0, types_1.isInstantiableClass)(mroClass)) {
838
868
  break;
839
869
  }
@@ -862,13 +892,15 @@ function getSequencePatternInfo(evaluator, pattern, type) {
862
892
  if (mroClassToSpecialize) {
863
893
  const specializedSequence = (0, typeUtils_1.partiallySpecializeType)(mroClassToSpecialize, concreteSubtype);
864
894
  if ((0, typeUtils_1.isTupleClass)(specializedSequence)) {
865
- const typeArgs = (_a = specializedSequence.tupleTypeArguments) !== null && _a !== void 0 ? _a : [
895
+ const typeArgs = (_a = specializedSequence.priv.tupleTypeArguments) !== null && _a !== void 0 ? _a : [
866
896
  { type: types_1.UnknownType.create(), isUnbounded: true },
867
897
  ];
868
898
  const tupleIndeterminateIndex = typeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type));
899
+ let tupleDeterminateEntryCount = typeArgs.length;
869
900
  // If the tuple contains an indeterminate entry, expand or remove that
870
901
  // entry to match the length of the pattern if possible.
871
902
  if (tupleIndeterminateIndex >= 0) {
903
+ tupleDeterminateEntryCount--;
872
904
  while (typeArgs.length < patternEntryCount) {
873
905
  typeArgs.splice(tupleIndeterminateIndex, 0, typeArgs[tupleIndeterminateIndex]);
874
906
  }
@@ -891,11 +923,17 @@ function getSequencePatternInfo(evaluator, pattern, type) {
891
923
  if (typeArgs.length === patternEntryCount) {
892
924
  let isDefiniteNoMatch = false;
893
925
  let isPotentialNoMatch = tupleIndeterminateIndex >= 0;
894
- if (patternStarEntryIndex !== undefined && patternEntryCount === 1) {
926
+ // If the pattern includes a "star entry" and the tuple includes an
927
+ // indeterminate-length entry that aligns to the star entry, we can
928
+ // assume it will always match.
929
+ if (patternStarEntryIndex !== undefined &&
930
+ tupleIndeterminateIndex >= 0 &&
931
+ pattern.d.entries.length - 1 === tupleDeterminateEntryCount &&
932
+ patternStarEntryIndex === tupleIndeterminateIndex) {
895
933
  isPotentialNoMatch = false;
896
934
  }
897
935
  for (let i = 0; i < patternEntryCount; i++) {
898
- const subPattern = pattern.entries[i];
936
+ const subPattern = pattern.d.entries[i];
899
937
  const typeArg = typeArgs[i].type;
900
938
  const narrowedType = narrowTypeBasedOnPattern(evaluator, typeArg, subPattern,
901
939
  /* isPositiveTest */ true);
@@ -935,7 +973,7 @@ function getSequencePatternInfo(evaluator, pattern, type) {
935
973
  if (i === patternStarEntryIndex) {
936
974
  continue;
937
975
  }
938
- const subPattern = pattern.entries[i];
976
+ const subPattern = pattern.d.entries[i];
939
977
  const typeArg = typeArgs[i].type;
940
978
  const narrowedType = narrowTypeBasedOnPattern(evaluator, typeArg, subPattern,
941
979
  /* isPositiveTest */ true);
@@ -958,8 +996,8 @@ function getSequencePatternInfo(evaluator, pattern, type) {
958
996
  sequenceInfo.push({
959
997
  subtype,
960
998
  entryTypes: [
961
- specializedSequence.typeArguments && specializedSequence.typeArguments.length > 0
962
- ? specializedSequence.typeArguments[0]
999
+ specializedSequence.priv.typeArguments && specializedSequence.priv.typeArguments.length > 0
1000
+ ? specializedSequence.priv.typeArguments[0]
963
1001
  : types_1.UnknownType.create(),
964
1002
  ],
965
1003
  isIndeterminateLength: true,
@@ -974,12 +1012,12 @@ function getSequencePatternInfo(evaluator, pattern, type) {
974
1012
  const sequenceType = evaluator.getTypingType(pattern, 'Sequence');
975
1013
  if (sequenceType && (0, types_1.isInstantiableClass)(sequenceType)) {
976
1014
  const sequenceTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(sequenceType));
977
- if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, types_1.ClassType.cloneAsInstance(sequenceType), subtype, sequenceTypeVarContext, (0, parseTreeUtils_1.getTypeVarScopesForNode)(pattern), pattern.start)) {
1015
+ if ((0, constraintSolver_1.addConstraintsForExpectedType)(evaluator, types_1.ClassType.cloneAsInstance(sequenceType), subtype, sequenceTypeVarContext, (0, parseTreeUtils_1.getTypeVarScopesForNode)(pattern), pattern.start)) {
978
1016
  const specializedSequence = (0, typeUtils_1.applySolvedTypeVars)(types_1.ClassType.cloneAsInstantiable(sequenceType), sequenceTypeVarContext);
979
- if (specializedSequence.typeArguments && specializedSequence.typeArguments.length > 0) {
1017
+ if (specializedSequence.priv.typeArguments && specializedSequence.priv.typeArguments.length > 0) {
980
1018
  sequenceInfo.push({
981
1019
  subtype,
982
- entryTypes: [specializedSequence.typeArguments[0]],
1020
+ entryTypes: [specializedSequence.priv.typeArguments[0]],
983
1021
  isIndeterminateLength: true,
984
1022
  isDefiniteNoMatch: false,
985
1023
  isPotentialNoMatch: true,
@@ -1026,7 +1064,16 @@ function getTypeOfPatternSequenceEntry(evaluator, node, sequenceInfo, entryIndex
1026
1064
  // Note that we strip literal types here.
1027
1065
  const starEntryTypes = sequenceInfo.entryTypes
1028
1066
  .slice(starEntryIndex, starEntryIndex + sequenceInfo.entryTypes.length - entryCount + 1)
1029
- .map((type) => evaluator.stripLiteralValue(type));
1067
+ .map((type) => {
1068
+ // If this is a variadic TypeVar, there's not much we can say about
1069
+ // its type other than it's "Unknown". We could evaluate it as an
1070
+ // "object", but that will cause problems given that this type will
1071
+ // be wrapped in a "list" below, and lists are invariant.
1072
+ if ((0, types_1.isVariadicTypeVar)(type) && !type.priv.isVariadicInUnion) {
1073
+ return types_1.UnknownType.create();
1074
+ }
1075
+ return evaluator.stripLiteralValue(type);
1076
+ });
1030
1077
  let entryType = (0, types_1.combineTypes)(starEntryTypes);
1031
1078
  if (!unpackStarEntry) {
1032
1079
  entryType = wrapTypeInList(evaluator, node, entryType);
@@ -1047,19 +1094,19 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1047
1094
  switch (pattern.nodeType) {
1048
1095
  case 65 /* ParseNodeType.PatternSequence */: {
1049
1096
  const sequenceInfo = getSequencePatternInfo(evaluator, pattern, narrowedType).filter((seqInfo) => !seqInfo.isDefiniteNoMatch);
1050
- pattern.entries.forEach((entry, index) => {
1051
- const entryType = (0, types_1.combineTypes)(sequenceInfo.map((info) => getTypeOfPatternSequenceEntry(evaluator, pattern, info, index, pattern.entries.length, pattern.starEntryIndex,
1097
+ pattern.d.entries.forEach((entry, index) => {
1098
+ const entryType = (0, types_1.combineTypes)(sequenceInfo.map((info) => getTypeOfPatternSequenceEntry(evaluator, pattern, info, index, pattern.d.entries.length, pattern.d.starEntryIndex,
1052
1099
  /* unpackStarEntry */ false)));
1053
1100
  assignTypeToPatternTargets(evaluator, entryType, isTypeIncomplete, entry);
1054
1101
  });
1055
1102
  break;
1056
1103
  }
1057
1104
  case 66 /* ParseNodeType.PatternAs */: {
1058
- if (pattern.target) {
1059
- evaluator.assignTypeToExpression(pattern.target, { type: narrowedType, isIncomplete: isTypeIncomplete }, pattern.target);
1105
+ if (pattern.d.target) {
1106
+ evaluator.assignTypeToExpression(pattern.d.target, { type: narrowedType, isIncomplete: isTypeIncomplete }, pattern.d.target);
1060
1107
  }
1061
1108
  let runningNarrowedType = narrowedType;
1062
- pattern.orPatterns.forEach((orPattern) => {
1109
+ pattern.d.orPatterns.forEach((orPattern) => {
1063
1110
  assignTypeToPatternTargets(evaluator, runningNarrowedType, isTypeIncomplete, orPattern);
1064
1111
  // OR patterns are evaluated left to right, so we can narrow
1065
1112
  // the type as we go.
@@ -1069,10 +1116,10 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1069
1116
  break;
1070
1117
  }
1071
1118
  case 69 /* ParseNodeType.PatternCapture */: {
1072
- if (pattern.isWildcard) {
1119
+ if (pattern.d.isWildcard) {
1073
1120
  if (!isTypeIncomplete) {
1074
1121
  if ((0, types_1.isUnknown)(narrowedType)) {
1075
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.LocMessage.wildcardPatternTypeUnknown(), pattern.target);
1122
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.LocMessage.wildcardPatternTypeUnknown(), pattern.d.target);
1076
1123
  }
1077
1124
  else if ((0, typeUtils_1.isPartlyUnknown)(narrowedType)) {
1078
1125
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
@@ -1080,24 +1127,24 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1080
1127
  name: '_',
1081
1128
  type: evaluator.printType(narrowedType, { expandTypeAlias: true }),
1082
1129
  }));
1083
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.LocMessage.wildcardPatternTypePartiallyUnknown() + diagAddendum.getString(), pattern.target);
1130
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.LocMessage.wildcardPatternTypePartiallyUnknown() + diagAddendum.getString(), pattern.d.target);
1084
1131
  }
1085
1132
  }
1086
1133
  }
1087
1134
  else {
1088
- evaluator.assignTypeToExpression(pattern.target, { type: narrowedType, isIncomplete: isTypeIncomplete }, pattern.target);
1135
+ evaluator.assignTypeToExpression(pattern.d.target, { type: narrowedType, isIncomplete: isTypeIncomplete }, pattern.d.target);
1089
1136
  }
1090
1137
  break;
1091
1138
  }
1092
1139
  case 70 /* ParseNodeType.PatternMapping */: {
1093
1140
  const mappingInfo = getMappingPatternInfo(evaluator, narrowedType, pattern);
1094
- pattern.entries.forEach((mappingEntry) => {
1141
+ pattern.d.entries.forEach((mappingEntry) => {
1095
1142
  const keyTypes = [];
1096
1143
  const valueTypes = [];
1097
1144
  mappingInfo.forEach((mappingSubtypeInfo) => {
1098
1145
  if (mappingSubtypeInfo.typedDict) {
1099
1146
  if (mappingEntry.nodeType === 71 /* ParseNodeType.PatternMappingKeyEntry */) {
1100
- const keyType = narrowTypeBasedOnPattern(evaluator, evaluator.getBuiltInObject(pattern, 'str'), mappingEntry.keyPattern,
1147
+ const keyType = narrowTypeBasedOnPattern(evaluator, evaluator.getBuiltInObject(pattern, 'str'), mappingEntry.d.keyPattern,
1101
1148
  /* isPositiveTest */ true);
1102
1149
  keyTypes.push(keyType);
1103
1150
  (0, typeUtils_1.doForEachSubtype)(keyType, (keySubtype) => {
@@ -1105,7 +1152,7 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1105
1152
  types_1.ClassType.isBuiltIn(keySubtype, 'str') &&
1106
1153
  (0, typeUtils_1.isLiteralType)(keySubtype)) {
1107
1154
  const tdEntries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluator, mappingSubtypeInfo.typedDict);
1108
- const valueInfo = tdEntries.knownItems.get(keySubtype.literalValue);
1155
+ const valueInfo = tdEntries.knownItems.get(keySubtype.priv.literalValue);
1109
1156
  valueTypes.push(valueInfo ? valueInfo.valueType : types_1.UnknownType.create());
1110
1157
  }
1111
1158
  else {
@@ -1115,15 +1162,15 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1115
1162
  }
1116
1163
  else if (mappingEntry.nodeType === 72 /* ParseNodeType.PatternMappingExpandEntry */) {
1117
1164
  keyTypes.push(evaluator.getBuiltInObject(pattern, 'str'));
1118
- valueTypes.push(types_1.UnknownType.create());
1165
+ valueTypes.push(evaluator.getObjectType());
1119
1166
  }
1120
1167
  }
1121
1168
  else if (mappingSubtypeInfo.dictTypeArgs) {
1122
1169
  if (mappingEntry.nodeType === 71 /* ParseNodeType.PatternMappingKeyEntry */) {
1123
- const keyType = narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.key, mappingEntry.keyPattern,
1170
+ const keyType = narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.key, mappingEntry.d.keyPattern,
1124
1171
  /* isPositiveTest */ true);
1125
1172
  keyTypes.push(keyType);
1126
- valueTypes.push(narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.value, mappingEntry.valuePattern,
1173
+ valueTypes.push(narrowTypeBasedOnPattern(evaluator, mappingSubtypeInfo.dictTypeArgs.value, mappingEntry.d.valuePattern,
1127
1174
  /* isPositiveTest */ true));
1128
1175
  }
1129
1176
  else if (mappingEntry.nodeType === 72 /* ParseNodeType.PatternMappingExpandEntry */) {
@@ -1135,8 +1182,8 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1135
1182
  const keyType = (0, types_1.combineTypes)(keyTypes);
1136
1183
  const valueType = (0, types_1.combineTypes)(valueTypes);
1137
1184
  if (mappingEntry.nodeType === 71 /* ParseNodeType.PatternMappingKeyEntry */) {
1138
- assignTypeToPatternTargets(evaluator, keyType, isTypeIncomplete, mappingEntry.keyPattern);
1139
- assignTypeToPatternTargets(evaluator, valueType, isTypeIncomplete, mappingEntry.valuePattern);
1185
+ assignTypeToPatternTargets(evaluator, keyType, isTypeIncomplete, mappingEntry.d.keyPattern);
1186
+ assignTypeToPatternTargets(evaluator, valueType, isTypeIncomplete, mappingEntry.d.valuePattern);
1140
1187
  }
1141
1188
  else if (mappingEntry.nodeType === 72 /* ParseNodeType.PatternMappingExpandEntry */) {
1142
1189
  const dictClass = evaluator.getBuiltInType(pattern, 'dict');
@@ -1145,19 +1192,19 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1145
1192
  ? types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(dictClass, [keyType, valueType],
1146
1193
  /* isTypeArgumentExplicit */ true))
1147
1194
  : types_1.UnknownType.create();
1148
- evaluator.assignTypeToExpression(mappingEntry.target, { type: dictType, isIncomplete: isTypeIncomplete }, mappingEntry.target);
1195
+ evaluator.assignTypeToExpression(mappingEntry.d.target, { type: dictType, isIncomplete: isTypeIncomplete }, mappingEntry.d.target);
1149
1196
  }
1150
1197
  });
1151
1198
  break;
1152
1199
  }
1153
1200
  case 68 /* ParseNodeType.PatternClass */: {
1154
- const argTypes = pattern.arguments.map((arg) => []);
1201
+ const argTypes = pattern.d.args.map((arg) => []);
1155
1202
  evaluator.mapSubtypesExpandTypeVars(narrowedType, /* options */ undefined, (expandedSubtype) => {
1156
1203
  if ((0, types_1.isClassInstance)(expandedSubtype)) {
1157
1204
  (0, typeUtils_1.doForEachSubtype)(narrowedType, (subjectSubtype) => {
1158
1205
  const concreteSubtype = evaluator.makeTopLevelTypeVarsConcrete(subjectSubtype);
1159
1206
  if ((0, types_1.isAnyOrUnknown)(concreteSubtype)) {
1160
- pattern.arguments.forEach((arg, index) => {
1207
+ pattern.d.args.forEach((arg, index) => {
1161
1208
  argTypes[index].push(concreteSubtype);
1162
1209
  });
1163
1210
  }
@@ -1165,10 +1212,10 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1165
1212
  // Are there any positional arguments? If so, try to get the mappings for
1166
1213
  // these arguments by fetching the __match_args__ symbol from the class.
1167
1214
  let positionalArgNames = [];
1168
- if (pattern.arguments.some((arg) => !arg.name)) {
1215
+ if (pattern.d.args.some((arg) => !arg.d.name)) {
1169
1216
  positionalArgNames = getPositionalMatchArgNames(evaluator, types_1.ClassType.cloneAsInstantiable(expandedSubtype));
1170
1217
  }
1171
- pattern.arguments.forEach((arg, index) => {
1218
+ pattern.d.args.forEach((arg, index) => {
1172
1219
  const narrowedArgType = narrowTypeOfClassPatternArgument(evaluator, arg, index, positionalArgNames, types_1.ClassType.cloneAsInstantiable(expandedSubtype),
1173
1220
  /* isPositiveTest */ true);
1174
1221
  argTypes[index].push(narrowedArgType);
@@ -1177,14 +1224,14 @@ function assignTypeToPatternTargets(evaluator, type, isTypeIncomplete, pattern)
1177
1224
  });
1178
1225
  }
1179
1226
  else {
1180
- pattern.arguments.forEach((arg, index) => {
1227
+ pattern.d.args.forEach((arg, index) => {
1181
1228
  argTypes[index].push(types_1.UnknownType.create());
1182
1229
  });
1183
1230
  }
1184
1231
  return undefined;
1185
1232
  });
1186
- pattern.arguments.forEach((arg, index) => {
1187
- assignTypeToPatternTargets(evaluator, (0, types_1.combineTypes)(argTypes[index]), isTypeIncomplete, arg.pattern);
1233
+ pattern.d.args.forEach((arg, index) => {
1234
+ assignTypeToPatternTargets(evaluator, (0, types_1.combineTypes)(argTypes[index]), isTypeIncomplete, arg.d.pattern);
1188
1235
  });
1189
1236
  break;
1190
1237
  }
@@ -1213,55 +1260,56 @@ function wrapTypeInList(evaluator, node, type) {
1213
1260
  return types_1.UnknownType.create();
1214
1261
  }
1215
1262
  function validateClassPattern(evaluator, pattern) {
1216
- let exprType = evaluator.getTypeOfExpression(pattern.className, 2 /* EvaluatorFlags.CallBaseDefaults */).type;
1263
+ var _a, _b;
1264
+ let exprType = evaluator.getTypeOfExpression(pattern.d.className, 2 /* EvalFlags.CallBaseDefaults */).type;
1217
1265
  // If the expression is a type alias or other special form, treat it
1218
1266
  // as the special form rather than the class.
1219
- if (exprType.specialForm) {
1220
- exprType = exprType.specialForm;
1267
+ if ((_a = exprType.props) === null || _a === void 0 ? void 0 : _a.specialForm) {
1268
+ exprType = exprType.props.specialForm;
1221
1269
  }
1222
1270
  if ((0, types_1.isAnyOrUnknown)(exprType)) {
1223
1271
  return;
1224
1272
  }
1225
1273
  // Check for certain uses of type aliases that generate runtime exceptions.
1226
- if (exprType.typeAliasInfo &&
1274
+ if (((_b = exprType.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo) &&
1227
1275
  (0, types_1.isInstantiableClass)(exprType) &&
1228
- exprType.typeArguments &&
1229
- exprType.isTypeArgumentExplicit) {
1230
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.classPatternTypeAlias().format({ type: evaluator.printType(exprType) }), pattern.className);
1276
+ exprType.priv.typeArguments &&
1277
+ exprType.priv.isTypeArgumentExplicit) {
1278
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.classPatternTypeAlias().format({ type: evaluator.printType(exprType) }), pattern.d.className);
1231
1279
  }
1232
1280
  else if (!(0, types_1.isInstantiableClass)(exprType)) {
1233
1281
  if (!(0, types_1.isNever)(exprType)) {
1234
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocAddendum.typeNotClass().format({ type: evaluator.printType(exprType) }), pattern.className);
1282
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocAddendum.typeNotClass().format({ type: evaluator.printType(exprType) }), pattern.d.className);
1235
1283
  }
1236
1284
  }
1237
1285
  else {
1238
1286
  const isBuiltIn = isClassSpecialCaseForClassPattern(exprType);
1239
1287
  // If it's a special-case builtin class, only positional arguments are allowed.
1240
1288
  if (isBuiltIn) {
1241
- if (pattern.arguments.length === 1 && pattern.arguments[0].name) {
1242
- evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.classPatternBuiltInArgPositional(), pattern.arguments[0].name);
1289
+ if (pattern.d.args.length === 1 && pattern.d.args[0].d.name) {
1290
+ evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.classPatternBuiltInArgPositional(), pattern.d.args[0].d.name);
1243
1291
  }
1244
1292
  }
1245
1293
  // Emits an error if the supplied number of positional patterns is less than
1246
1294
  // expected for the given subject type.
1247
- let positionalPatternCount = pattern.arguments.findIndex((arg) => arg.name !== undefined);
1295
+ let positionalPatternCount = pattern.d.args.findIndex((arg) => arg.d.name !== undefined);
1248
1296
  if (positionalPatternCount < 0) {
1249
- positionalPatternCount = pattern.arguments.length;
1297
+ positionalPatternCount = pattern.d.args.length;
1250
1298
  }
1251
1299
  let expectedPatternCount = 1;
1252
1300
  if (!isBuiltIn) {
1253
1301
  let positionalArgNames = [];
1254
- if (pattern.arguments.some((arg) => !arg.name)) {
1302
+ if (pattern.d.args.some((arg) => !arg.d.name)) {
1255
1303
  positionalArgNames = getPositionalMatchArgNames(evaluator, exprType);
1256
1304
  }
1257
1305
  expectedPatternCount = positionalArgNames.length;
1258
1306
  }
1259
1307
  if (positionalPatternCount > expectedPatternCount) {
1260
1308
  evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.classPatternPositionalArgCount().format({
1261
- type: exprType.details.name,
1309
+ type: exprType.shared.name,
1262
1310
  expected: expectedPatternCount,
1263
1311
  received: positionalPatternCount,
1264
- }), pattern.arguments[expectedPatternCount]);
1312
+ }), pattern.d.args[expectedPatternCount]);
1265
1313
  }
1266
1314
  }
1267
1315
  }
@@ -1274,22 +1322,22 @@ function getPatternSubtypeNarrowingCallback(evaluator, reference, subjectExpress
1274
1322
  // <literal> is either a str (for TypedDict discrimination) or an int
1275
1323
  // (for tuple discrimination).
1276
1324
  if (subjectExpression.nodeType === 27 /* ParseNodeType.Index */ &&
1277
- subjectExpression.items.length === 1 &&
1278
- !subjectExpression.trailingComma &&
1279
- subjectExpression.items[0].argumentCategory === 0 /* ArgumentCategory.Simple */ &&
1280
- (0, parseTreeUtils_1.isMatchingExpression)(reference, subjectExpression.baseExpression)) {
1281
- const indexTypeResult = evaluator.getTypeOfExpression(subjectExpression.items[0].valueExpression);
1325
+ subjectExpression.d.items.length === 1 &&
1326
+ !subjectExpression.d.trailingComma &&
1327
+ subjectExpression.d.items[0].d.argCategory === 0 /* ArgumentCategory.Simple */ &&
1328
+ (0, parseTreeUtils_1.isMatchingExpression)(reference, subjectExpression.d.leftExpr)) {
1329
+ const indexTypeResult = evaluator.getTypeOfExpression(subjectExpression.d.items[0].d.valueExpr);
1282
1330
  const indexType = indexTypeResult.type;
1283
1331
  if ((0, types_1.isClassInstance)(indexType) && (0, typeUtils_1.isLiteralType)(indexType)) {
1284
1332
  if (types_1.ClassType.isBuiltIn(indexType, ['int', 'str'])) {
1285
- const unnarrowedReferenceTypeResult = evaluator.getTypeOfExpression(subjectExpression.baseExpression, 2 /* EvaluatorFlags.CallBaseDefaults */);
1333
+ const unnarrowedReferenceTypeResult = evaluator.getTypeOfExpression(subjectExpression.d.leftExpr, 2 /* EvalFlags.CallBaseDefaults */);
1286
1334
  const unnarrowedReferenceType = unnarrowedReferenceTypeResult.type;
1287
1335
  return (narrowedSubjectType) => {
1288
1336
  let canNarrow = true;
1289
1337
  const typesToCombine = [];
1290
1338
  (0, typeUtils_1.doForEachSubtype)(narrowedSubjectType, (subtype) => {
1291
1339
  subtype = evaluator.makeTopLevelTypeVarsConcrete(subtype);
1292
- if ((0, types_1.isClassInstance)(subtype) && subtype.literalValue !== undefined) {
1340
+ if ((0, types_1.isClassInstance)(subtype) && subtype.priv.literalValue !== undefined) {
1293
1341
  if (types_1.ClassType.isBuiltIn(indexType, 'str')) {
1294
1342
  typesToCombine.push((0, typeGuards_1.narrowTypeForDiscriminatedDictEntryComparison)(evaluator, unnarrowedReferenceType, indexType, subtype,
1295
1343
  /* isPositiveTest */ true));
@@ -1318,19 +1366,19 @@ function getPatternSubtypeNarrowingCallback(evaluator, reference, subjectExpress
1318
1366
  // Look for a subject expression that contains the reference
1319
1367
  // expression as an entry in a tuple.
1320
1368
  if (subjectExpression.nodeType === 52 /* ParseNodeType.Tuple */) {
1321
- const matchingEntryIndex = subjectExpression.expressions.findIndex((expr) => (0, parseTreeUtils_1.isMatchingExpression)(reference, expr));
1369
+ const matchingEntryIndex = subjectExpression.d.items.findIndex((expr) => (0, parseTreeUtils_1.isMatchingExpression)(reference, expr));
1322
1370
  if (matchingEntryIndex >= 0) {
1323
- const typeResult = evaluator.getTypeOfExpression(subjectExpression.expressions[matchingEntryIndex]);
1371
+ const typeResult = evaluator.getTypeOfExpression(subjectExpression.d.items[matchingEntryIndex]);
1324
1372
  return (narrowedSubjectType) => {
1325
1373
  let canNarrow = true;
1326
1374
  const narrowedSubtypes = [];
1327
1375
  (0, typeUtils_1.doForEachSubtype)(narrowedSubjectType, (subtype) => {
1328
1376
  if ((0, types_1.isClassInstance)(subtype) &&
1329
1377
  types_1.ClassType.isBuiltIn(subtype, 'tuple') &&
1330
- subtype.tupleTypeArguments &&
1331
- matchingEntryIndex < subtype.tupleTypeArguments.length &&
1332
- subtype.tupleTypeArguments.every((e) => !e.isUnbounded)) {
1333
- narrowedSubtypes.push(subtype.tupleTypeArguments[matchingEntryIndex].type);
1378
+ subtype.priv.tupleTypeArguments &&
1379
+ matchingEntryIndex < subtype.priv.tupleTypeArguments.length &&
1380
+ subtype.priv.tupleTypeArguments.every((e) => !e.isUnbounded)) {
1381
+ narrowedSubtypes.push(subtype.priv.tupleTypeArguments[matchingEntryIndex].type);
1334
1382
  }
1335
1383
  else if ((0, types_1.isNever)(narrowedSubjectType)) {
1336
1384
  narrowedSubtypes.push(narrowedSubjectType);
@@ -1348,8 +1396,8 @@ function getPatternSubtypeNarrowingCallback(evaluator, reference, subjectExpress
1348
1396
  // Look for a subject expression of the form "a.b" where "b" is an attribute
1349
1397
  // that is annotated with a literal type.
1350
1398
  if (subjectExpression.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
1351
- (0, parseTreeUtils_1.isMatchingExpression)(reference, subjectExpression.leftExpression)) {
1352
- const unnarrowedReferenceTypeResult = evaluator.getTypeOfExpression(subjectExpression.leftExpression, 2 /* EvaluatorFlags.CallBaseDefaults */);
1399
+ (0, parseTreeUtils_1.isMatchingExpression)(reference, subjectExpression.d.leftExpr)) {
1400
+ const unnarrowedReferenceTypeResult = evaluator.getTypeOfExpression(subjectExpression.d.leftExpr, 2 /* EvalFlags.CallBaseDefaults */);
1353
1401
  const unnarrowedReferenceType = unnarrowedReferenceTypeResult.type;
1354
1402
  return (narrowedSubjectType) => {
1355
1403
  if ((0, types_1.isNever)(narrowedSubjectType)) {
@@ -1359,8 +1407,8 @@ function getPatternSubtypeNarrowingCallback(evaluator, reference, subjectExpress
1359
1407
  return undefined;
1360
1408
  }
1361
1409
  const resultType = (0, typeUtils_1.mapSubtypes)(narrowedSubjectType, (literalSubtype) => {
1362
- (0, debug_1.assert)((0, types_1.isClassInstance)(literalSubtype) && literalSubtype.literalValue !== undefined);
1363
- return (0, typeGuards_1.narrowTypeForDiscriminatedLiteralFieldComparison)(evaluator, unnarrowedReferenceType, subjectExpression.memberName.value, literalSubtype,
1410
+ (0, debug_1.assert)((0, types_1.isClassInstance)(literalSubtype) && literalSubtype.priv.literalValue !== undefined);
1411
+ return (0, typeGuards_1.narrowTypeForDiscriminatedLiteralFieldComparison)(evaluator, unnarrowedReferenceType, subjectExpression.d.member.d.value, literalSubtype,
1364
1412
  /* isPositiveTest */ true);
1365
1413
  });
1366
1414
  return {