@@ -1883,6 +1883,10 @@ ConstraintSystem::getTypeOfMemberReferencePre(
1883
1883
Type baseRValueTy = baseTy->getRValueType ();
1884
1884
auto baseObjTy = baseRValueTy->getMetatypeInstanceType ();
1885
1885
1886
+ if (baseObjTy->is <ModuleType>()) {
1887
+ return getTypeOfReferencePre (choice, useDC, locator, preparedOverload);
1888
+ }
1889
+
1886
1890
Type openedType;
1887
1891
Type thrownErrorType;
1888
1892
@@ -2048,19 +2052,20 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReferencePost(
2048
2052
Type openedType, Type thrownErrorType) {
2049
2053
auto *value = choice.getDecl ();
2050
2054
2051
- if (isa<TypeDecl>(value)) {
2052
- auto type = openedType->castTo <FunctionType>()->getResult ();
2053
- return { openedType, openedType, type, type, Type () };
2054
- }
2055
-
2056
2055
// Figure out the instance type used for the base.
2057
2056
Type baseTy = choice.getBaseType ();
2058
2057
Type baseRValueTy = baseTy->getRValueType ();
2059
2058
Type baseObjTy = baseRValueTy->getMetatypeInstanceType ();
2060
2059
2061
- // A reference to a module member is really unqualified, and should
2062
- // be handled by the caller via getTypeOfReference().
2063
- ASSERT (!baseObjTy->is <ModuleType>());
2060
+ if (baseObjTy->is <ModuleType>()) {
2061
+ return getTypeOfReferencePost (choice, useDC, locator,
2062
+ openedType, thrownErrorType);
2063
+ }
2064
+
2065
+ if (isa<TypeDecl>(value)) {
2066
+ auto type = openedType->castTo <FunctionType>()->getResult ();
2067
+ return { openedType, openedType, type, type, Type () };
2068
+ }
2064
2069
2065
2070
auto hasAppliedSelf = doesMemberRefApplyCurriedSelf (baseRValueTy, value);
2066
2071
@@ -2854,15 +2859,7 @@ ConstraintSystem::prepareOverloadImpl(OverloadChoice choice,
2854
2859
auto openedType = getTypeOfReferenceWithSpecialTypeCheckingSemantics (
2855
2860
*this , locator, semantics, preparedOverload);
2856
2861
return {openedType, Type ()};
2857
- } else if (auto baseTy = choice.getBaseType ()) {
2858
- // Retrieve the type of a reference to the specific declaration choice.
2859
- assert (!baseTy->hasTypeParameter ());
2860
-
2861
- // If the base is a module type, it's an unqualified reference.
2862
- if (baseTy->getMetatypeInstanceType ()->is <ModuleType>()) {
2863
- return getTypeOfReferencePre (choice, useDC, locator, preparedOverload);
2864
- }
2865
-
2862
+ } else if (choice.getBaseType ()) {
2866
2863
return getTypeOfMemberReferencePre (choice, useDC, locator, preparedOverload);
2867
2864
} else {
2868
2865
return getTypeOfReferencePre (choice, useDC, locator, preparedOverload);
@@ -2926,15 +2923,9 @@ void ConstraintSystem::resolveOverload(OverloadChoice choice, DeclContext *useDC
2926
2923
} else {
2927
2924
DeclReferenceType declRefType;
2928
2925
2929
- if (auto baseTy = choice.getBaseType ()) {
2930
- // If the base is a module type, it's an unqualified reference.
2931
- if (baseTy->getMetatypeInstanceType ()->is <ModuleType>()) {
2932
- declRefType = getTypeOfReferencePost (
2933
- choice, useDC, locator, openedType, thrownErrorType);
2934
- } else {
2935
- declRefType = getTypeOfMemberReferencePost (
2936
- choice, useDC, locator, openedType, thrownErrorType);
2937
- }
2926
+ if (choice.getBaseType ()) {
2927
+ declRefType = getTypeOfMemberReferencePost (
2928
+ choice, useDC, locator, openedType, thrownErrorType);
2938
2929
} else {
2939
2930
declRefType = getTypeOfReferencePost (
2940
2931
choice, useDC, locator, openedType, thrownErrorType);
0 commit comments