Skip to content

Commit 578097c

Browse files
committed
[GSB] AbstractProtocol sources are explicit when computing req. sig. and not inferred.
If they're considered explicit, requirement inference will complain when it infers X: SomeProtocol for some concrete type X. Fixes SR-4693, rdar://problem/31819616
1 parent f4e2b53 commit 578097c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,13 @@ bool FloatingRequirementSource::isExplicit() const {
930930
return false;
931931

932932
case AbstractProtocol:
933+
// Requirements implied by other protocol conformance requirements are
934+
// implicit, except when computing a requirement signature, where
935+
// non-inferred ones are explicit, to allow flagging of redundant
936+
// requirements.
933937
switch (storage.get<const RequirementSource *>()->kind) {
934938
case RequirementSource::RequirementSignatureSelf:
935-
return true;
939+
return !protocolReq.inferred;
936940

937941
case RequirementSource::Concrete:
938942
case RequirementSource::Explicit:

test/Generics/protocol_where_clause.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,14 @@ struct BadConcreteNestedConforms: NestedConforms {
6666
// expected-error@-1 {{type 'ConcreteParentNonFoo2.T' (aka 'Float') does not conform to protocol 'Foo2'}}
6767
typealias U = ConcreteParentNonFoo2
6868
}
69+
70+
71+
// SR4693:
72+
protocol P1 {}
73+
struct X: P1 {}
74+
struct Y<T: P1> {}
75+
76+
protocol P2 {
77+
associatedtype AT
78+
}
79+
protocol P3: P2 where AT == Y<X> {}

0 commit comments

Comments
 (0)