mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Changes in shadowing behaviour by #15412 caused a property on a concrete type to no longer shadow a protocol property member, which created unintentional ambiguities in 4.2. This commit ensures we at least keep these cases unambiguous in Swift 5 under Swift 4 compatibility mode. This is intentionally narrow in order to best preserve source compatibility under Swift 4 mode by ensuring we don't introduce any new ambiguities. Resolves SR-7425, SR-7940 & SR-8343.
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()
|
|
}
|
|
}
|