Skip to content

Commit 129092e

Browse files
committed
[Diagnostics] NFC: Adjust couple of regressed diagnostics related to protocol composition
1 parent 253abad commit 129092e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/type/subclass_composition.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ func basicSubtyping(
105105
let _: Derived = baseAndP2 // expected-error {{cannot convert value of type 'Base<Int> & P2' to specified type 'Derived'}}
106106
let _: Derived & P2 = baseAndP2 // expected-error {{value of type 'Base<Int> & P2' does not conform to specified type 'Derived & P2'}}
107107

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}}
109110
let _ = Unrelated() as? Derived & P2 // expected-warning {{always fails}}
110111
let _ = baseAndP2 as Unrelated // expected-error {{cannot convert value of type 'Base<Int> & P2' to type 'Unrelated' in coercion}}
111112
let _ = baseAndP2 as? Unrelated // expected-warning {{always fails}}
@@ -301,8 +302,8 @@ func conformsToAnyObject<T : AnyObject>(_: T) {}
301302
func conformsToP1<T : P1>(_: T) {}
302303
func conformsToP2<T : P2>(_: T) {}
303304
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>'}}
306307

307308
func conformsToBaseIntAndP2WithWhereClause<T>(_: T) where T : Base<Int> & P2 {}
308309
// expected-note@-1 {{where 'T' = 'Base<String>'}}
@@ -420,9 +421,10 @@ func conformsTo<T1 : P2, T2 : Base<Int> & P2>(
420421
conformsToBaseIntAndP2(base)
421422
// expected-error@-1 {{argument type 'Base<Int>' does not conform to expected type 'P2'}}
422423

424+
// TODO(diagnostics): Diagnostic for this problem should mention both `Base<String>` not conforming to `P2`
425+
// and invalid generic parameter (Int vs. String)
423426
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'}}
426428

427429
conformsToBaseIntAndP2(fakeDerived)
428430
// expected-error@-1 {{global function 'conformsToBaseIntAndP2' requires that 'Base<String>' inherit from 'Base<Int>'}}
@@ -547,4 +549,4 @@ struct Generic<T> {
547549
yield &_x
548550
}
549551
}
550-
}
552+
}

0 commit comments

Comments
 (0)