Skip to content

Commit 6895707

Browse files
committed
GSB: Set HadAnyError in two more places
If we don't set this flag, we can end up making an invalid GSB into the canonical builder for some signature. This was caught by requirement machine cross-checking on the compiler_crashers suite.
1 parent fd0e1e2 commit 6895707

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8146,6 +8146,8 @@ void GenericSignatureBuilder::enumerateRequirements(
81468146
RequirementRHS rhs) {
81478147
if (auto req = createRequirement(kind, depTy, rhs, genericParams))
81488148
requirements.push_back(*req);
8149+
else
8150+
Impl->HadAnyError = true;
81498151
};
81508152

81518153
// Collect all non-same type requirements.
@@ -8489,6 +8491,8 @@ GenericSignature GenericSignatureBuilder::rebuildSignatureWithoutRedundantRequir
84898491
auto newReq = stripBoundDependentMemberTypes(*optReq);
84908492
newBuilder.addRequirement(newReq, getRebuiltSource(req.getSource()),
84918493
nullptr);
8494+
} else {
8495+
Impl->HadAnyError = true;
84928496
}
84938497
}
84948498

test/decl/protocol/req/recursion.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ public struct S<A: P> where A.T == S<A> { // expected-error {{circular reference
4949
// expected-note@-3 {{while resolving type 'S<A>'}}
5050
func f(a: A.T) {
5151
g(a: id(t: a)) // `a` has error type which is diagnosed as circular reference
52+
// expected-error@-1 {{conflicting arguments to generic parameter 'T' ('A.T' (associated type of protocol 'P') vs. 'S<A>')}}
5253
_ = A.T.self
5354
}
5455

5556
func g(a: S<A>) {
5657
f(a: id(t: a))
57-
// expected-error@-1 {{cannot convert value of type 'S<A>' to expected argument type 'A.T'}}
58+
// expected-error@-1 {{conflicting arguments to generic parameter 'T' ('S<A>' vs. 'A.T' (associated type of protocol 'P'))}}
5859
_ = S<A>.self
5960
}
6061

0 commit comments

Comments
 (0)