[ConstraintSystem] Detect and diagnose missing generic arguments

Introduce a fix to detect and diagnose situations when omitted
generic arguments couldn't be deduced by the solver based on
the enclosing context.

Example:

```swift
struct S<T> {
}

_ = S() // There is not enough context to deduce `T`
```

Resolves: rdar://problem/51203824
This commit is contained in:
Pavel Yaskevich
2019-05-29 15:21:15 -07:00
parent 636b4ceeb2
commit c30845fa74
24 changed files with 342 additions and 84 deletions

View File

@@ -1,12 +1,13 @@
// RUN: %target-typecheck-verify-swift
struct MyCollection<Element> { // expected-note {{'Element' declared as parameter to type 'MyCollection'}}
func map<T>(_ transform: (Element) -> T) -> MyCollection<T> {
func map<T>(_ transform: (Element) -> T) -> MyCollection<T> { // expected-note 2 {{in call to function 'map'}}
fatalError("implement")
}
}
MyCollection.map // expected-error{{generic parameter 'Element' could not be inferred}} expected-note {{explicitly specify the generic arguments to fix this issue}} {{13-13=<Any>}}
// expected-error@-1 {{generic parameter 'T' could not be inferred}}
let a = MyCollection<Int>()
a.map // expected-error{{generic parameter 'T' could not be inferred}}