Skip to content

Commit 7511e0a

Browse files
authored
Merge pull request #24926 from xedin/rdar-50668864
[CSDiag] Adjust assert to account for changes in `filterContextualMem…
2 parents 464761e + 31d001c commit 7511e0a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6491,16 +6491,20 @@ bool FailureDiagnosis::visitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
64916491

64926492
// Depending on how we matched, produce tailored diagnostics.
64936493
switch (candidateInfo.closeness) {
6494+
case CC_SelfMismatch: // Self argument mismatches.
6495+
llvm_unreachable("These aren't produced by filterContextualMemberList");
6496+
return false;
6497+
64946498
case CC_NonLValueInOut: // First argument is inout but no lvalue present.
64956499
case CC_OneArgumentMismatch: // All arguments except one match.
64966500
case CC_OneArgumentNearMismatch:
64976501
case CC_OneGenericArgumentMismatch:
64986502
case CC_OneGenericArgumentNearMismatch:
64996503
case CC_GenericNonsubstitutableMismatch:
6500-
case CC_SelfMismatch: // Self argument mismatches.
65016504
case CC_ArgumentNearMismatch: // Argument list mismatch.
65026505
case CC_ArgumentMismatch: // Argument list mismatch.
6503-
llvm_unreachable("These aren't produced by filterContextualMemberList");
6506+
// Candidate filtering can produce these now, but they can't
6507+
// be properly diagnosed here at the moment.
65046508
return false;
65056509

65066510
case CC_ExactMatch: { // This is a perfect match for the arguments.

test/Constraints/construction.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,14 @@ func rdar_45535925() {
209209
// expected-error@-1 {{'bar' is inaccessible due to 'private' protection level}}
210210
}
211211
}
212+
213+
// rdar://problem/50668864
214+
func rdar_50668864() {
215+
struct Foo {
216+
init(anchors: [Int]) {
217+
// TODO: This would be improved when argument conversions are diagnosed via new diagnostic framework,
218+
// actual problem here is that `[Int]` cannot be converted to function type represented by a closure.
219+
self = .init { _ in [] } // expected-error {{type of expression is ambiguous without more context}}
220+
}
221+
}
222+
}

0 commit comments

Comments
 (0)