Skip to content

Commit facb2d8

Browse files
committed
Sema / Test: Allow fallback to CSDiag still using the new diagnostic
1 parent 6af91cc commit facb2d8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,15 @@ void FailureDiagnosis::diagnoseUnviableLookupResults(
754754
case MemberLookupResult::UR_WritableKeyPathOnReadOnlyMember:
755755
case MemberLookupResult::UR_ReferenceWritableKeyPathOnMutatingMember:
756756
case MemberLookupResult::UR_KeyPathWithAnyObjectRootType:
757-
case MemberLookupResult::UR_UnavailableInExistential:
758757
break;
758+
759+
case MemberLookupResult::UR_UnavailableInExistential: {
760+
AllowProtocolTypeMemberFailure failure(baseExpr, CS, instanceTy, memberName,
761+
CS.getConstraintLocator(E));
762+
failure.diagnoseAsError();
763+
return;
764+
}
765+
759766
case MemberLookupResult::UR_InstanceMemberOnType:
760767
case MemberLookupResult::UR_TypeMemberOnInstance: {
761768
auto locatorKind = isa<SubscriptExpr>(E)

test/decl/protocol/protocols.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ struct WrongIsEqual : IsEqualComparable { // expected-error{{type 'WrongIsEqual'
267267
//===----------------------------------------------------------------------===//
268268

269269
func existentialSequence(_ e: Sequence) { // expected-error{{has Self or associated type requirements}}
270-
var x = e.makeIterator() // expected-error{{value of type 'Sequence' has no member 'makeIterator'}}
270+
var x = e.makeIterator() // expected-error{{member 'makeIterator' cannot be used on value of protocol type 'Sequence'; use a generic constraint instead}}
271271
x.next()
272272
x.nonexistent()
273273
}

0 commit comments

Comments
 (0)