@@ -1109,10 +1109,10 @@ recordFixIfNeededForPlaceholderInDecl(ConstraintSystem &cs, ValueDecl *D,
1109
1109
}
1110
1110
1111
1111
std::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) {
1116
1116
auto *value = choice.getDecl ();
1117
1117
1118
1118
ASSERT (!!preparedOverload == PreparingOverload);
@@ -1237,16 +1237,10 @@ ConstraintSystem::getTypeOfReferenceImpl(OverloadChoice choice,
1237
1237
}
1238
1238
1239
1239
DeclReferenceType
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) {
1250
1244
auto *value = choice.getDecl ();
1251
1245
1252
1246
if (value->getDeclContext ()->isTypeContext () && isa<FuncDecl>(value)) {
@@ -1331,7 +1325,24 @@ ConstraintSystem::getTypeOfReference(OverloadChoice choice,
1331
1325
ClosureIsolatedByPreconcurrency{*this });
1332
1326
}
1333
1327
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);
1335
1346
}
1336
1347
1337
1348
// / Bind type variables for archetypes that are determined from
@@ -1856,7 +1867,7 @@ static FunctionType *applyOptionality(ValueDecl *value, FunctionType *fnTy) {
1856
1867
}
1857
1868
1858
1869
std::pair<Type, Type>
1859
- ConstraintSystem::getTypeOfMemberReferenceImpl (
1870
+ ConstraintSystem::getTypeOfMemberReferencePre (
1860
1871
OverloadChoice choice, DeclContext *useDC,
1861
1872
ConstraintLocator *locator,
1862
1873
PreparedOverloadBuilder *preparedOverload) {
@@ -2032,13 +2043,16 @@ ConstraintSystem::getTypeOfMemberReferenceImpl(
2032
2043
return { openedType, thrownErrorType };
2033
2044
}
2034
2045
2035
- DeclReferenceType ConstraintSystem::getTypeOfMemberReference (
2046
+ DeclReferenceType ConstraintSystem::getTypeOfMemberReferencePost (
2036
2047
OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
2037
- PreparedOverloadBuilder *preparedOverload) {
2038
- ASSERT (!!preparedOverload == PreparingOverload);
2039
-
2048
+ Type openedType, Type thrownErrorType) {
2040
2049
auto *value = choice.getDecl ();
2041
2050
2051
+ if (isa<TypeDecl>(value)) {
2052
+ auto type = openedType->castTo <FunctionType>()->getResult ();
2053
+ return { openedType, openedType, type, type, Type () };
2054
+ }
2055
+
2042
2056
// Figure out the instance type used for the base.
2043
2057
Type baseTy = choice.getBaseType ();
2044
2058
Type baseRValueTy = baseTy->getRValueType ();
@@ -2048,15 +2062,6 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
2048
2062
// be handled by the caller via getTypeOfReference().
2049
2063
ASSERT (!baseObjTy->is <ModuleType>());
2050
2064
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
-
2060
2065
auto hasAppliedSelf = doesMemberRefApplyCurriedSelf (baseRValueTy, value);
2061
2066
2062
2067
// Adjust the opened type for concurrency.
@@ -2113,6 +2118,19 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
2113
2118
return { origOpenedType, openedType, origType, type, thrownErrorType };
2114
2119
}
2115
2120
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
+
2116
2134
Type ConstraintSystem::getEffectiveOverloadType (ConstraintLocator *locator,
2117
2135
const OverloadChoice &overload,
2118
2136
bool allowMembers,
@@ -2825,9 +2843,9 @@ void ConstraintSystem::replayChanges(
2825
2843
// / FIXME: As a transitional mechanism, if preparedOverload is nullptr, this
2826
2844
// / immediately performs all operations.
2827
2845
DeclReferenceType
2828
- ConstraintSystem::prepareOverloadImpl (ConstraintLocator *locator,
2829
- OverloadChoice choice,
2846
+ ConstraintSystem::prepareOverloadImpl (OverloadChoice choice,
2830
2847
DeclContext *useDC,
2848
+ ConstraintLocator *locator,
2831
2849
PreparedOverloadBuilder *preparedOverload) {
2832
2850
// If we refer to a top-level decl with special type-checking semantics,
2833
2851
// handle it now.
@@ -2842,23 +2860,23 @@ ConstraintSystem::prepareOverloadImpl(ConstraintLocator *locator,
2842
2860
2843
2861
// If the base is a module type, it's an unqualified reference.
2844
2862
if (baseTy->getMetatypeInstanceType ()->is <ModuleType>()) {
2845
- return getTypeOfReference (choice, locator, useDC , preparedOverload);
2863
+ return getTypeOfReference (choice, useDC, locator , preparedOverload);
2846
2864
}
2847
2865
2848
2866
return getTypeOfMemberReference (choice, useDC, locator, preparedOverload);
2849
2867
} else {
2850
- return getTypeOfReference (choice, locator, useDC , preparedOverload);
2868
+ return getTypeOfReference (choice, useDC, locator , preparedOverload);
2851
2869
}
2852
2870
}
2853
2871
2854
- PreparedOverload *ConstraintSystem::prepareOverload (ConstraintLocator *locator ,
2855
- OverloadChoice choice ,
2856
- DeclContext *useDC ) {
2872
+ PreparedOverload *ConstraintSystem::prepareOverload (OverloadChoice choice ,
2873
+ DeclContext *useDC ,
2874
+ ConstraintLocator *locator ) {
2857
2875
ASSERT (!PreparingOverload);
2858
2876
PreparingOverload = true ;
2859
2877
2860
2878
PreparedOverloadBuilder builder;
2861
- auto declRefType = prepareOverloadImpl (locator, choice, useDC, &builder);
2879
+ auto declRefType = prepareOverloadImpl (choice, useDC, locator , &builder);
2862
2880
2863
2881
PreparingOverload = false ;
2864
2882
@@ -2869,9 +2887,8 @@ PreparedOverload *ConstraintSystem::prepareOverload(ConstraintLocator *locator,
2869
2887
return new (mem) PreparedOverload (declRefType, builder.Changes );
2870
2888
}
2871
2889
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,
2875
2892
PreparedOverload *preparedOverload) {
2876
2893
// Determine the type to which we'll bind the overload set's type.
2877
2894
Type openedType;
@@ -2896,7 +2913,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
2896
2913
adjustedRefType = preparedOverload->getAdjustedReferenceType ();
2897
2914
thrownErrorTypeOnAccess = preparedOverload->getThrownErrorTypeOnAccess ();
2898
2915
} else {
2899
- auto declRefType = prepareOverloadImpl (locator, choice, useDC, nullptr );
2916
+ auto declRefType = prepareOverloadImpl (choice, useDC, locator , nullptr );
2900
2917
2901
2918
openedType = declRefType.openedType ;
2902
2919
adjustedOpenedType = declRefType.adjustedOpenedType ;
0 commit comments