mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This commit adds a new rule to `isDeclAsSpecializedAs` in order to favour a member on a concrete type over a protocol member. This rule is effectively an extension of the existing rule that prefers concrete type members over protocol extension members.
28 lines
465 B
Swift
28 lines
465 B
Swift
// RUN: %target-typecheck-verify-swift -swift-version 5
|
|
|
|
class A<T> {
|
|
var foo: Int? { return 42 }
|
|
func baz() -> T { fatalError() }
|
|
func fiz() -> Int { return 42 }
|
|
}
|
|
|
|
protocol P1 {
|
|
associatedtype T
|
|
var foo: Int? { get }
|
|
func baz() -> T
|
|
func fiz() -> Int
|
|
}
|
|
|
|
protocol P2 : P1 {
|
|
var bar: Int? { get }
|
|
}
|
|
|
|
extension P2 where Self: A<Int> {
|
|
var bar: Int? {
|
|
guard let foo = foo else { return 0 }
|
|
_ = foo
|
|
let _ = baz()
|
|
return fiz()
|
|
}
|
|
}
|