mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Even dynamically casting a generic parameter to a protocol type is only guaranteed to succeed for conformances available at build time. Since we can't express conditional availability of conformances yet, this part of the test is useless, so redo it.
49 lines
684 B
Swift
49 lines
684 B
Swift
|
|
public func getVersion() -> Int {
|
|
#if BEFORE
|
|
return 0
|
|
#else
|
|
return 1
|
|
#endif
|
|
}
|
|
|
|
public struct AddConformance {
|
|
public init() {
|
|
x = 0
|
|
y = 0
|
|
}
|
|
|
|
public var x: Int
|
|
public var y: Int
|
|
|
|
public var z: Int {
|
|
get { return x + y }
|
|
set {
|
|
x = newValue / 2
|
|
y = newValue - x
|
|
}
|
|
}
|
|
}
|
|
|
|
public protocol PointLike {
|
|
var x: Int { get set }
|
|
var y: Int { get set }
|
|
}
|
|
|
|
public protocol Point3DLike {
|
|
var z: Int { get set }
|
|
}
|
|
|
|
#if AFTER
|
|
extension AddConformance : PointLike {}
|
|
extension AddConformance : Point3DLike {}
|
|
#endif
|
|
|
|
public func workWithPointLike<T>(t: T) -> Int {
|
|
if let p = t as? PointLike {
|
|
return p.x * p.y
|
|
} else {
|
|
return 0
|
|
}
|
|
}
|