Files
swift-mirror/test/Constraints/rdar39401774.swift
Hamish Knight 286f16404b [CSRanking] Favour members on concrete types over protocol members
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.
2018-08-24 15:50:27 +01:00

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()
}
}