Commit Graph

6 Commits

Author SHA1 Message Date
Anthony Latsis
a07f2b4889 Sema, DiagQoI: Fix and tailor diagnosis of explicit closure result type conflicts 2022-06-20 22:20:32 +03:00
Pavel Yaskevich
431ca98246 [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`
```
2019-11-13 14:05:59 -08:00
Ben Cohen
fc7830a4ed Remove Swift 3-only Compatibility Shims (#21019) 2018-12-04 18:22:27 -08:00
Pavel Yaskevich
66a79301b4 [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
2018-11-07 14:28:50 -08:00
John McCall
0730a27f5b Compute the expression range correctly for substring-to-string fixits.
rdar://33474838
2017-07-26 19:10:55 -04:00
Mark Lacey
70c0e85581 Diagnose Substring-to-String conversions resulting from subscripting.
When we have a Substring-to-String conversion as a result of
subscripting in a context expecting String, we emit the rather generic
and unactionable availability diagnostic.

Instead, to aid in migration, emit a highly specialized diagnostic and
fixit when we're compiling for -swift-version 4.
2017-05-14 23:28:36 -07:00