2
2
3
3
struct MyType < TyA, TyB> { // expected-note {{generic type 'MyType' declared here}}
4
4
// expected-note @-1 {{arguments to generic parameter 'TyB' ('S' and 'Int') are expected to be equal}}
5
- // expected-note @-2 4 {{arguments to generic parameter 'TyA' ('Float' and 'Int') are expected to be equal}}
5
+ // expected-note @-2 6 {{arguments to generic parameter 'TyA' ('Float' and 'Int') are expected to be equal}}
6
+ // expected-note @-3 2 {{arguments to generic parameter 'TyA' ('Float' and 'Double') are expected to be equal}}
7
+ // expected-note @-4 2 {{arguments to generic parameter 'TyB' ('Int' and 'Float') are expected to be equal}}
8
+ // expected-note @-5 2 {{arguments to generic parameter 'TyB' ('Double' and 'Float') are expected to be equal}}
6
9
var a : TyA , b : TyB
7
10
}
8
11
@@ -24,6 +27,22 @@ let _: OurType<Int, String>
24
27
let _: YourType < Int >
25
28
let _: Container . YourType < Int >
26
29
30
+ // The question of whether a type alias is implicitly generic should not
31
+ // arise until after we attempt to resolve the underlying type.
32
+ do {
33
+ struct Outer < T> {
34
+ typealias NotGeneric = Outer
35
+ struct Inner < U> {
36
+ typealias NotGeneric = Outer
37
+ }
38
+ }
39
+
40
+ let _: Outer < Int > . NotGeneric < Bool >
41
+ // expected-error@-1 {{cannot specialize non-generic type 'Outer<Int>.NotGeneric' (aka 'Outer<Int>')}}
42
+ let _: Outer < Int > . Inner < Never > . NotGeneric < Bool >
43
+ // expected-error@-1 {{cannot specialize non-generic type 'Outer<Int>.Inner<Never>.NotGeneric' (aka 'Outer<Int>')}}
44
+ }
45
+
27
46
//
28
47
// Bona-fide generic type aliases
29
48
//
@@ -246,8 +265,14 @@ let _: ConcreteStruct.O<Int> = ConcreteStruct.O<Int>(123)
246
265
// In the other cases, we manage to fold the UnresolvedSpecializeExpr in the
247
266
// precheckExpression() phase, which handles generic typealiases correctly.
248
267
249
- let _ = GenericClass . TA< Float> ( a: 4.0 , b: 1 ) // FIXME
250
- let _ = GenericClass . TA< Float> ( a: 1 , b: 4.0 )
268
+ do {
269
+ let x1 = GenericClass . TA< Float> ( a: 4.0 , b: 1 ) // FIXME
270
+ let x2 = GenericClass . TA< Float> ( a: 1 , b: 4.0 ) // FIXME
271
+
272
+ // FIXME: Should not diagnose
273
+ let _: MyType < Double , Float > = x1 // expected-error {{cannot assign value of type 'MyType<Float, Int>' to type 'MyType<Double, Float>'}}
274
+ let _: MyType < Int , Float > = x2 // expected-error {{cannot assign value of type 'MyType<Float, Double>' to type 'MyType<Int, Float>'}}
275
+ }
251
276
252
277
let _ = GenericClass< Int> . TA( a: 4.0 , b: 1 ) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
253
278
let _ = GenericClass< Int> . TA( a: 1 , b: 4.0 )
@@ -258,8 +283,14 @@ let _ = GenericClass<Int>.TA<Float>(a: 1, b: 4.0)
258
283
let _: GenericClass . TA = GenericClass . TA ( a: 4.0 , b: 1 )
259
284
let _: GenericClass . TA = GenericClass . TA ( a: 1 , b: 4.0 )
260
285
261
- let _: GenericClass . TA = GenericClass . TA< Float> ( a: 4.0 , b: 1 ) // FIXME
262
- let _: GenericClass . TA = GenericClass . TA< Float> ( a: 1 , b: 4.0 )
286
+ do {
287
+ let x1 : GenericClass . TA = GenericClass . TA< Float> ( a: 4.0 , b: 1 ) // FIXME
288
+ let x2 : GenericClass . TA = GenericClass . TA< Float> ( a: 1 , b: 4.0 ) // FIXME
289
+
290
+ // FIXME: Should not diagnose
291
+ let _: MyType < Double , Float > = x1 // expected-error {{cannot assign value of type 'MyType<Float, Int>' to type 'MyType<Double, Float>'}}
292
+ let _: MyType < Int , Float > = x2 // expected-error {{cannot assign value of type 'MyType<Float, Double>' to type 'MyType<Int, Float>'}}
293
+ }
263
294
264
295
let _: GenericClass . TA = GenericClass< Int> . TA( a: 4.0 , b: 1 ) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
265
296
let _: GenericClass . TA = GenericClass< Int> . TA( a: 1 , b: 4.0 )
0 commit comments