You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/Constraints/diagnostics.swift
+4-4
Original file line number
Diff line number
Diff line change
@@ -51,9 +51,9 @@ f0(i, i, // expected-error@:7 {{cannot convert value of type 'Int' to expected a
51
51
52
52
53
53
// Cannot conform to protocols.
54
-
f5(f4) // expected-error {{type '(Int) -> Int' cannot conform to 'P2'; only concrete types such as structs, enums and classes can conform to protocols}}
55
-
f5((1,"hello")) // expected-error {{type '(Int, String)' cannot conform to 'P2'; only concrete types such as structs, enums and classes can conform to protocols}}
56
-
f5(Int.self) // expected-error {{type 'Int.Type' cannot conform to 'P2'; only concrete types such as structs, enums and classes can conform to protocols}}
54
+
f5(f4) // expected-error {{type '(Int) -> Int' cannot conform to 'P2'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
55
+
f5((1,"hello")) // expected-error {{type '(Int, String)' cannot conform to 'P2'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
56
+
f5(Int.self) // expected-error {{type 'Int.Type' cannot conform to 'P2'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
f8(3, f4) // expected-error {{global function 'f8' requires that 'Int' conform to 'P2'}}
105
105
typealiasTup=(Int,Double)
106
106
func f9(_ x:Tup)->Tup{return x }
107
-
f8((1,2.0), f9) // expected-error {{type 'Tup' (aka '(Int, Double)') cannot conform to 'P2'; only concrete types such as structs, enums and classes can conform to protocols}}
107
+
f8((1,2.0), f9) // expected-error {{type 'Tup' (aka '(Int, Double)') cannot conform to 'P2'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
108
108
109
109
// <rdar://problem/19658691> QoI: Incorrect diagnostic for calling nonexistent members on literals
110
110
1.doesntExist(0) // expected-error {{value of type 'Int' has no member 'doesntExist'}}
Copy file name to clipboardExpand all lines: test/Constraints/generics.swift
+1-1
Original file line number
Diff line number
Diff line change
@@ -188,7 +188,7 @@ func r22459135() {
188
188
189
189
// <rdar://problem/19710848> QoI: Friendlier error message for "[] as Set"
190
190
// <rdar://problem/22326930> QoI: "argument for generic parameter 'Element' could not be inferred" lacks context
191
-
_ =[]asSet // expected-error {{protocol 'Any' as a type cannot conform to 'Hashable'; only concrete types such as structs, enums and classes can conform to protocols}}
191
+
_ =[]asSet // expected-error {{protocol 'Any' as a type cannot conform to 'Hashable'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
192
192
// expected-note@-1 {{required by generic struct 'Set' where 'Element' = 'Any'}}
// expected-error@-1 {{type '() -> Int' cannot conform to 'Hashable'; only concrete types such as structs, enums and classes can conform to protocols}}
28
+
// expected-error@-1 {{type '() -> Int' cannot conform to 'Hashable'}} expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
Copy file name to clipboardExpand all lines: test/Constraints/result_builder_diags.swift
+1-1
Original file line number
Diff line number
Diff line change
@@ -195,7 +195,7 @@ struct Label<L> : P where L : P { // expected-note 2 {{'L' declared as parameter
195
195
}
196
196
197
197
func test_51167632()->someP{
198
-
AnyP(G{ // expected-error {{type 'Label<_>.Type' cannot conform to 'P'; only concrete types such as structs, enums and classes can conform to protocols}}
198
+
AnyP(G{ // expected-error {{type 'Label<_>.Type' cannot conform to 'P'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
199
199
Text("hello")
200
200
Label // expected-error {{generic parameter 'L' could not be inferred}}
201
201
// expected-note@-1 {{explicitly specify the generic arguments to fix this issue}} {{10-10=<<#L: P#>>}}
Copy file name to clipboardExpand all lines: test/Generics/conditional_conformances_literals.swift
+2-2
Original file line number
Diff line number
Diff line change
@@ -128,9 +128,9 @@ func combined() {
128
128
129
129
// Needs self conforming protocols:
130
130
let _:Conforms=[[0:[1:[works]]asConforms]]
131
-
// expected-error@-1 {{protocol 'Conforms' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
131
+
// expected-error@-1 {{protocol 'Conforms' as a type cannot conform to the protocol itself}} expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
132
132
133
133
let _:Conforms=[[0:[1:[fails]]asConforms]]
134
134
// expected-error@-1 {{protocol 'Conforms' requires that 'Fails' conform to 'Conforms'}}
135
-
// expected-error@-2 {{protocol 'Conforms' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
135
+
// expected-error@-2 {{protocol 'Conforms' as a type cannot conform to the protocol itself}} expected-note@-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
fP(p) // expected-error{{protocol 'P' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
26
+
fP(p) // expected-error{{protocol 'P' as a type cannot conform to the protocol itself}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
27
27
fAO(p) // expected-error{{global function 'fAO' requires that 'P' be a class type}}
28
28
fAOE(p) // expected-error{{argument type 'P' expected to be an instance of a class or class-constrained type}}
fP(opp) // expected-error{{protocol 'OP & P' as a type cannot conform to 'P'; only concrete types such as structs, enums and classes can conform to protocols}}
41
-
fOP(opp) // expected-error{{protocol 'OP & P' as a type cannot conform to 'OP'; only concrete types such as structs, enums and classes can conform to protocols}}
40
+
fP(opp) // expected-error{{protocol 'OP & P' as a type cannot conform to 'P'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
41
+
fOP(opp) // expected-error{{protocol 'OP & P' as a type cannot conform to 'OP'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
42
42
fAO(opp) // expected-error{{global function 'fAO' requires that 'OP & P' be a class type}}
43
43
fAOE(opp)
44
44
fT(opp)
@@ -64,9 +64,9 @@ class GAO<T : AnyObject> {} // expected-note 2{{requirement specified as 'T' : '
64
64
func blackHole(_ t:Any){}
65
65
66
66
func testBindExistential(){
67
-
blackHole(GP<P>()) // expected-error{{protocol 'P' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
67
+
blackHole(GP<P>()) // expected-error{{protocol 'P' as a type cannot conform to the protocol itself}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
68
68
blackHole(GOP<OP>())
69
-
blackHole(GCP<CP>()) // expected-error{{protocol 'CP' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
69
+
blackHole(GCP<CP>()) // expected-error{{protocol 'CP' as a type cannot conform to the protocol itself}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
70
70
blackHole(GAO<P>()) // expected-error{{'GAO' requires that 'P' be a class type}}
71
71
blackHole(GAO<OP>())
72
72
blackHole(GAO<CP>()) // expected-error{{'GAO' requires that 'CP' be a class type}}
@@ -92,5 +92,5 @@ func foo() {
92
92
// generic no overloads error path. The error should actually talk
93
93
// about the return type, and this can happen in other contexts as well;
allMine.takeAll() // expected-error{{protocol 'Mine' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
95
+
allMine.takeAll() // expected-error{{protocol 'Mine' as a type cannot conform to the protocol itself}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
// expected-error @+3 {{invalid character in source file}}
19
19
// expected-error @+2 {{expected ',' separator}}
20
-
// expected-error @+1 {{type '(Int, Int)' cannot conform to 'BinaryInteger'; only concrete types such as structs, enums and classes can conform to protocols}}
20
+
// expected-error @+1 {{type '(Int, Int)' cannot conform to 'BinaryInteger'}}
21
21
if(5 ‒ 5)==0{} // expected-note {{unicode character '‒' (Figure Dash) looks similar to '-' (Hyphen Minus); did you mean to use '-' (Hyphen Minus)?}} {{7-10=-}}
22
22
// expected-note @-1 {{operator function '=='}}
23
+
// expected-note @-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
23
24
24
25
// FIXME(rdar://61028087): The above note should read "required by referencing operator function '==' on 'BinaryInteger' where 'Self' = '(Int, Int)'".
wantsError(error) // expected-error {{protocol 'ErrorRefinement' as a type cannot conform to 'Error'; only concrete types such as structs, enums and classes can conform to protocols}}
14
+
wantsError(error) // expected-error {{protocol 'ErrorRefinement' as a type cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
wantsError(error) // expected-error {{protocol 'Error & OtherProtocol' as a type cannot conform to 'Error'; only concrete types such as structs, enums and classes can conform to protocols}}
19
+
wantsError(error) // expected-error {{protocol 'Error & OtherProtocol' as a type cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
wantsError(error) // expected-error {{protocol 'C & Error' as a type cannot conform to 'Error'; only concrete types such as structs, enums and classes can conform to protocols}}
24
+
wantsError(error) // expected-error {{protocol 'C & Error' as a type cannot conform to 'Error'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
Copy file name to clipboardExpand all lines: test/stmt/foreach.swift
+1-1
Original file line number
Diff line number
Diff line change
@@ -177,7 +177,7 @@ func testOptionalSequence() {
177
177
178
178
// Crash with (invalid) for each over an existential
179
179
func testExistentialSequence(s:Sequence){ // expected-error {{protocol 'Sequence' can only be used as a generic constraint because it has Self or associated type requirements}}
180
-
forxin s { // expected-error {{protocol 'Sequence' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
180
+
forxin s { // expected-error {{protocol 'Sequence' as a type cannot conform to the protocol itself}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
Copy file name to clipboardExpand all lines: test/type/opaque.swift
+1-1
Original file line number
Diff line number
Diff line change
@@ -383,7 +383,7 @@ protocol P_51641323 {
383
383
func rdar_51641323(){
384
384
structFoo:P_51641323{
385
385
varfoo:someP_51641323{ // expected-note {{required by opaque return type of property 'foo'}}
386
-
{} // expected-error {{type '() -> ()' cannot conform to 'P_51641323'; only concrete types such as structs, enums and classes can conform to protocols}}
386
+
{} // expected-error {{type '() -> ()' cannot conform to 'P_51641323'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
// expected-error@-1 {{global function 'conformsToAnyObject' requires that 'P1' be a class type}}
414
414
415
415
conformsToP1(p1)
416
-
// expected-error@-1 {{protocol 'P1' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
416
+
// expected-error@-1 {{protocol 'P1' as a type cannot conform to the protocol itself}}
417
+
// expected-note@-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
417
418
418
419
// FIXME: Following diagnostics are not great because when
419
420
// `conformsTo*` methods are re-typechecked, they loose information
// expected-note@-1 {{required by global function 'fn(_:arg2:)' where 'U' = '()'}}
7
7
8
8
func test(str:String){
9
-
fn(str){ arg in // expected-error {{type '()' cannot conform to 'P'; only concrete types such as structs, enums and classes can conform to protocols}}
9
+
fn(str){ arg in // expected-error {{type '()' cannot conform to 'P'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
10
10
<#FOO#> // expected-error {{editor placeholder in source file}}
// expected-note@-1 {{required by global function 'f' where 'T' = 'BooleanProtocol'}}
22
22
23
-
f(trueasBooleanProtocol) // expected-error {{protocol 'BooleanProtocol' as a type cannot conform to the protocol itself; only concrete types such as structs, enums and classes can conform to protocols}}
23
+
f(trueasBooleanProtocol) // expected-error {{protocol 'BooleanProtocol' as a type cannot conform to the protocol itself}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
0 commit comments