@@ -1109,10 +1109,10 @@ recordFixIfNeededForPlaceholderInDecl(ConstraintSystem &cs, ValueDecl *D,
11091109}
11101110
11111111std::pair<Type, Type>
1112- ConstraintSystem::getTypeOfReferenceImpl (OverloadChoice choice,
1113- ConstraintLocatorBuilder locator ,
1114- DeclContext *useDC ,
1115- PreparedOverloadBuilder *preparedOverload) {
1112+ ConstraintSystem::getTypeOfReferencePre (OverloadChoice choice,
1113+ DeclContext *useDC ,
1114+ ConstraintLocatorBuilder locator ,
1115+ PreparedOverloadBuilder *preparedOverload) {
11161116 auto *value = choice.getDecl ();
11171117
11181118 ASSERT (!!preparedOverload == PreparingOverload);
@@ -1237,16 +1237,10 @@ ConstraintSystem::getTypeOfReferenceImpl(OverloadChoice choice,
12371237}
12381238
12391239DeclReferenceType
1240- ConstraintSystem::getTypeOfReference (OverloadChoice choice,
1241- ConstraintLocatorBuilder locator,
1242- DeclContext *useDC,
1243- PreparedOverloadBuilder *preparedOverload) {
1244- ASSERT (!!preparedOverload == PreparingOverload);
1245-
1246- Type openedType, thrownErrorType;
1247- std::tie (openedType, thrownErrorType) = getTypeOfReferenceImpl (
1248- choice, locator, useDC, preparedOverload);
1249-
1240+ ConstraintSystem::getTypeOfReferencePost (OverloadChoice choice,
1241+ DeclContext *useDC,
1242+ ConstraintLocatorBuilder locator,
1243+ Type openedType, Type thrownErrorType) {
12501244 auto *value = choice.getDecl ();
12511245
12521246 if (value->getDeclContext ()->isTypeContext () && isa<FuncDecl>(value)) {
@@ -1331,7 +1325,24 @@ ConstraintSystem::getTypeOfReference(OverloadChoice choice,
13311325 ClosureIsolatedByPreconcurrency{*this });
13321326 }
13331327
1334- return { origOpenedType, openedType, origOpenedType, openedType, thrownErrorType };
1328+ return { origOpenedType, openedType,
1329+ origOpenedType, openedType,
1330+ thrownErrorType };
1331+ }
1332+
1333+ DeclReferenceType
1334+ ConstraintSystem::getTypeOfReference (OverloadChoice choice,
1335+ DeclContext *useDC,
1336+ ConstraintLocatorBuilder locator,
1337+ PreparedOverloadBuilder *preparedOverload) {
1338+ ASSERT (!!preparedOverload == PreparingOverload);
1339+
1340+ Type openedType, thrownErrorType;
1341+ std::tie (openedType, thrownErrorType) = getTypeOfReferencePre (
1342+ choice, useDC, locator, preparedOverload);
1343+
1344+ return getTypeOfReferencePost (choice, useDC, locator,
1345+ openedType, thrownErrorType);
13351346}
13361347
13371348// / Bind type variables for archetypes that are determined from
@@ -1856,7 +1867,7 @@ static FunctionType *applyOptionality(ValueDecl *value, FunctionType *fnTy) {
18561867}
18571868
18581869std::pair<Type, Type>
1859- ConstraintSystem::getTypeOfMemberReferenceImpl (
1870+ ConstraintSystem::getTypeOfMemberReferencePre (
18601871 OverloadChoice choice, DeclContext *useDC,
18611872 ConstraintLocator *locator,
18621873 PreparedOverloadBuilder *preparedOverload) {
@@ -2032,13 +2043,16 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
20322043 return { openedType, thrownErrorType };
20332044}
20342045
2035- DeclReferenceType ConstraintSystem::getTypeOfMemberReference (
2046+ DeclReferenceType ConstraintSystem::getTypeOfMemberReferencePost (
20362047 OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
2037- PreparedOverloadBuilder *preparedOverload) {
2038- ASSERT (!!preparedOverload == PreparingOverload);
2039-
2048+ Type openedType, Type thrownErrorType) {
20402049 auto *value = choice.getDecl ();
20412050
2051+ if (isa<TypeDecl>(value)) {
2052+ auto type = openedType->castTo <FunctionType>()->getResult ();
2053+ return { openedType, openedType, type, type, Type () };
2054+ }
2055+
20422056 // Figure out the instance type used for the base.
20432057 Type baseTy = choice.getBaseType ();
20442058 Type baseRValueTy = baseTy->getRValueType ();
@@ -2048,15 +2062,6 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
20482062 // be handled by the caller via getTypeOfReference().
20492063 ASSERT (!baseObjTy->is <ModuleType>());
20502064
2051- Type openedType, thrownErrorType;
2052- std::tie (openedType, thrownErrorType)
2053- = getTypeOfMemberReferenceImpl (choice, useDC, locator, preparedOverload);
2054-
2055- if (isa<TypeDecl>(value)) {
2056- auto type = openedType->castTo <FunctionType>()->getResult ();
2057- return { openedType, openedType, type, type, Type () };
2058- }
2059-
20602065 auto hasAppliedSelf = doesMemberRefApplyCurriedSelf (baseRValueTy, value);
20612066
20622067 // Adjust the opened type for concurrency.
@@ -2113,6 +2118,19 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
21132118 return { origOpenedType, openedType, origType, type, thrownErrorType };
21142119}
21152120
2121+ DeclReferenceType ConstraintSystem::getTypeOfMemberReference (
2122+ OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
2123+ PreparedOverloadBuilder *preparedOverload) {
2124+ ASSERT (!!preparedOverload == PreparingOverload);
2125+
2126+ Type openedType, thrownErrorType;
2127+ std::tie (openedType, thrownErrorType)
2128+ = getTypeOfMemberReferencePre (choice, useDC, locator, preparedOverload);
2129+
2130+ return getTypeOfMemberReferencePost (
2131+ choice, useDC, locator, openedType, thrownErrorType);
2132+ }
2133+
21162134Type ConstraintSystem::getEffectiveOverloadType (ConstraintLocator *locator,
21172135 const OverloadChoice &overload,
21182136 bool allowMembers,
@@ -2825,9 +2843,9 @@ void ConstraintSystem::replayChanges(
28252843// / FIXME: As a transitional mechanism, if preparedOverload is nullptr, this
28262844// / immediately performs all operations.
28272845DeclReferenceType
2828- ConstraintSystem::prepareOverloadImpl (ConstraintLocator *locator,
2829- OverloadChoice choice,
2846+ ConstraintSystem::prepareOverloadImpl (OverloadChoice choice,
28302847 DeclContext *useDC,
2848+ ConstraintLocator *locator,
28312849 PreparedOverloadBuilder *preparedOverload) {
28322850 // If we refer to a top-level decl with special type-checking semantics,
28332851 // handle it now.
@@ -2842,23 +2860,23 @@ ConstraintSystem::prepareOverloadImpl(ConstraintLocator *locator,
28422860
28432861 // If the base is a module type, it's an unqualified reference.
28442862 if (baseTy->getMetatypeInstanceType ()->is <ModuleType>()) {
2845- return getTypeOfReference (choice, locator, useDC , preparedOverload);
2863+ return getTypeOfReference (choice, useDC, locator , preparedOverload);
28462864 }
28472865
28482866 return getTypeOfMemberReference (choice, useDC, locator, preparedOverload);
28492867 } else {
2850- return getTypeOfReference (choice, locator, useDC , preparedOverload);
2868+ return getTypeOfReference (choice, useDC, locator , preparedOverload);
28512869 }
28522870}
28532871
2854- PreparedOverload *ConstraintSystem::prepareOverload (ConstraintLocator *locator ,
2855- OverloadChoice choice ,
2856- DeclContext *useDC ) {
2872+ PreparedOverload *ConstraintSystem::prepareOverload (OverloadChoice choice ,
2873+ DeclContext *useDC ,
2874+ ConstraintLocator *locator ) {
28572875 ASSERT (!PreparingOverload);
28582876 PreparingOverload = true ;
28592877
28602878 PreparedOverloadBuilder builder;
2861- auto declRefType = prepareOverloadImpl (locator, choice, useDC, &builder);
2879+ auto declRefType = prepareOverloadImpl (choice, useDC, locator , &builder);
28622880
28632881 PreparingOverload = false ;
28642882
@@ -2869,9 +2887,8 @@ PreparedOverload *ConstraintSystem::prepareOverload(ConstraintLocator *locator,
28692887 return new (mem) PreparedOverload (declRefType, builder.Changes );
28702888}
28712889
2872- void ConstraintSystem::resolveOverload (ConstraintLocator *locator,
2873- Type boundType, OverloadChoice choice,
2874- DeclContext *useDC,
2890+ void ConstraintSystem::resolveOverload (OverloadChoice choice, DeclContext *useDC,
2891+ ConstraintLocator *locator, Type boundType,
28752892 PreparedOverload *preparedOverload) {
28762893 // Determine the type to which we'll bind the overload set's type.
28772894 Type openedType;
@@ -2896,7 +2913,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
28962913 adjustedRefType = preparedOverload->getAdjustedReferenceType ();
28972914 thrownErrorTypeOnAccess = preparedOverload->getThrownErrorTypeOnAccess ();
28982915 } else {
2899- auto declRefType = prepareOverloadImpl (locator, choice, useDC, nullptr );
2916+ auto declRefType = prepareOverloadImpl (choice, useDC, locator , nullptr );
29002917
29012918 openedType = declRefType.openedType ;
29022919 adjustedOpenedType = declRefType.adjustedOpenedType ;
0 commit comments