@@ -105,7 +105,8 @@ func basicSubtyping(
105
105
let _: Derived = baseAndP2 // expected-error {{cannot convert value of type 'Base<Int> & P2' to specified type 'Derived'}}
106
106
let _: Derived & P2 = baseAndP2 // expected-error {{value of type 'Base<Int> & P2' does not conform to specified type 'Derived & P2'}}
107
107
108
- let _ = Unrelated ( ) as Derived & P2 // expected-error {{value of type 'Unrelated' does not conform to 'Derived & P2' in coercion}}
108
+ // TODO(diagnostics): Diagnostic regression, better message is `value of type 'Unrelated' does not conform to 'Derived & P2' in coercion`
109
+ let _ = Unrelated ( ) as Derived & P2 // expected-error {{cannot convert value of type 'Unrelated' to type 'Derived' in coercion}}
109
110
let _ = Unrelated ( ) as? Derived & P2 // expected-warning {{always fails}}
110
111
let _ = baseAndP2 as Unrelated // expected-error {{cannot convert value of type 'Base<Int> & P2' to type 'Unrelated' in coercion}}
111
112
let _ = baseAndP2 as? Unrelated // expected-warning {{always fails}}
@@ -301,8 +302,8 @@ func conformsToAnyObject<T : AnyObject>(_: T) {}
301
302
func conformsToP1< T : P1 > ( _: T ) { }
302
303
func conformsToP2< T : P2 > ( _: T ) { }
303
304
func conformsToBaseIntAndP2< T : Base < Int > & P2 > ( _: T ) { }
304
- // expected-note@-1 2 {{where 'T' = 'Base<String>'}}
305
- // expected-note@-2 {{where 'T' = 'Base<Int>'}}
305
+ // expected-note@-1 {{where 'T' = 'Base<String>'}}
306
+ // expected-note@-2 2 {{where 'T' = 'Base<Int>'}}
306
307
307
308
func conformsToBaseIntAndP2WithWhereClause< T> ( _: T ) where T : Base < Int > & P2 { }
308
309
// expected-note@-1 {{where 'T' = 'Base<String>'}}
@@ -420,9 +421,10 @@ func conformsTo<T1 : P2, T2 : Base<Int> & P2>(
420
421
conformsToBaseIntAndP2 ( base)
421
422
// expected-error@-1 {{argument type 'Base<Int>' does not conform to expected type 'P2'}}
422
423
424
+ // TODO(diagnostics): Diagnostic for this problem should mention both `Base<String>` not conforming to `P2`
425
+ // and invalid generic parameter (Int vs. String)
423
426
conformsToBaseIntAndP2 ( badBase)
424
- // expected-error@-1 {{global function 'conformsToBaseIntAndP2' requires that 'Base<String>' inherit from 'Base<Int>'}}
425
- // expected-error@-2 {{argument type 'Base<String>' does not conform to expected type 'P2'}}
427
+ // expected-error@-1 {{global function 'conformsToBaseIntAndP2' requires that 'Base<Int>' conform to 'P2'}}
426
428
427
429
conformsToBaseIntAndP2 ( fakeDerived)
428
430
// expected-error@-1 {{global function 'conformsToBaseIntAndP2' requires that 'Base<String>' inherit from 'Base<Int>'}}
@@ -547,4 +549,4 @@ struct Generic<T> {
547
549
yield & _x
548
550
}
549
551
}
550
- }
552
+ }
0 commit comments