Skip to content

Commit ed94131

Browse files
committed
[Sema] Bail out early of solution application for UME
…when the deduced type is unresolved. Otherwise, we won’t be able to fetch the overload choice or do anything else useful.
1 parent 1e27f26 commit ed94131

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,15 @@ namespace {
27532753
}
27542754

27552755
Expr *visitUnresolvedMemberExpr(UnresolvedMemberExpr *expr) {
2756+
// If constraint solving resolved this to an UnresolvedType, then we're in
2757+
// an ambiguity tolerant mode used for diagnostic generation. Just leave
2758+
// this as an unresolved member reference.
2759+
Type resultTy = simplifyType(cs.getType(expr));
2760+
if (resultTy->getRValueType()->is<UnresolvedType>()) {
2761+
cs.setType(expr, resultTy);
2762+
return expr;
2763+
}
2764+
27562765
auto &ctx = cs.getASTContext();
27572766
// Find the selected member and base type.
27582767
auto memberLocator = cs.getConstraintLocator(
@@ -2762,6 +2771,7 @@ namespace {
27622771
// Unresolved member lookup always happens in a metatype so dig out the
27632772
// instance type.
27642773
auto baseTy = selected.choice.getBaseType()->getMetatypeInstanceType();
2774+
baseTy = simplifyType(baseTy);
27652775

27662776
// The base expression is simply the metatype of the base type.
27672777
// FIXME: This location info is bogus.
@@ -2805,8 +2815,7 @@ namespace {
28052815
diagnoseAmbiguousNominalMember(baseTy, result);
28062816
}
28072817

2808-
return coerceToType(result, simplifyType(cs.getType(expr)),
2809-
cs.getConstraintLocator(expr));
2818+
return coerceToType(result, resultTy, cs.getConstraintLocator(expr));
28102819
}
28112820

28122821
/// Diagnose if the base type is optional, we're referring to a nominal

0 commit comments

Comments
 (0)