@@ -104,24 +104,51 @@ var c = C()
104
104
var x = c. p1
105
105
c. p1 = 1
106
106
107
+ // Reject extension of existential type
108
+
109
+ protocol P3 { }
110
+
111
+ extension any P3 {
112
+ // expected-error@-1 {{extension of type 'any P3' is not supported}}
113
+ // expected-note@-2 {{did you mean to extend 'P3' instead?}}
114
+ }
115
+
107
116
// Reject extension of nominal type via inferred associated type
108
- protocol P3 {
117
+ protocol P4 {
109
118
associatedtype Assoc
110
119
func foo( ) -> Assoc
111
120
}
112
121
113
- struct X3 : P3 {
122
+ struct X4 : P4 {
114
123
}
115
124
116
- extension X3 . Assoc {
117
- // expected-error@-1 {{extension of type 'X3 .Assoc' (aka 'Int') must be declared as an extension of 'Int'}}
125
+ extension X4 . Assoc {
126
+ // expected-error@-1 {{extension of type 'X4 .Assoc' (aka 'Int') must be declared as an extension of 'Int'}}
118
127
// expected-note@-2 {{did you mean to extend 'Int' instead?}}
119
128
}
120
129
121
- extension X3 {
130
+ extension X4 {
122
131
func foo( ) -> Int { return 0 }
123
132
}
124
133
134
+ // Reject extension of nominal type via typealias with dependent underlying type
135
+
136
+ struct Nest < Egg> { typealias Contents = Egg }
137
+ struct Tree {
138
+ typealias LimbContent = Nest < Int >
139
+ typealias BoughPayload = Nest < Nest < Int > >
140
+ }
141
+
142
+ extension Tree . LimbContent . Contents {
143
+ // expected-error@-1 {{extension of type 'Tree.LimbContent.Contents' (aka 'Int') must be declared as an extension of 'Int'}}
144
+ // expected-note@-2 {{did you mean to extend 'Int' instead?}} {{11-36=Int}}
145
+ }
146
+
147
+ extension Tree . BoughPayload . Contents {
148
+ // expected-error@-1 {{extension of type 'Tree.BoughPayload.Contents' (aka 'Nest<Int>') must be declared as an extension of 'Nest<Int>'}}
149
+ // expected-note@-2 {{did you mean to extend 'Nest<Int>' instead?}} {{11-37=Nest<Int>}}
150
+ }
151
+
125
152
// Make sure the test case from https://bugs.swift.org/browse/SR-3847 doesn't
126
153
// cause problems when the later extension is incorrectly nested inside another
127
154
// declaration.
@@ -334,24 +361,6 @@ extension ImposeClassReq2 {
334
361
}
335
362
}
336
363
337
- // Reject extension of nominal type via typealias with dependent underlying type
338
-
339
- struct Nest < Egg> { typealias Contents = Egg }
340
- struct Tree {
341
- typealias LimbContent = Nest < Int >
342
- typealias BoughPayload = Nest < Nest < Int > >
343
- }
344
-
345
- extension Tree . LimbContent . Contents {
346
- // expected-error@-1 {{extension of type 'Tree.LimbContent.Contents' (aka 'Int') must be declared as an extension of 'Int'}}
347
- // expected-note@-2 {{did you mean to extend 'Int' instead?}} {{11-36=Int}}
348
- }
349
-
350
- extension Tree . BoughPayload . Contents {
351
- // expected-error@-1 {{extension of type 'Tree.BoughPayload.Contents' (aka 'Nest<Int>') must be declared as an extension of 'Nest<Int>'}}
352
- // expected-note@-2 {{did you mean to extend 'Nest<Int>' instead?}}
353
- }
354
-
355
364
// SR-10466 Check 'where' clause when referencing type defined inside extension
356
365
struct SR_10466 < T> {
357
366
var a : A // expected-error {{'SR_10466<T>.A' (aka 'Int') requires the types 'T' and 'Never' be equivalent}}
0 commit comments