Files
swift-mirror/test/Constraints/rdar39401774.swift
Hamish Knight 9268fcd6ae [CSRanking] Swift 4.1 compatibility hack for favouring properties on concrete types over protocols
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.
2018-08-24 17:09:58 +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()
}
}