Files
swift-mirror/test/Interpreter/SDK/objc_dealloc.swift
Jordan Rose 006a016e04 [test] Remove a hackaround for supporting last year's SDKs.
We have much stronger dependencies on this year's SDKs now.

rdar://problem/19494514

Swift SVN r29451
2015-06-17 17:52:42 +00:00

28 lines
590 B
Swift

// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: executable_test
// 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
autoreleasepool {
let root = Root()
objc_setAssociatedObject(root, &token, Associated(),
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
// CHECK: deallocating root
// CHECK-NEXT: deallocating associated