Files
swift-mirror/validation-test/Evolution/Inputs/struct_resilient_add_conformance.swift
Slava Pestov c823974f85 Fix add_conformance evolution tests to pass with optimized builds
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.
2016-02-13 18:21:58 -08:00

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