|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// |
| 3 | +// RUN: %target-clang -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o |
| 4 | +// RUN: %target-swift-frontend -prespecialize-generic-metadata -enable-experimental-feature LayoutStringValueWitnesses -enable-experimental-feature LayoutStringValueWitnessesInstantiation -enable-layout-string-value-witnesses -enable-layout-string-value-witnesses-instantiation -enable-type-layout -enable-autolinking-runtime-compatibility-bytecode-layouts -parse-stdlib -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift |
| 5 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(layout_string_witnesses_types)) -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnessesInstantiation -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -enable-layout-string-value-witnesses-instantiation -Xfrontend -enable-type-layout -Xfrontend -parse-stdlib -parse-as-library %S/Inputs/layout_string_witnesses_types.swift |
| 6 | +// RUN: %target-build-swift -g -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnessesInstantiation -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -enable-layout-string-value-witnesses-instantiation -Xfrontend -enable-type-layout -parse-stdlib -module-name layout_string_witnesses_dynamic -llayout_string_witnesses_types -L%t -I %S/Inputs/ObjCClasses/ %t/ObjCClasses.o -I %t -o %t/main %s %target-rpath(%t) |
| 7 | +// RUN: %target-codesign %t/main |
| 8 | +// RUN: %target-run %t/main %t/%target-library-name(layout_string_witnesses_types) | %FileCheck %s --check-prefix=CHECK |
| 9 | + |
| 10 | +// REQUIRES: executable_test |
| 11 | +// REQUIRES: objc_interop |
| 12 | + |
| 13 | +import Swift |
| 14 | +import layout_string_witnesses_types |
| 15 | +import ObjCClasses |
| 16 | +import Foundation |
| 17 | + |
| 18 | +func testNestedResilientObjc() { |
| 19 | + let ptr = allocateInternalGenericPtr(of: NestedWrapper<ObjCPrintOnDealloc>.self) |
| 20 | + |
| 21 | + do { |
| 22 | + let x = NestedWrapper<ObjCPrintOnDealloc>(x: .init(x: ObjCPrintOnDealloc()), y: .init(x: ObjCPrintOnDealloc())) |
| 23 | + testGenericInit(ptr, to: x) |
| 24 | + } |
| 25 | + |
| 26 | + do { |
| 27 | + let y = NestedWrapper<ObjCPrintOnDealloc>(x: .init(x: ObjCPrintOnDealloc()), y: .init(x: ObjCPrintOnDealloc())) |
| 28 | + // CHECK: Before deinit |
| 29 | + print("Before deinit") |
| 30 | + |
| 31 | + // CHECK-NEXT: ObjCPrintOnDealloc deinitialized! |
| 32 | + // CHECK-NEXT: ObjCPrintOnDealloc deinitialized! |
| 33 | + testGenericAssign(ptr, from: y) |
| 34 | + } |
| 35 | + |
| 36 | + // CHECK-NEXT: Before deinit |
| 37 | + print("Before deinit") |
| 38 | + |
| 39 | + // CHECK-NEXT: ObjCPrintOnDealloc deinitialized! |
| 40 | + // CHECK-NEXT: ObjCPrintOnDealloc deinitialized! |
| 41 | + testGenericDestroy(ptr, of: NestedWrapper<ObjCPrintOnDealloc>.self) |
| 42 | + |
| 43 | + ptr.deallocate() |
| 44 | +} |
| 45 | + |
| 46 | +testNestedResilientObjc() |
0 commit comments