mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously in situations like:
```swift
protocol P {}
struct S<T: P> {
var value: T
}
_ = S(value: 42)
```
Diagnostic has reported a problem as related to "reference" to `init`
but the failing generic type requirement belongs to `S`, so a
better diagnostic in such case should mention `generic struct S`.
18 lines
339 B
Swift
18 lines
339 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol P {}
|
|
struct S<V> where V: P { // expected-note {{where 'V' = 'Double'}}
|
|
var value: V
|
|
}
|
|
|
|
struct A {
|
|
subscript<T>(_ v: S<T>) -> A {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
func foo(_ v: Double) {
|
|
_ = A()[S(value: v)]
|
|
// expected-error@-1 {{generic struct 'S' requires that 'Double' conform to 'P'}}
|
|
}
|