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
[Diagnostics] Port explicit closure result contextual mismatch
Detect and diagnose a problem when explicitly specified closure
result type doesn't match what is expected by the context:
Example:
```swift
func foo(_: () -> Int) {}
foo { () -> String in "" } // `Int` vs. `String`
```
Copy file name to clipboardExpand all lines: test/Sema/immutability.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -656,8 +656,8 @@ func sr4214() {
656
656
letclosure={ val in val.x =7}as(inoutMutableSubscripts)->() // Ok
657
657
varv=MutableSubscripts()
658
658
closure(&v)
659
-
// FIXME: This diagnostic isn't really all that much better
660
-
// expected-error@+1 {{cannot convert value of type '(inout MutableSubscripts) -> ()' to expected argument type '(_) -> _'}}
659
+
// expected-error@+2 {{declared closure result '()' is incompatible with contextual type 'MutableSubscripts'}}
660
+
// expected-error@+1 {{cannot convert value of type '(inout MutableSubscripts) -> ()' to expected argument type '(MutableSubscripts) -> MutableSubscripts'}}
Copy file name to clipboardExpand all lines: test/Sema/substring_to_string_conversion_swift4.swift
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ do {
45
45
46
46
// CTP_ClosureResult
47
47
do{
48
-
[ss].map{(x:Substring)->Stringin x } // expected-error {{cannot convert value of type 'Substring' to closure result type 'String'}} {{42-42=String(}} {{43-43=)}}
48
+
[ss].map{(x:Substring)->Stringin x } // expected-error {{declared closure result 'Substring' is incompatible with contextual type 'String'}}
0 commit comments