|
1 | 1 |
|
2 | 2 |
|
3 | 3 | // RUN: %empty-directory(%t)
|
4 |
| -// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-experimental-feature LayoutStringValueWitnessesInstantiation -enable-type-layout -enable-autolinking-runtime-compatibility-bytecode-layouts -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift |
5 |
| -// RUN: %target-build-swift -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnessesInstantiation -Xfrontend -enable-type-layout -Xfrontend -enable-autolinking-runtime-compatibility-bytecode-layouts -c -parse-as-library -o %t/layout_string_witnesses_types.o %S/Inputs/layout_string_witnesses_types.swift |
6 |
| -// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-experimental-feature LayoutStringValueWitnessesInstantiation -enable-library-evolution -enable-autolinking-runtime-compatibility-bytecode-layouts -emit-module -emit-module-path=%t/layout_string_witnesses_types_resilient.swiftmodule %S/Inputs/layout_string_witnesses_types_resilient.swift |
7 |
| -// RUN: %target-build-swift -g -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnessesInstantiation -Xfrontend -enable-library-evolution -c -parse-as-library -o %t/layout_string_witnesses_types_resilient.o %S/Inputs/layout_string_witnesses_types_resilient.swift |
8 |
| -// RUN: %target-build-swift -g -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnessesInstantiation -Xfrontend -enable-type-layout -Xfrontend -enable-autolinking-runtime-compatibility-bytecode-layouts -module-name layout_string_witnesses_dynamic %t/layout_string_witnesses_types.o %t/layout_string_witnesses_types_resilient.o -I %t -o %t/main %s |
| 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 -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift |
| 5 | +// RUN: %target-build-swift -Xfrontend -prespecialize-generic-metadata -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 -enable-autolinking-runtime-compatibility-bytecode-layouts -c -parse-as-library -o %t/layout_string_witnesses_types.o %S/Inputs/layout_string_witnesses_types.swift |
| 6 | +// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-experimental-feature LayoutStringValueWitnessesInstantiation -enable-layout-string-value-witnesses -enable-layout-string-value-witnesses-instantiation -enable-library-evolution -enable-autolinking-runtime-compatibility-bytecode-layouts -emit-module -emit-module-path=%t/layout_string_witnesses_types_resilient.swiftmodule %S/Inputs/layout_string_witnesses_types_resilient.swift |
| 7 | +// 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-library-evolution -c -parse-as-library -o %t/layout_string_witnesses_types_resilient.o %S/Inputs/layout_string_witnesses_types_resilient.swift |
| 8 | +// 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 -Xfrontend -enable-autolinking-runtime-compatibility-bytecode-layouts -module-name layout_string_witnesses_dynamic %t/layout_string_witnesses_types.o %t/layout_string_witnesses_types_resilient.o -I %t -o %t/main %s |
9 | 9 | // RUN: %target-codesign %t/main
|
10 | 10 | // RUN: %target-run %t/main | %FileCheck %s --check-prefix=CHECK -check-prefix=CHECK-%target-os
|
11 | 11 |
|
@@ -52,6 +52,85 @@ func testGeneric() {
|
52 | 52 |
|
53 | 53 | testGeneric()
|
54 | 54 |
|
| 55 | +func testPrespecializedAnyObject() { |
| 56 | + let ptr = UnsafeMutablePointer<PrespecializedStruct<AnyObject>>.allocate(capacity: 1) |
| 57 | + |
| 58 | + do { |
| 59 | + let x = PrespecializedStruct<AnyObject>(x: SimpleClass(x: 23)) |
| 60 | + testInit(ptr, to: x) |
| 61 | + } |
| 62 | + |
| 63 | + do { |
| 64 | + let y = PrespecializedStruct<AnyObject>(x: SimpleClass(x: 32)) |
| 65 | + |
| 66 | + // CHECK-NEXT: Before deinit |
| 67 | + print("Before deinit") |
| 68 | + |
| 69 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 70 | + testAssign(ptr, from: y) |
| 71 | + } |
| 72 | + |
| 73 | + // CHECK-NEXT: Before deinit |
| 74 | + print("Before deinit") |
| 75 | + |
| 76 | + |
| 77 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 78 | + testDestroy(ptr) |
| 79 | + |
| 80 | + ptr.deallocate() |
| 81 | +} |
| 82 | + |
| 83 | +testPrespecializedAnyObject() |
| 84 | + |
| 85 | +func testPrespecializedSimpleClass() { |
| 86 | + let ptr = UnsafeMutablePointer<PrespecializedStruct<SimpleClass>>.allocate(capacity: 1) |
| 87 | + |
| 88 | + do { |
| 89 | + let x = PrespecializedStruct<SimpleClass>(x: SimpleClass(x: 23)) |
| 90 | + testInit(ptr, to: x) |
| 91 | + } |
| 92 | + |
| 93 | + do { |
| 94 | + let y = PrespecializedStruct<SimpleClass>(x: SimpleClass(x: 32)) |
| 95 | + |
| 96 | + // CHECK-NEXT: Before deinit |
| 97 | + print("Before deinit") |
| 98 | + |
| 99 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 100 | + testAssign(ptr, from: y) |
| 101 | + } |
| 102 | + |
| 103 | + // CHECK-NEXT: Before deinit |
| 104 | + print("Before deinit") |
| 105 | + |
| 106 | + |
| 107 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 108 | + testDestroy(ptr) |
| 109 | + |
| 110 | + ptr.deallocate() |
| 111 | +} |
| 112 | + |
| 113 | +testPrespecializedSimpleClass() |
| 114 | + |
| 115 | + |
| 116 | +func testPrespecializedInt() { |
| 117 | + let ptr = UnsafeMutablePointer<PrespecializedStruct<Int>>.allocate(capacity: 1) |
| 118 | + |
| 119 | + do { |
| 120 | + let x = PrespecializedStruct<Int>(x: 23) |
| 121 | + testInit(ptr, to: x) |
| 122 | + } |
| 123 | + |
| 124 | + do { |
| 125 | + let y = PrespecializedStruct<Int>(x: 32) |
| 126 | + testAssign(ptr, from: y) |
| 127 | + } |
| 128 | + |
| 129 | + ptr.deallocate() |
| 130 | +} |
| 131 | + |
| 132 | +testPrespecializedInt() |
| 133 | + |
55 | 134 | func testGenericTuple() {
|
56 | 135 | let ptr = allocateInternalGenericPtr(of: GenericTupleWrapper<TestClass>.self)
|
57 | 136 |
|
|
0 commit comments