@zzzen/pyright-internal 1.2.0-dev.20240915 → 1.2.0-dev.20240922

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 (58) hide show
  1. package/dist/analyzer/checker.js +2 -6
  2. package/dist/analyzer/checker.js.map +1 -1
  3. package/dist/analyzer/codeFlowEngine.js +21 -3
  4. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  5. package/dist/analyzer/constraintSolver.js +5 -20
  6. package/dist/analyzer/constraintSolver.js.map +1 -1
  7. package/dist/analyzer/constraintTracker.d.ts +0 -4
  8. package/dist/analyzer/constraintTracker.js +0 -21
  9. package/dist/analyzer/constraintTracker.js.map +1 -1
  10. package/dist/analyzer/constructors.js +0 -1
  11. package/dist/analyzer/constructors.js.map +1 -1
  12. package/dist/analyzer/protocols.js +2 -2
  13. package/dist/analyzer/protocols.js.map +1 -1
  14. package/dist/analyzer/service.d.ts +1 -2
  15. package/dist/analyzer/service.js +16 -19
  16. package/dist/analyzer/service.js.map +1 -1
  17. package/dist/analyzer/typeEvaluator.js +65 -42
  18. package/dist/analyzer/typeEvaluator.js.map +1 -1
  19. package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -1
  20. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  21. package/dist/analyzer/typeGuards.js +7 -3
  22. package/dist/analyzer/typeGuards.js.map +1 -1
  23. package/dist/backgroundAnalysisBase.js +2 -1
  24. package/dist/backgroundAnalysisBase.js.map +1 -1
  25. package/dist/common/commandLineOptions.d.ts +1 -0
  26. package/dist/common/commandLineOptions.js.map +1 -1
  27. package/dist/languageService/analyzerServiceExecutor.js +1 -1
  28. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  29. package/dist/languageService/hoverProvider.d.ts +1 -1
  30. package/dist/languageService/hoverProvider.js +9 -10
  31. package/dist/languageService/hoverProvider.js.map +1 -1
  32. package/dist/localization/package.nls.cs.json +2 -0
  33. package/dist/localization/package.nls.de.json +2 -0
  34. package/dist/localization/package.nls.es.json +2 -0
  35. package/dist/localization/package.nls.fr.json +2 -0
  36. package/dist/localization/package.nls.it.json +2 -0
  37. package/dist/localization/package.nls.ja.json +2 -0
  38. package/dist/localization/package.nls.ko.json +2 -0
  39. package/dist/localization/package.nls.pl.json +2 -0
  40. package/dist/localization/package.nls.pt-br.json +2 -0
  41. package/dist/localization/package.nls.qps-ploc.json +2 -0
  42. package/dist/localization/package.nls.ru.json +2 -0
  43. package/dist/localization/package.nls.tr.json +49 -47
  44. package/dist/localization/package.nls.zh-cn.json +2 -0
  45. package/dist/localization/package.nls.zh-tw.json +2 -0
  46. package/dist/parser/unicode.js +136 -8
  47. package/dist/parser/unicode.js.map +1 -1
  48. package/dist/tests/config.test.js +40 -3
  49. package/dist/tests/config.test.js.map +1 -1
  50. package/dist/tests/typeEvaluator2.test.js +4 -0
  51. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  52. package/dist/tests/typeEvaluator3.test.js +4 -0
  53. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  54. package/dist/tests/typeEvaluator7.test.js +4 -0
  55. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  56. package/dist/workspaceFactory.js +1 -1
  57. package/dist/workspaceFactory.js.map +1 -1
  58. package/package.json +1 -1
@@ -209,6 +209,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
209
209
  let intClass;
210
210
  let strClass;
211
211
  let dictClass;
212
+ let moduleTypeClass;
212
213
  let typedDictPrivateClass;
213
214
  let supportsKeysAndGetItemClass;
214
215
  let mappingClass;
@@ -490,6 +491,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
490
491
  intClass = getBuiltInType(node, 'int');
491
492
  strClass = getBuiltInType(node, 'str');
492
493
  dictClass = getBuiltInType(node, 'dict');
494
+ moduleTypeClass = getTypingType(node, 'ModuleType');
493
495
  typedDictPrivateClass = getTypingType(node, '_TypedDict');
494
496
  awaitableClass = getTypingType(node, 'Awaitable');
495
497
  mappingClass = getTypingType(node, 'Mapping');
@@ -1724,6 +1726,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1724
1726
  function getDeclaredTypeForExpression(expression, usage) {
1725
1727
  var _a, _b;
1726
1728
  let symbol;
1729
+ let selfType;
1727
1730
  let classOrObjectBase;
1728
1731
  let memberAccessClass;
1729
1732
  let bindFunction = true;
@@ -1756,11 +1759,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1756
1759
  return getDeclaredTypeForExpression(expression.d.valueExpr, usage);
1757
1760
  }
1758
1761
  case 35 /* ParseNodeType.MemberAccess */: {
1759
- const baseType = makeTopLevelTypeVarsConcrete(getTypeOfExpression(expression.d.leftExpr, 2 /* EvalFlags.MemberAccessBaseDefaults */).type);
1762
+ const baseType = getTypeOfExpression(expression.d.leftExpr, 2 /* EvalFlags.MemberAccessBaseDefaults */).type;
1763
+ const baseTypeConcrete = makeTopLevelTypeVarsConcrete(baseType);
1760
1764
  let classMemberInfo;
1761
- if ((0, types_1.isClassInstance)(baseType)) {
1762
- classMemberInfo = (0, typeUtils_1.lookUpObjectMember)(baseType, expression.d.member.d.value, 64 /* MemberAccessFlags.DeclaredTypesOnly */);
1763
- classOrObjectBase = baseType;
1765
+ if ((0, types_1.isClassInstance)(baseTypeConcrete)) {
1766
+ classMemberInfo = (0, typeUtils_1.lookUpObjectMember)(baseTypeConcrete, expression.d.member.d.value, 64 /* MemberAccessFlags.DeclaredTypesOnly */);
1767
+ classOrObjectBase = baseTypeConcrete;
1764
1768
  memberAccessClass = classMemberInfo === null || classMemberInfo === void 0 ? void 0 : classMemberInfo.classType;
1765
1769
  // If this is an instance member (e.g. a dataclass field), don't
1766
1770
  // bind it to the object if it's a function.
@@ -1769,11 +1773,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1769
1773
  }
1770
1774
  useDescriptorSetterType = true;
1771
1775
  }
1772
- else if ((0, types_1.isInstantiableClass)(baseType)) {
1773
- classMemberInfo = (0, typeUtils_1.lookUpClassMember)(baseType, expression.d.member.d.value, 16 /* MemberAccessFlags.SkipInstanceMembers */ | 64 /* MemberAccessFlags.DeclaredTypesOnly */);
1774
- classOrObjectBase = baseType;
1776
+ else if ((0, types_1.isInstantiableClass)(baseTypeConcrete)) {
1777
+ classMemberInfo = (0, typeUtils_1.lookUpClassMember)(baseTypeConcrete, expression.d.member.d.value, 16 /* MemberAccessFlags.SkipInstanceMembers */ | 64 /* MemberAccessFlags.DeclaredTypesOnly */);
1778
+ classOrObjectBase = baseTypeConcrete;
1775
1779
  memberAccessClass = classMemberInfo === null || classMemberInfo === void 0 ? void 0 : classMemberInfo.classType;
1776
1780
  }
1781
+ if ((0, types_1.isTypeVar)(baseType)) {
1782
+ selfType = baseType;
1783
+ }
1777
1784
  if (classMemberInfo) {
1778
1785
  symbol = classMemberInfo.symbol;
1779
1786
  }
@@ -1814,11 +1821,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1814
1821
  }
1815
1822
  if (classOrObjectBase) {
1816
1823
  if (memberAccessClass && (0, types_1.isInstantiableClass)(memberAccessClass)) {
1817
- declaredType = (0, typeUtils_1.partiallySpecializeType)(declaredType, memberAccessClass, getTypeClassType());
1824
+ declaredType = (0, typeUtils_1.partiallySpecializeType)(declaredType, memberAccessClass, getTypeClassType(), selfType);
1818
1825
  }
1819
1826
  if ((0, types_1.isFunction)(declaredType) || (0, types_1.isOverloaded)(declaredType)) {
1820
1827
  if (bindFunction) {
1821
- declaredType = bindFunctionToClassOrObject(classOrObjectBase, declaredType);
1828
+ declaredType = bindFunctionToClassOrObject(classOrObjectBase, declaredType,
1829
+ /* memberClass */ undefined,
1830
+ /* treatConstructorAsClassMethod */ undefined, selfType);
1822
1831
  }
1823
1832
  }
1824
1833
  }
@@ -3236,13 +3245,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3236
3245
  }
3237
3246
  // If the value is a special form (like a TypeVar or `Any`) and is being
3238
3247
  // evaluated in a value expression context, convert it from its special
3239
- // meaning to its runtime value.
3240
- function convertSpecialFormToRuntimeValue(type, flags) {
3248
+ // meaning to its runtime value. If convertModule is true, a module is
3249
+ // converted to an instance of types.ModuleType.
3250
+ function convertSpecialFormToRuntimeValue(type, flags, convertModule = false) {
3241
3251
  var _a, _b, _c, _d;
3242
3252
  const exemptFlags = 256 /* EvalFlags.TypeExpression */ | 128 /* EvalFlags.InstantiableType */ | 33554432 /* EvalFlags.NoConvertSpecialForm */;
3243
3253
  if ((flags & exemptFlags) !== 0) {
3244
3254
  return type;
3245
3255
  }
3256
+ if (convertModule && (0, types_1.isModule)(type) && moduleTypeClass && (0, types_1.isInstantiableClass)(moduleTypeClass)) {
3257
+ return types_1.ClassType.cloneAsInstance(moduleTypeClass);
3258
+ }
3246
3259
  // Isinstance treats traditional (non-PEP 695) type aliases that are unions
3247
3260
  // as tuples of classes rather than unions.
3248
3261
  if ((flags & 536870912 /* EvalFlags.IsinstanceArg */) !== 0) {
@@ -4270,8 +4283,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4270
4283
  else {
4271
4284
  accessMethodName = '__delete__';
4272
4285
  }
4286
+ const subDiag = diag ? new diagnostic_1.DiagnosticAddendum() : undefined;
4273
4287
  const methodTypeResult = getTypeOfBoundMember(errorNode, concreteMemberType, accessMethodName,
4274
- /* usage */ undefined, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), 16 /* MemberAccessFlags.SkipInstanceMembers */ | 512 /* MemberAccessFlags.SkipAttributeAccessOverride */);
4288
+ /* usage */ undefined, subDiag, 16 /* MemberAccessFlags.SkipInstanceMembers */ | 512 /* MemberAccessFlags.SkipAttributeAccessOverride */);
4275
4289
  if (!methodTypeResult || methodTypeResult.typeErrors) {
4276
4290
  // Provide special error messages for properties.
4277
4291
  if (types_1.ClassType.isPropertyClass(concreteMemberType) && usage.method !== 'get') {
@@ -4287,6 +4301,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4287
4301
  const methodClassType = methodTypeResult.classType;
4288
4302
  let methodType = methodTypeResult.type;
4289
4303
  if (methodTypeResult.typeErrors || !methodClassType) {
4304
+ if (diag && subDiag) {
4305
+ diag.addAddendum(subDiag);
4306
+ }
4290
4307
  return { type: types_1.UnknownType.create(), typeErrors: true };
4291
4308
  }
4292
4309
  if (!(0, types_1.isFunction)(methodType) && !(0, types_1.isOverloaded)(methodType)) {
@@ -5786,7 +5803,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5786
5803
  entryTypes.push({ type: types_1.UnknownType.create(/* isIncomplete */ true), isUnbounded: false });
5787
5804
  }
5788
5805
  else {
5789
- let entryType = convertSpecialFormToRuntimeValue(typeResult.type, 0 /* EvalFlags.None */);
5806
+ let entryType = convertSpecialFormToRuntimeValue(typeResult.type, 0 /* EvalFlags.None */,
5807
+ /* convertModule */ true);
5790
5808
  entryType = stripLiterals ? (0, typeUtils_1.stripTypeForm)(stripLiteralValue(entryType)) : entryType;
5791
5809
  entryTypes.push({ type: entryType, isUnbounded: !!typeResult.unpackedType });
5792
5810
  }
@@ -6403,7 +6421,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
6403
6421
  }
6404
6422
  // Clone the constraints so we don't modify the original.
6405
6423
  const effectiveConstraints = (_a = constraints === null || constraints === void 0 ? void 0 : constraints.clone()) !== null && _a !== void 0 ? _a : new constraintTracker_1.ConstraintTracker();
6406
- effectiveConstraints.unlock();
6407
6424
  // Use speculative mode so we don't output any diagnostics or
6408
6425
  // record any final types in the type cache.
6409
6426
  const callResult = useSpeculativeMode(speculativeNode, () => {
@@ -6515,7 +6532,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
6515
6532
  // And run through the first expanded argument list one more time to
6516
6533
  // populate the type cache.
6517
6534
  const finalConstraints = constraints !== null && constraints !== void 0 ? constraints : matchedOverloads[0].constraints;
6518
- finalConstraints.unlock();
6519
6535
  const finalCallResult = validateArgTypesWithContext(errorNode, matchedOverloads[0].matchResults, finalConstraints, skipUnknownArgCheck, inferenceContext);
6520
6536
  if (finalCallResult.isTypeIncomplete) {
6521
6537
  isTypeIncomplete = true;
@@ -6689,7 +6705,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
6689
6705
  }
6690
6706
  }
6691
6707
  const effectiveConstraints = constraints !== null && constraints !== void 0 ? constraints : new constraintTracker_1.ConstraintTracker();
6692
- effectiveConstraints.unlock();
6693
6708
  return validateArgTypesWithContext(errorNode, bestMatch, effectiveConstraints, skipUnknownArgCheck, inferenceContext);
6694
6709
  }
6695
6710
  // If there is only one possible arg/param match among the overloads,
@@ -7083,7 +7098,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7083
7098
  // The one-parameter form of "type" returns the class
7084
7099
  // for the specified object.
7085
7100
  if (expandedCallType.shared.name === 'type' && argList.length === 1) {
7086
- const argType = getTypeOfArg(argList[0], /* inferenceContext */ undefined).type;
7101
+ const argTypeResult = getTypeOfArg(argList[0], /* inferenceContext */ undefined);
7102
+ const argType = argTypeResult.type;
7087
7103
  const returnType = (0, typeUtils_1.mapSubtypes)(argType, (subtype) => {
7088
7104
  if ((0, types_1.isNever)(subtype)) {
7089
7105
  return subtype;
@@ -7100,7 +7116,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7100
7116
  types_1.UnknownType.create(),
7101
7117
  ]);
7102
7118
  });
7103
- return { returnType };
7119
+ return { returnType, isTypeIncomplete: argTypeResult.isIncomplete };
7104
7120
  }
7105
7121
  if (argList.length >= 2) {
7106
7122
  // The two-parameter form of a call to a metaclass returns a new class
@@ -8391,9 +8407,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8391
8407
  });
8392
8408
  });
8393
8409
  }
8394
- // Lock the type var map so it cannot be modified when revalidating
8395
- // the arguments in a second pass.
8396
- constraints.lock();
8397
8410
  }
8398
8411
  let sawParamSpecArgs = false;
8399
8412
  let sawParamSpecKwargs = false;
@@ -9697,8 +9710,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
9697
9710
  typeErrors = true;
9698
9711
  }
9699
9712
  // Strip any literal values and TypeForm types.
9700
- const keyTypes = keyTypeResults.map((t) => (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(stripLiteralValue(t.type), flags)));
9701
- const valueTypes = valueTypeResults.map((t) => (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(stripLiteralValue(t.type), flags)));
9713
+ const keyTypes = keyTypeResults.map((t) => (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(stripLiteralValue(t.type), flags, /* convertModule */ true)));
9714
+ const valueTypes = valueTypeResults.map((t) => (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(stripLiteralValue(t.type), flags, /* convertModule */ true)));
9702
9715
  keyType = keyTypes.length > 0 ? (0, types_1.combineTypes)(keyTypes) : fallbackType;
9703
9716
  // If the value type differs and we're not using "strict inference mode",
9704
9717
  // we need to back off because we can't properly represent the mappings
@@ -10049,7 +10062,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
10049
10062
  else {
10050
10063
  entryTypeResult = getTypeOfExpression(entry, flags | 268435456 /* EvalFlags.StripTupleLiterals */);
10051
10064
  }
10052
- entryTypeResult.type = (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(entryTypeResult.type, flags));
10065
+ entryTypeResult.type = (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(entryTypeResult.type, flags, /* convertModule */ true));
10053
10066
  if (entryTypeResult.isIncomplete) {
10054
10067
  isIncomplete = true;
10055
10068
  }
@@ -11922,6 +11935,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11922
11935
  function createSubclass(errorNode, type1, type2) {
11923
11936
  var _a, _b;
11924
11937
  (0, debug_1.assert)((0, types_1.isInstantiableClass)(type1) && (0, types_1.isInstantiableClass)(type2));
11938
+ // If both classes are class objects (type[A] and type[B]), create a new
11939
+ // class object (type[A & B]) rather than "type[A] & type[B]".
11940
+ let createClassObject = false;
11941
+ if (types_1.TypeBase.getInstantiableDepth(type1) > 0 && types_1.TypeBase.getInstantiableDepth(type2) > 0) {
11942
+ type1 = types_1.ClassType.cloneAsInstance(type1);
11943
+ type2 = types_1.ClassType.cloneAsInstance(type2);
11944
+ createClassObject = true;
11945
+ }
11925
11946
  const className = `<subclass of ${printType((0, typeUtils_1.convertToInstance)(type1), {
11926
11947
  omitTypeArgsIfUnknown: true,
11927
11948
  })} and ${printType((0, typeUtils_1.convertToInstance)(type2), { omitTypeArgsIfUnknown: true })}>`;
@@ -11939,6 +11960,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11939
11960
  (0, typeUtils_1.computeMroLinearization)(newClassType);
11940
11961
  newClassType = (0, typeUtils_1.addConditionToType)(newClassType, (_a = type1.props) === null || _a === void 0 ? void 0 : _a.condition);
11941
11962
  newClassType = (0, typeUtils_1.addConditionToType)(newClassType, (_b = type2.props) === null || _b === void 0 ? void 0 : _b.condition);
11963
+ if (createClassObject) {
11964
+ newClassType = types_1.ClassType.cloneAsInstantiable(newClassType);
11965
+ }
11942
11966
  return newClassType;
11943
11967
  }
11944
11968
  function getTypeOfClass(node) {
@@ -13384,7 +13408,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13384
13408
  skipInference = true;
13385
13409
  }
13386
13410
  if (!skipInference) {
13387
- inferredParamType = convertSpecialFormToRuntimeValue(defaultValueType, 0 /* EvalFlags.None */);
13411
+ inferredParamType = convertSpecialFormToRuntimeValue(defaultValueType, 0 /* EvalFlags.None */,
13412
+ /* convertModule */ true);
13388
13413
  inferredParamType = (0, typeUtils_1.stripTypeForm)(inferredParamType);
13389
13414
  inferredParamType = stripLiteralValue(inferredParamType);
13390
13415
  }
@@ -14373,7 +14398,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14373
14398
  const typeAnnotation = ParseTreeUtils.getTypeAnnotationForParam(functionNode, paramIndex);
14374
14399
  if (typeAnnotation) {
14375
14400
  const param = functionNode.d.params[paramIndex];
14376
- const annotatedType = getTypeOfParamAnnotation(typeAnnotation, functionNode.d.params[paramIndex].d.category);
14401
+ let annotatedType = getTypeOfParamAnnotation(typeAnnotation, functionNode.d.params[paramIndex].d.category);
14402
+ const liveTypeVarScopes = ParseTreeUtils.getTypeVarScopesForNode(param);
14403
+ annotatedType = (0, typeUtils_1.makeTypeVarsBound)(annotatedType, liveTypeVarScopes);
14377
14404
  const adjType = transformVariadicParamType(node, node.d.category, adjustParamAnnotatedType(param, annotatedType));
14378
14405
  writeTypeCache(node.d.name, { type: adjType }, 0 /* EvalFlags.None */);
14379
14406
  return;
@@ -15420,7 +15447,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15420
15447
  else {
15421
15448
  const synthesizedType = symbol.getSynthesizedType();
15422
15449
  if (synthesizedType) {
15423
- synthesizedTypes.push(synthesizedType);
15450
+ synthesizedTypes.push({ type: synthesizedType, node });
15424
15451
  }
15425
15452
  else {
15426
15453
  (0, collectionUtils_1.appendArray)(declarations, symbol.getDeclarations());
@@ -15509,7 +15536,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15509
15536
  return { decls: declarations, synthesizedTypes };
15510
15537
  }
15511
15538
  function getTypeForDeclaration(declaration) {
15512
- var _a, _b;
15539
+ var _a, _b, _c;
15513
15540
  switch (declaration.type) {
15514
15541
  case 0 /* DeclarationType.Intrinsic */: {
15515
15542
  if (declaration.intrinsicType === 'Any') {
@@ -15570,12 +15597,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15570
15597
  return { type: getTypeOfTypeAlias(declaration.node) };
15571
15598
  }
15572
15599
  case 2 /* DeclarationType.Param */: {
15573
- let typeAnnotationNode = declaration.node.d.annotation || declaration.node.d.annotationComment;
15600
+ let typeAnnotationNode = (_a = declaration.node.d.annotation) !== null && _a !== void 0 ? _a : declaration.node.d.annotationComment;
15574
15601
  // If there wasn't an annotation, see if the parent function
15575
15602
  // has a function-level annotation comment that provides
15576
15603
  // this parameter's annotation type.
15577
15604
  if (!typeAnnotationNode) {
15578
- if (((_a = declaration.node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 31 /* ParseNodeType.Function */) {
15605
+ if (((_b = declaration.node.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 31 /* ParseNodeType.Function */) {
15579
15606
  const functionNode = declaration.node.parent;
15580
15607
  if (functionNode.d.funcAnnotationComment &&
15581
15608
  !functionNode.d.funcAnnotationComment.d.isEllipsis) {
@@ -15609,7 +15636,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15609
15636
  }
15610
15637
  else {
15611
15638
  const declNode = declaration.isDefinedByMemberAccess &&
15612
- ((_b = declaration.node.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 35 /* ParseNodeType.MemberAccess */
15639
+ ((_c = declaration.node.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 35 /* ParseNodeType.MemberAccess */
15613
15640
  ? declaration.node.parent
15614
15641
  : declaration.node;
15615
15642
  declaredType = getTypeOfAnnotation(typeAnnotationNode, {
@@ -16033,7 +16060,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16033
16060
  includesVariableDecl: includesVariableTypeDecl(typedDecls),
16034
16061
  includesIllegalTypeAliasDecl: !typedDecls.every((decl) => isPossibleTypeAliasDeclaration(decl)),
16035
16062
  includesSpeculativeResult: false,
16036
- isRecursiveDefinition: !declaredType,
16063
+ isRecursiveDefinition: !declaredType && !speculativeTypeTracker.isSpeculative(/* node */ undefined),
16037
16064
  };
16038
16065
  return result;
16039
16066
  }
@@ -16572,7 +16599,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16572
16599
  paramType = types_1.UnknownType.create();
16573
16600
  }
16574
16601
  if (stripLiteralArgTypes) {
16575
- paramType = (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(stripLiteralValue(paramType), 0 /* EvalFlags.None */));
16602
+ paramType = (0, typeUtils_1.stripTypeForm)(convertSpecialFormToRuntimeValue(stripLiteralValue(paramType), 0 /* EvalFlags.None */,
16603
+ /* convertModule */ true));
16576
16604
  }
16577
16605
  paramTypes.push(paramType);
16578
16606
  writeTypeCache(param.d.name, { type: paramType }, 0 /* EvalFlags.None */);
@@ -16979,7 +17007,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16979
17007
  // in this case. Adding more information is unnecessary and confusing.
16980
17008
  (flags & 1 /* AssignTypeFlags.Invariant */) === 0 ? diag : undefined, constraints, flags, recursionCount);
16981
17009
  }
16982
- if (constraints && curSrcType.priv.typeArgs && !constraints.isLocked()) {
17010
+ if (constraints && curSrcType.priv.typeArgs) {
16983
17011
  // Populate the typeVar map with type arguments of the source.
16984
17012
  const srcTypeArgs = curSrcType.priv.typeArgs;
16985
17013
  for (let i = 0; i < destType.shared.typeParams.length; i++) {
@@ -17921,9 +17949,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17921
17949
  // Finds unsolved type variables in the destType and establishes constraints
17922
17950
  // in the constraint tracker for them based on the srcType.
17923
17951
  function setConstraintsForFreeTypeVars(destType, srcType, constraints) {
17924
- if (constraints.isLocked()) {
17925
- return;
17926
- }
17927
17952
  const typeVars = (0, typeUtils_1.getTypeVarArgsRecursive)(destType);
17928
17953
  typeVars.forEach((typeVar) => {
17929
17954
  if (!types_1.TypeVarType.isBound(typeVar) && !constraints.getMainConstraintSet().getTypeVar(typeVar)) {
@@ -19519,11 +19544,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
19519
19544
  // contain references to themselves or their subclasses, so if
19520
19545
  // we attempt to call assignType, we'll risk infinite recursion.
19521
19546
  // Instead, we'll assume it's assignable.
19522
- if (!constraints.isLocked()) {
19523
- constraints.setBounds(memberTypeFirstParamType, types_1.TypeBase.isInstantiable(memberTypeFirstParamType)
19524
- ? (0, typeUtils_1.convertToInstance)(firstParamType)
19525
- : firstParamType);
19526
- }
19547
+ constraints.setBounds(memberTypeFirstParamType, types_1.TypeBase.isInstantiable(memberTypeFirstParamType)
19548
+ ? (0, typeUtils_1.convertToInstance)(firstParamType)
19549
+ : firstParamType);
19527
19550
  }
19528
19551
  else {
19529
19552
  const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();