[CSDiagnostics] Diagnose contextual closure result mismatches via fixes

Let's keep track of type mismatch between type deduced
for the body of the closure vs. what is requested
contextually, it makes it much easier to diagnose
problems like:

```swift
func foo(_: () -> Int) {}
foo { "hello" }
```

Because we can pin-point problematic area of the source
when the rest of the system is consistent.

Resolves: rdar://problem/40537960
This commit is contained in:
Pavel Yaskevich
2018-11-07 14:23:11 -08:00
parent 6e938f8359
commit 66a79301b4
11 changed files with 241 additions and 79 deletions

View File

@@ -5,7 +5,7 @@ let ss = s[s.startIndex..<s.endIndex]
// CTP_Initialization
do {
let s1: String = { return ss }() // expected-error {{cannot convert value of type 'Substring' to specified type 'String'}} {{20-20=String(}} {{35-35=)}}
let s1: String = { return ss }() // expected-error {{cannot convert value of type 'Substring' to closure result type 'String'}} {{29-29=String(}} {{31-31=)}}
_ = s1
}