[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

@@ -49,32 +49,32 @@ func mismatchedAppends<T, U, V>(readOnlyLeft: KeyPath<T, U>,
readOnlyRight: KeyPath<U, V>,
writableRight: WritableKeyPath<U, V>,
referenceRight: ReferenceWritableKeyPath<U, V>){
// expected-error@+1{{}}
_ = readOnlyRight.appending(path: readOnlyLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'KeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = readOnlyRight.appending(path: writableLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'KeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = readOnlyRight.appending(path: referenceLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'KeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = writableRight.appending(path: readOnlyLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'WritableKeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = writableRight.appending(path: writableLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'WritableKeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = writableRight.appending(path: referenceLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'WritableKeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = referenceRight.appending(path: readOnlyLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'ReferenceWritableKeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = referenceRight.appending(path: writableLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'ReferenceWritableKeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
// expected-error@+1{{}}
_ = referenceRight.appending(path: referenceLeft)
// expected-error@-1 {{referencing instance method 'appending(path:)' on '_AppendKeyPath' requires the types 'ReferenceWritableKeyPath<U, V>' and 'AnyKeyPath' be equivalent}}
}
func partialAppends<T, U, V>(partial: PartialKeyPath<T>,