mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Code like that is usually indicative of programmer error, and does not round-trip through module interface files since there is no source syntax to refer to an outer generic parameter. For source compatibility this is a warning, but becomes an error with -swift-version 6. Fixes rdar://problem/108385980 and https://github.com/apple/swift/issues/62767.
27 lines
619 B
Swift
27 lines
619 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// https://github.com/apple/swift/issues/53296
|
|
|
|
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<U>() -> [U] {
|
|
return []
|
|
}
|
|
}
|