mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We have an SPI between the Swift compiler and Foundation based on the SWIFT_SDK_OVERLAY_FOUNDATION_EPOCH preprocessor macro that allows us to request the new API. rdar://20270080 tracks removing it. Swift SVN r26475
55 lines
1.1 KiB
Swift
55 lines
1.1 KiB
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
// <rdar://problem/17014037>
|
|
// REQUIRES: OS=macosx
|
|
|
|
import QuartzCore
|
|
|
|
class Canary: NSObject {
|
|
deinit {
|
|
println("died")
|
|
}
|
|
}
|
|
|
|
var CanaryAssocObjectHandle: UInt8 = 0
|
|
|
|
// Hack to build with both older and newer SDKs.
|
|
// rdar://problem/19494514
|
|
extension UInt {
|
|
static let OBJC_ASSOCIATION_RETAIN_NONATOMIC: UInt = 1
|
|
}
|
|
|
|
// Attach an associated object with a loud deinit so we can see that the
|
|
// error died.
|
|
func hangCanary(o: AnyObject) {
|
|
objc_setAssociatedObject(o, &CanaryAssocObjectHandle, Canary(),
|
|
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
|
}
|
|
|
|
class FooLayer: CALayer {
|
|
var black: CGColor
|
|
var white: CGColor = CGColorGetConstantColor(kCGColorWhite)
|
|
|
|
override init() {
|
|
black = CGColorGetConstantColor(kCGColorBlack)
|
|
super.init()
|
|
hangCanary(self)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
black = coder.decodeObjectForKey("black") as! CGColor
|
|
super.init(coder: coder)
|
|
}
|
|
|
|
override var description: String {
|
|
return "FooLayer"
|
|
}
|
|
}
|
|
|
|
if true {
|
|
let layer = FooLayer()
|
|
println("\(layer)")
|
|
}
|
|
|
|
// CHECK: FooLayer
|
|
// CHECK: died
|