Skip to content

Commit 3a0d1a2

Browse files
committed
Sema: Use diagnoseOrDefer() in ConformanceChecker::ensureRequirementsAreSatisfied()
1 parent 2973e3f commit 3a0d1a2

5 files changed

+14
-22
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5110,20 +5110,19 @@ void ConformanceChecker::ensureRequirementsAreSatisfied() {
51105110
// Diagnose the failure generically.
51115111
// FIXME: Would be nice to give some more context here!
51125112
if (!Conformance->isInvalid()) {
5113-
diags.diagnose(Loc, diag::type_does_not_conform,
5114-
Adoptee,
5115-
Proto->getDeclaredInterfaceType());
5116-
51175113
if (result.getKind() == CheckRequirementsResult::RequirementFailure) {
5118-
TypeChecker::diagnoseRequirementFailure(
5119-
result.getRequirementFailureInfo(), Loc, Loc,
5120-
proto->getDeclaredInterfaceType(),
5121-
{proto->getSelfInterfaceType()->castTo<GenericTypeParamType>()},
5122-
QuerySubstitutionMap{substitutions}, module);
5114+
auto Loc = this->Loc;
5115+
diagnoseOrDefer(nullptr, /*isError=*/true,
5116+
[Loc, result, proto, substitutions, module](NormalProtocolConformance *conformance) {
5117+
TypeChecker::diagnoseRequirementFailure(
5118+
result.getRequirementFailureInfo(), Loc, Loc,
5119+
proto->getDeclaredInterfaceType(),
5120+
{proto->getSelfInterfaceType()->castTo<GenericTypeParamType>()},
5121+
QuerySubstitutionMap{substitutions}, module);
5122+
});
51235123
}
51245124

51255125
Conformance->setInvalid();
5126-
AlreadyComplained = true;
51275126
}
51285127
return;
51295128
}

test/Distributed/distributed_protocols_distributed_func_serialization_requirements.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ protocol ProtocolWithChecksSeqReq: DistributedActor
4949
distributed actor ProtocolWithChecksSeqReqDA_MissingSystem: ProtocolWithChecksSeqReq {
5050
// expected-error@-1{{distributed actor 'ProtocolWithChecksSeqReqDA_MissingSystem' does not declare ActorSystem it can be used with.}}
5151
// expected-note@-2{{you can provide a module-wide default actor system by declaring:}}
52-
// expected-error@-3{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'ProtocolWithChecksSeqReq'}}
5352
//
54-
// expected-error@-5{{distributed actor 'ProtocolWithChecksSeqReqDA_MissingSystem' does not declare ActorSystem it can be used with.}}
53+
// expected-error@-4{{distributed actor 'ProtocolWithChecksSeqReqDA_MissingSystem' does not declare ActorSystem it can be used with}}
5554

5655
// Entire conformance is doomed, so we didn't proceed to checking the functions; that's fine
5756
distributed func testAT() async throws -> NotCodable { .init() }

test/decl/protocol/req/associated_type_inference.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,7 @@ protocol P35a {
572572
associatedtype B // expected-note {{protocol requires nested type 'B'}}
573573
}
574574
protocol P35b: P35a where B == A {}
575-
// expected-error@+2 {{type 'S35' does not conform to protocol 'P35a'}}
576-
// expected-error@+1 {{type 'S35' does not conform to protocol 'P35b'}}
575+
// expected-error@+1 {{type 'S35' does not conform to protocol 'P35a'}}
577576
struct S35: P35b {}
578577

579578
// Circular reference through a value witness.
@@ -634,7 +633,6 @@ protocol P40b: P40a {
634633
protocol P40c: P40b where D == S40<Never> {}
635634
struct S40<E: Equatable>: P40c {
636635
// expected-error@-1 {{type 'S40<E>' does not conform to protocol 'P40b'}}
637-
// expected-error@-2 {{type 'S40<E>' does not conform to protocol 'P40c'}}
638636
func foo(arg: Never) {}
639637

640638
typealias B = Self
@@ -712,6 +710,5 @@ protocol FIXME_P1a {
712710
associatedtype B: FIXME_P1a // expected-note {{protocol requires nested type 'B'}}
713711
}
714712
protocol FIXME_P1b: FIXME_P1a where B == FIXME_S1<A> {}
715-
// expected-error@+2 {{type 'FIXME_S1<T>' does not conform to protocol 'FIXME_P1a'}}
716-
// expected-error@+1 {{type 'FIXME_S1<T>' does not conform to protocol 'FIXME_P1b'}}
713+
// expected-error@+1 {{type 'FIXME_S1<T>' does not conform to protocol 'FIXME_P1a'}}
717714
struct FIXME_S1<T: Equatable>: FIXME_P1b {}

test/decl/protocol/req/associated_type_inference_fixed_type.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ protocol Q11 {
108108
}
109109
do {
110110
struct Conformer: Q11, P11b {}
111-
// expected-error@-1 {{type 'Conformer' does not conform to protocol 'P11b'}}
112-
// expected-error@-2 {{type 'Conformer' does not conform to protocol 'P11a'}}
113-
// expected-error@-3 {{type 'Conformer' does not conform to protocol 'Q11'}}
111+
// expected-error@-1 {{type 'Conformer' does not conform to protocol 'P11a'}}
112+
// expected-error@-2 {{type 'Conformer' does not conform to protocol 'Q11'}}
114113
}
115114

116115
protocol P12 where A == B {
@@ -151,7 +150,6 @@ protocol P15b: P15a where A == B {}
151150
do {
152151
struct Conformer: P15b {}
153152
// expected-error@-1 {{type 'Conformer' does not conform to protocol 'P15a'}}
154-
// expected-error@-2 {{type 'Conformer' does not conform to protocol 'P15b'}}
155153
}
156154

157155
protocol P16a where A == B {

test/decl/protocol/req/associated_type_inference_fixed_type_experimental_inference.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,5 +885,4 @@ do {
885885
struct Conformer: P48c {}
886886
// expected-error@-1 {{type 'Conformer' does not conform to protocol 'P48a'}}
887887
// expected-error@-2 {{type 'Conformer' does not conform to protocol 'P48b'}}
888-
// expected-error@-3 {{type 'Conformer' does not conform to protocol 'P48c'}}
889888
}

0 commit comments

Comments
 (0)