@@ -1851,29 +1851,20 @@ static FunctionType *applyOptionality(ValueDecl *value, FunctionType *fnTy) {
1851
1851
fnTy->getExtInfo ());
1852
1852
}
1853
1853
1854
- DeclReferenceType ConstraintSystem::getTypeOfMemberReference (
1854
+ std::tuple<Type, Type, Type>
1855
+ ConstraintSystem::getTypeOfMemberReferenceImpl (
1855
1856
Type baseTy, ValueDecl *value, DeclContext *useDC, bool isDynamicLookup,
1856
1857
FunctionRefInfo functionRefInfo, ConstraintLocator *locator,
1857
1858
SmallVectorImpl<OpenedType> *replacementsPtr,
1858
1859
PreparedOverloadBuilder *preparedOverload) {
1860
+ ASSERT (!isa<TypeDecl>(value));
1859
1861
ASSERT (!!preparedOverload == PreparingOverload);
1860
1862
recordFixIfNeededForPlaceholderInDecl (*this , value, locator);
1861
1863
1862
1864
// Figure out the instance type used for the base.
1863
1865
Type baseRValueTy = baseTy->getRValueType ();
1864
1866
auto baseObjTy = baseRValueTy->getMetatypeInstanceType ();
1865
1867
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
-
1877
1868
// Figure out the declaration context to use when opening this type.
1878
1869
DeclContext *innerDC = value->getInnermostDeclContext ();
1879
1870
DeclContext *outerDC = value->getDeclContext ();
@@ -1914,7 +1905,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
1914
1905
isa<MacroDecl>(value)) {
1915
1906
auto interfaceType = value->getInterfaceType ();
1916
1907
if (interfaceType->is <ErrorType>() || isa<MacroDecl>(value))
1917
- return { interfaceType, interfaceType, interfaceType, interfaceType, Type () };
1908
+ return { interfaceType, Type (), baseObjTy };
1918
1909
1919
1910
if (outerDC->getSelfClassDecl ()) {
1920
1911
if (isa<ConstructorDecl>(value)) {
@@ -2030,6 +2021,40 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
2030
2021
}
2031
2022
}
2032
2023
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
+
2033
2058
// Adjust the opened type for concurrency.
2034
2059
Type origOpenedType = openedType;
2035
2060
if (isRequirementOrWitness (locator)) {
0 commit comments