@@ -1851,29 +1851,20 @@ static FunctionType *applyOptionality(ValueDecl *value, FunctionType *fnTy) {
18511851 fnTy->getExtInfo ());
18521852}
18531853
1854- DeclReferenceType ConstraintSystem::getTypeOfMemberReference (
1854+ std::tuple<Type, Type, Type>
1855+ ConstraintSystem::getTypeOfMemberReferenceImpl (
18551856 Type baseTy, ValueDecl *value, DeclContext *useDC, bool isDynamicLookup,
18561857 FunctionRefInfo functionRefInfo, ConstraintLocator *locator,
18571858 SmallVectorImpl<OpenedType> *replacementsPtr,
18581859 PreparedOverloadBuilder *preparedOverload) {
1860+ ASSERT (!isa<TypeDecl>(value));
18591861 ASSERT (!!preparedOverload == PreparingOverload);
18601862 recordFixIfNeededForPlaceholderInDecl (*this , value, locator);
18611863
18621864 // Figure out the instance type used for the base.
18631865 Type baseRValueTy = baseTy->getRValueType ();
18641866 auto baseObjTy = baseRValueTy->getMetatypeInstanceType ();
18651867
1866- // If the base is a module type, just use the type of the decl.
1867- if (baseObjTy->is <ModuleType>()) {
1868- return getTypeOfReference (value, functionRefInfo, locator, useDC,
1869- preparedOverload);
1870- }
1871-
1872- if (auto *typeDecl = dyn_cast<TypeDecl>(value)) {
1873- return getTypeOfMemberTypeReference (baseObjTy, typeDecl,
1874- locator, preparedOverload);
1875- }
1876-
18771868 // Figure out the declaration context to use when opening this type.
18781869 DeclContext *innerDC = value->getInnermostDeclContext ();
18791870 DeclContext *outerDC = value->getDeclContext ();
@@ -1914,7 +1905,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
19141905 isa<MacroDecl>(value)) {
19151906 auto interfaceType = value->getInterfaceType ();
19161907 if (interfaceType->is <ErrorType>() || isa<MacroDecl>(value))
1917- return { interfaceType, interfaceType, interfaceType, interfaceType, Type () };
1908+ return { interfaceType, Type (), baseObjTy };
19181909
19191910 if (outerDC->getSelfClassDecl ()) {
19201911 if (isa<ConstructorDecl>(value)) {
@@ -2030,6 +2021,40 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
20302021 }
20312022 }
20322023
2024+ return { openedType, thrownErrorType, baseObjTy };
2025+ }
2026+
2027+ DeclReferenceType ConstraintSystem::getTypeOfMemberReference (
2028+ Type baseTy, ValueDecl *value, DeclContext *useDC, bool isDynamicLookup,
2029+ FunctionRefInfo functionRefInfo, ConstraintLocator *locator,
2030+ SmallVectorImpl<OpenedType> *replacementsPtr,
2031+ PreparedOverloadBuilder *preparedOverload) {
2032+ ASSERT (!!preparedOverload == PreparingOverload);
2033+
2034+ // Figure out the instance type used for the base.
2035+ Type baseRValueTy = baseTy;
2036+ Type baseObjTy = baseRValueTy->getMetatypeInstanceType ();
2037+
2038+ // If the base is a module type, just use the type of the decl.
2039+ if (baseObjTy->getMetatypeInstanceType ()->is <ModuleType>()) {
2040+ return getTypeOfReference (value, functionRefInfo, locator, useDC,
2041+ preparedOverload);
2042+ }
2043+
2044+ if (auto *typeDecl = dyn_cast<TypeDecl>(value)) {
2045+ return getTypeOfMemberTypeReference (baseObjTy, typeDecl,
2046+ locator, preparedOverload);
2047+ }
2048+
2049+ Type openedType, thrownErrorType;
2050+ std::tie (openedType, thrownErrorType, baseObjTy)
2051+ = getTypeOfMemberReferenceImpl (baseTy, value, useDC,
2052+ isDynamicLookup, functionRefInfo,
2053+ locator, replacementsPtr,
2054+ preparedOverload);
2055+
2056+ auto hasAppliedSelf = doesMemberRefApplyCurriedSelf (baseRValueTy, value);
2057+
20332058 // Adjust the opened type for concurrency.
20342059 Type origOpenedType = openedType;
20352060 if (isRequirementOrWitness (locator)) {
0 commit comments