File tree Expand file tree Collapse file tree 5 files changed +43
-22
lines changed
lib/AST/RequirementMachine
validation-test/compiler_crashers_2_fixed Expand file tree Collapse file tree 5 files changed +43
-22
lines changed Original file line number Diff line number Diff line change @@ -153,10 +153,13 @@ void PropertyMap::concretizeNestedTypesFromConcreteParent(
153153 // subclasses of 'C' which are 'Sendable'.
154154 bool allowMissing = (requirementKind == RequirementKind::SameType);
155155
156+ bool allowUnavailable =
157+ !proto->isSpecificProtocol (KnownProtocolKind::Sendable);
156158 auto conformance = module ->lookupConformance (concreteType,
157159 const_cast <ProtocolDecl *>(proto),
158- allowMissing);
159- if (conformance.isInvalid () || conformance.hasUnavailableConformance ()) {
160+ allowMissing,
161+ allowUnavailable);
162+ if (conformance.isInvalid ()) {
160163 // For superclass rules, it is totally fine to have a signature like:
161164 //
162165 // protocol P {}
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift
2+
3+ protocol P { }
4+
5+ struct X { }
6+
7+ @available ( * , unavailable)
8+ extension X : P { }
9+
10+ struct Y < T: P > { }
11+
12+ @available ( * , unavailable)
13+ extension Y {
14+ // Okay, because the unavailable conformance is used within an
15+ // unavailable context.
16+ init ( ) where T == X { }
17+ }
18+
19+ // A more elaborate setup that hits the conformance check in property map
20+ // construction rather than concrete contraction.
21+
22+ protocol AssocP { }
23+
24+ @available ( * , unavailable)
25+ struct ConcreteP { }
26+
27+ @available ( * , unavailable)
28+ extension ConcreteP : AssocP { }
29+
30+ protocol Base {
31+ associatedtype T : AssocP
32+ }
33+
34+ @available ( * , unavailable)
35+ extension Base where T == ConcreteP { }
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ protocol PI {
7373}
7474
7575struct SI < A: PI > : I where A : I , A. T == SI < A > {
76- // expected-error@-1 5 {{generic struct 'SI' has self-referential generic requirements}}
76+ // expected-error@-1 3 {{generic struct 'SI' has self-referential generic requirements}}
7777 func ggg< T : I > ( t: T . Type ) -> T {
7878 return T ( )
7979 }
@@ -104,5 +104,5 @@ struct SU<A: P> where A.T == SU {
104104}
105105
106106struct SIU < A: PI > : I where A : I , A. T == SIU {
107- // expected-error@-1 5 {{generic struct 'SIU' has self-referential generic requirements}}
107+ // expected-error@-1 3 {{generic struct 'SIU' has self-referential generic requirements}}
108108}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ protocol P {
66
77struct Type < Param> { }
88extension Type : P where Param: P , Param. A == Type < Param > {
9- // expected-error@-1 8 {{extension of generic struct 'Type' has self-referential generic requirements}}
9+ // expected-error@-1 6 {{extension of generic struct 'Type' has self-referential generic requirements}}
1010 // expected-note@-2 6{{through reference here}}
1111 // expected-error@-3 {{type 'Type<Param>' does not conform to protocol 'P'}}
1212 typealias A = Param
You can’t perform that action at this time.
0 commit comments