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
Extend callee diagnoses to non-conforming complex args including generics.
Previously, type checking arguments worked fine if the entire arg was
UnresolvedType, but if the type just contained UnresolvedType, the
constraint system always failed via explicitly constraining to
unresolved.
Now in TypeCheckConstraints, if the solution allows for free variables
that are UnresolvedType, then also convert any incoming UnresolvedTypes
into variables. At worst, in the solution these just get converted back
into the same Unresolved that they started with.
This change allows for incorrect tuple/function type possibilities to
make it back out to CSDiag, where they can be more precisely diagnosed
with callee info. The rest of the changes are to correctly figure
out the failure info when evaluating more types of Types.
New diagnosis for a partial part of an arg type not confroming. Tests
added for that. Expected errors changed in several places where we
now get real types in the diagnosis instead of '(_)' unresolved.
Copy file name to clipboardExpand all lines: test/Constraints/diagnostics.swift
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -87,11 +87,18 @@ for j in i.wibble(a, a) { // expected-error {{type 'A' does not conform to proto
87
87
func f6<T:P2>(g:Void->T)->(c:Int, i:T){
88
88
return(c:0, i:g())
89
89
}
90
+
90
91
func f7()->(c:Int, v:A){
91
92
letg:Void->A={returnA()}
92
93
returnf6(g) // expected-error {{cannot convert return expression of type '(c: Int, i: A)' to return type '(c: Int, v: A)'}}
93
94
}
94
95
96
+
func f8<T:P2>(n:T, _ f:(T)->T){}
97
+
f8(3, f4) // expected-error {{in argument type '(Int) -> Int', 'Int' does not conform to expected type 'P2'}}
98
+
typealiasTup=(Int,Double)
99
+
func f9(x:Tup)->Tup{return x }
100
+
f8((1,2.0), f9) // expected-error {{in argument type '(Tup) -> Tup', 'Tup' (aka '(Int, Double)') does not conform to expected type 'P2'}}
101
+
95
102
// <rdar://problem/19658691> QoI: Incorrect diagnostic for calling nonexistent members on literals
96
103
1.doesntExist(0) // expected-error {{value of type 'Int' has no member 'doesntExist'}}
97
104
[1,2,3].doesntExist(0) // expected-error {{value of type '[Int]' has no member 'doesntExist'}}
@@ -643,7 +650,7 @@ let a = safeAssign // expected-error {{generic parameter 'T' could not be inferr
643
650
644
651
// <rdar://problem/21692808> QoI: Incorrect 'add ()' fixit with trailing closure
645
652
func foo()->[Int]{
646
-
returnArray<Int>(count:1){ // expected-error {{cannot invoke initializer for type 'Array<Int>' with an argument list of type '(count: Int, () -> _)'}}
653
+
returnArray<Int>(count:1){ // expected-error {{cannot invoke initializer for type 'Array<Int>' with an argument list of type '(count: Int, () -> Int)'}}
647
654
// expected-note @-1 {{expected an argument list of type '(count: Int, repeatedValue: Element)'}}
0 commit comments