@@ -2795,7 +2795,7 @@ export function createTypeEvaluator(
2795
2795
case ParseNodeType.MemberAccess: {
2796
2796
const baseType = getTypeOfExpression(expression.d.leftExpr, EvalFlags.MemberAccessBaseDefaults).type;
2797
2797
const baseTypeConcrete = makeTopLevelTypeVarsConcrete(baseType);
2798
- let classMemberInfo: ClassMember | undefined ;
2798
+ const memberName = expression.d.member.d.value ;
2799
2799
2800
2800
// Normally, baseTypeConcrete will not be a composite type (a union),
2801
2801
// but this can occur. In this case, it's not clear how to handle this
@@ -2805,29 +2805,42 @@ export function createTypeEvaluator(
2805
2805
baseTypeConcrete,
2806
2806
(baseSubtype) => {
2807
2807
if (isClassInstance(baseSubtype)) {
2808
- classMemberInfo = lookUpObjectMember(
2808
+ const classMemberInfo = lookUpObjectMember(
2809
2809
baseSubtype,
2810
- expression.d.member.d.value ,
2810
+ memberName ,
2811
2811
MemberAccessFlags.DeclaredTypesOnly
2812
2812
);
2813
+
2813
2814
classOrObjectBase = baseSubtype;
2814
2815
memberAccessClass = classMemberInfo?.classType;
2816
+ symbol = classMemberInfo?.symbol;
2817
+ useDescriptorSetterType = true;
2815
2818
2816
2819
// If this is an instance member (e.g. a dataclass field), don't
2817
2820
// bind it to the object if it's a function.
2818
- if (classMemberInfo?.isInstanceMember) {
2819
- bindFunction = false;
2820
- }
2821
-
2822
- useDescriptorSetterType = true;
2821
+ bindFunction = !classMemberInfo?.isInstanceMember;
2823
2822
} else if (isInstantiableClass(baseSubtype)) {
2824
- classMemberInfo = lookUpClassMember(
2823
+ const classMemberInfo = lookUpClassMember(
2825
2824
baseSubtype,
2826
- expression.d.member.d.value ,
2825
+ memberName ,
2827
2826
MemberAccessFlags.SkipInstanceMembers | MemberAccessFlags.DeclaredTypesOnly
2828
2827
);
2828
+
2829
2829
classOrObjectBase = baseSubtype;
2830
2830
memberAccessClass = classMemberInfo?.classType;
2831
+ symbol = classMemberInfo?.symbol;
2832
+ useDescriptorSetterType = false;
2833
+ bindFunction = true;
2834
+ } else if (isModule(baseSubtype)) {
2835
+ classOrObjectBase = undefined;
2836
+ memberAccessClass = undefined;
2837
+ symbol = ModuleType.getField(baseSubtype, memberName);
2838
+ if (symbol && !symbol.hasTypedDeclarations()) {
2839
+ // Do not use inferred types for the declared type.
2840
+ symbol = undefined;
2841
+ }
2842
+ useDescriptorSetterType = false;
2843
+ bindFunction = false;
2831
2844
}
2832
2845
},
2833
2846
/* sortSubtypes */ true
@@ -2836,10 +2849,6 @@ export function createTypeEvaluator(
2836
2849
if (isTypeVar(baseType)) {
2837
2850
selfType = baseType;
2838
2851
}
2839
-
2840
- if (classMemberInfo) {
2841
- symbol = classMemberInfo.symbol;
2842
- }
2843
2852
break;
2844
2853
}
2845
2854
0 commit comments