@@ -645,7 +645,7 @@ namespace {
645
645
cs.cacheType (declRefExpr);
646
646
declRefExpr->setFunctionRefKind (choice.getFunctionRefKind ());
647
647
Expr *result = adjustTypeForDeclReference (
648
- declRefExpr, fullType, adjustedFullType);
648
+ declRefExpr, fullType, adjustedFullType, locator );
649
649
result = forceUnwrapIfExpected (result, locator);
650
650
651
651
if (auto *fnDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -925,6 +925,7 @@ namespace {
925
925
// / conversions. This can happen due to `@preconcurrency`.
926
926
Expr *adjustTypeForDeclReference (
927
927
Expr *expr, Type openedType, Type adjustedOpenedType,
928
+ ConstraintLocatorBuilder locator,
928
929
llvm::function_ref<Type(Type)> getNewType = [](Type type) {
929
930
return type;
930
931
}) {
@@ -960,16 +961,16 @@ namespace {
960
961
961
962
expr = new (context) BindOptionalExpr (expr, SourceLoc (), 0 , objectType);
962
963
cs.cacheType (expr);
963
- expr = adjustTypeForDeclReference (expr, objectType, adjustedObjectType);
964
+ expr = adjustTypeForDeclReference (
965
+ expr, objectType, adjustedObjectType, locator);
964
966
expr = new (context) InjectIntoOptionalExpr (expr, adjustedRefType);
965
967
cs.cacheType (expr);
966
968
expr = new (context) OptionalEvaluationExpr (expr, adjustedRefType);
967
969
cs.cacheType (expr);
968
970
return expr;
969
971
}
970
972
971
- assert (false && " Unhandled adjustment" );
972
- return expr;
973
+ return coerceToType (expr, adjustedOpenedType, locator);
973
974
}
974
975
975
976
// / Determines if a partially-applied member reference should be
@@ -1539,7 +1540,7 @@ namespace {
1539
1540
Expr *ref = cs.cacheType (new (context) DotSyntaxBaseIgnoredExpr (
1540
1541
base, dotLoc, dre, refTy));
1541
1542
1542
- ref = adjustTypeForDeclReference (ref, refTy, adjustedRefTy);
1543
+ ref = adjustTypeForDeclReference (ref, refTy, adjustedRefTy, locator );
1543
1544
return forceUnwrapIfExpected (ref, memberLocator);
1544
1545
}
1545
1546
@@ -1685,7 +1686,7 @@ namespace {
1685
1686
1686
1687
// Adjust the declaration reference type, if required.
1687
1688
ref = adjustTypeForDeclReference (
1688
- ref, openedType, adjustedOpenedType, computeRefType);
1689
+ ref, openedType, adjustedOpenedType, locator, computeRefType);
1689
1690
1690
1691
closeExistentials (ref, locator, /* force=*/ openedExistential);
1691
1692
@@ -1732,7 +1733,8 @@ namespace {
1732
1733
1733
1734
Expr *result = memberRefExpr;
1734
1735
result = adjustTypeForDeclReference (result, resultType (refTy),
1735
- resultType (adjustedRefTy));
1736
+ resultType (adjustedRefTy),
1737
+ locator);
1736
1738
closeExistentials (result, locator);
1737
1739
1738
1740
// If the property is of dynamic 'Self' type, wrap an implicit
@@ -1764,7 +1766,7 @@ namespace {
1764
1766
cs.setType (declRefExpr, refTy);
1765
1767
Expr *ref = declRefExpr;
1766
1768
1767
- ref = adjustTypeForDeclReference (ref, refTy, adjustedRefTy);
1769
+ ref = adjustTypeForDeclReference (ref, refTy, adjustedRefTy, locator );
1768
1770
1769
1771
// A partial application thunk consists of two nested closures:
1770
1772
//
@@ -1941,7 +1943,8 @@ namespace {
1941
1943
apply = ConstructorRefCallExpr::create (context, ref, base);
1942
1944
} else if (isUnboundInstanceMember) {
1943
1945
ref = adjustTypeForDeclReference (
1944
- ref, cs.getType (ref), cs.simplifyType (adjustedOpenedType));
1946
+ ref, cs.getType (ref), cs.simplifyType (adjustedOpenedType),
1947
+ locator);
1945
1948
1946
1949
// Reference to an unbound instance method.
1947
1950
Expr *result = new (context) DotSyntaxBaseIgnoredExpr (base, dotLoc,
0 commit comments