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(
153
153
// subclasses of 'C' which are 'Sendable'.
154
154
bool allowMissing = (requirementKind == RequirementKind::SameType);
155
155
156
+ bool allowUnavailable =
157
+ !proto->isSpecificProtocol (KnownProtocolKind::Sendable);
156
158
auto conformance = module ->lookupConformance (concreteType,
157
159
const_cast <ProtocolDecl *>(proto),
158
- allowMissing);
159
- if (conformance.isInvalid () || conformance.hasUnavailableConformance ()) {
160
+ allowMissing,
161
+ allowUnavailable);
162
+ if (conformance.isInvalid ()) {
160
163
// For superclass rules, it is totally fine to have a signature like:
161
164
//
162
165
// 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 {
73
73
}
74
74
75
75
struct 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}}
77
77
func ggg< T : I > ( t: T . Type ) -> T {
78
78
return T ( )
79
79
}
@@ -104,5 +104,5 @@ struct SU<A: P> where A.T == SU {
104
104
}
105
105
106
106
struct 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}}
108
108
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ protocol P {
6
6
7
7
struct Type < Param> { }
8
8
extension 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}}
10
10
// expected-note@-2 6{{through reference here}}
11
11
// expected-error@-3 {{type 'Type<Param>' does not conform to protocol 'P'}}
12
12
typealias A = Param
You can’t perform that action at this time.
0 commit comments