Files
swift-mirror/test/Interpreter/SDK/objc_dealloc.swift
Dmitri Hrybenko f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00

33 lines
714 B
Swift

// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: objc_interop
import Foundation
// Check that ObjC associated objects are cleaned up when attached to native
// Swift objects.
class Root {
deinit { print("deallocating root") }
}
class Associated {
deinit { print("deallocating associated") }
}
var token: Int8 = 0
// Hack to build with both older and newer SDKs.
// rdar://problem/19494514
extension UInt {
static let OBJC_ASSOCIATION_RETAIN_NONATOMIC: UInt = 1
}
autoreleasepool {
let root = Root()
objc_setAssociatedObject(root, &token, Associated(),
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
// CHECK: deallocating root
// CHECK-NEXT: deallocating associated