Files
swift-mirror/test/Interpreter/SDK/CALayer.swift
Dmitri Hrybenko ab408d4dc3 Update the compiler and SDK overlay for nullability and generics in Foundation
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
2015-03-24 02:18:06 +00:00

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