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
// expected-note @+5 2 {{candidate requires that 'Int' conform to 'Differentiable' (requirement specified as 'T' == 'Differentiable')}}
181
+
// expected-note @+5 2 {{found this candidate}}
182
182
// expected-error @+4 {{generic signature requires types 'Vector<T>' and 'Vector<T>.TangentVector' to be the same}}
183
183
// expected-error @+3 {{generic signature requires types 'Vector<U>' and 'Vector<U>.TangentVector' to be the same}}
184
184
// expected-error @+2 {{parameter type 'Vector<T>' does not conform to 'Differentiable' and satisfy 'Vector<T> == Vector<T>.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
185
185
// expected-error @+1 {{result type 'Vector<U>' does not conform to 'Differentiable' and satisfy 'Vector<U> == Vector<U>.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
Copy file name to clipboardExpand all lines: test/Constraints/diagnostics.swift
+7-3
Original file line number
Diff line number
Diff line change
@@ -687,7 +687,7 @@ enum AssocTest {
687
687
case one(Int)
688
688
}
689
689
690
-
ifAssocTest.one(1)==AssocTest.one(1){} // expected-error{{binary operator '==' cannot be applied to two 'AssocTest' operands}}
690
+
ifAssocTest.one(1)==AssocTest.one(1){} // expected-error{{referencing operator function '==' on 'Equatable' requires that 'AssocTest' conform to 'Equatable'}}
691
691
// expected-note @-1 {{binary operator '==' cannot be synthesized for enums with associated values}}
692
692
693
693
@@ -1100,9 +1100,13 @@ func rdar17170728() {
1100
1100
}
1101
1101
1102
1102
let _ =[i, j, k].reduce(0asInt?){
1103
+
// expected-error@-1 3 {{cannot convert value of type 'Int?' to expected element type 'Int'}}
1103
1104
$0 && $1 ? $0 + $1 :($0 ? $0 :($1 ? $1 :nil))
1104
-
// expected-error@-1 {{binary operator '+' cannot be applied to two 'Int?' operands}}
1105
-
// expected-error@-2 4 {{optional type 'Int?' cannot be used as a boolean; test for '!= nil' instead}}
1105
+
// expected-error@-1 2 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}}
1106
+
// expected-error@-2 {{value of optional type 'Int?' must be unwrapped to a value of type 'Int'}}
1107
+
// expected-error@-3 2 {{optional type 'Int?' cannot be used as a boolean; test for '!= nil' instead}}
1108
+
// expected-note@-4:16 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
1109
+
// expected-note@-5:16 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
ifStructWithoutExplicitConformance(a:1, b:"b")==StructWithoutExplicitConformance(a:2, b:"a"){} // expected-error{{binary operator '==' cannot be applied to two 'StructWithoutExplicitConformance' operands}}
117
+
// This diagnostic is about `Equatable` because it's considered the best possible solution among other ones for operator `==`.
118
+
ifStructWithoutExplicitConformance(a:1, b:"b")==StructWithoutExplicitConformance(a:2, b:"a"){} // expected-error{{referencing operator function '==' on 'Equatable' requires that 'StructWithoutExplicitConformance' conform to 'Equatable'}}
118
119
}
119
120
120
121
// Structs with non-hashable/equatable stored properties don't derive conformance.
0 commit comments