Files
swift-mirror/test/Constraints/sr10906.swift
Pavel Yaskevich 4bd5a1e4e1 [Diagnostics] Clarify requirement failure source when it's anchored at assignment
While trying to fetch owner type for generic requirement failures
anchored at assignment expression, use assignment source as an anchor
because that's where requirements come from - conversion from source
type to destination.

Resolves: rdar://problem/51587755
2019-06-11 11:59:46 -07:00

25 lines
571 B
Swift

// RUN: %target-typecheck-verify-swift
protocol ViewDataSource: class {
func foo<T>() -> [T]
}
class View {
weak var delegate: ViewDataSource?
}
final class ViewController<T> {
let view = View()
init() {
view.delegate = self
// expected-error@-1 {{generic class 'ViewController' requires the types 'T' and 'String' be equivalent}}
}
}
extension ViewController: ViewDataSource where T == String {
// expected-note@-1 {{requirement from conditional conformance of 'ViewController<T>' to 'ViewDataSource'}}
func foo<T>() -> [T] {
return []
}
}