mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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
28 lines
544 B
Swift
28 lines
544 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// Simple enumeration type
|
|
enum E1 {
|
|
case First
|
|
case Second(Int)
|
|
case Third(Int, Double)
|
|
case `default`
|
|
}
|
|
|
|
var e1: E1 = .First
|
|
e1 = .Second(5)
|
|
e1 = .Third(5, 3.14159)
|
|
|
|
e1 = .default // SE-0071
|
|
|
|
// Generic enumeration type
|
|
enum E2<T> { // expected-note {{'T' declared as parameter to type 'E2'}}
|
|
case First
|
|
case Second(T)
|
|
}
|
|
|
|
var e2a: E2<Int> = .First
|
|
e2a = .Second(5)
|
|
var e2b: E2 = .Second(5)
|
|
e2b = .First
|
|
var e2c: E2 = .First // expected-error{{generic parameter 'T' could not be inferred}}
|