|
1 | 1 | // RUN: %target-swift-frontend -typecheck -disable-availability-checking -dump-ast -enable-experimental-opaque-type-erasure %s | %FileCheck %s |
2 | 2 |
|
3 | | -class AnyP: P { |
4 | | - init<T: P>(erasing: T) {} |
| 3 | +public struct AnyP: P { |
| 4 | + public init<T: P>(erasing: T) {} |
5 | 5 | } |
6 | 6 |
|
7 | 7 | @_typeEraser(AnyP) |
8 | | -protocol P {} |
| 8 | +public protocol P {} |
9 | 9 |
|
10 | | -struct ConcreteP: P, Hashable {} |
| 10 | +public struct ConcreteP: P, Hashable { |
| 11 | + public init() {} |
| 12 | +} |
11 | 13 |
|
12 | 14 | // CHECK-LABEL: testTypeErased |
13 | | -func testTypeErased() -> some P { |
| 15 | +@inlinable public func testTypeErased() -> some P { |
14 | 16 | // CHECK: underlying_to_opaque_expr{{.*}}"some P" |
15 | 17 | // CHECK-NEXT: call_expr implicit type="AnyP" |
16 | 18 | ConcreteP() |
17 | 19 | } |
| 20 | + |
| 21 | +// Check with -enable-experimental-opaque-type-erasure |
| 22 | + |
| 23 | +// RUN: %empty-directory(%t) |
| 24 | +// RUN: %target-swift-emit-module-interface(%t/test1/erasure.swiftinterface) %s -module-name erasure -enable-experimental-opaque-type-erasure -enable-library-evolution -disable-availability-checking |
| 25 | +// RUN: %FileCheck %s --check-prefix CHECK-INTERFACE < %t/test1/erasure.swiftinterface |
| 26 | +// CHECK-INTERFACE: swift-module-flags:{{.*}} -enable-experimental-opaque-type-erasure |
| 27 | + |
| 28 | +// RUN: %target-swift-frontend -disable-availability-checking -I %t/test1/ -emit-sil %S/Inputs/import_with_opaque_type_erasure.swift | %FileCheck %s --check-prefix CHECK-UNDERLYING-TYPE |
| 29 | +// CHECK-UNDERLYING-TYPE-LABEL: s31import_with_opaque_type_erasure6erasedQrvg |
| 30 | +// CHECK-UNDERLYING-TYPE: bb0(%0 : $*AnyP): |
| 31 | +// CHECK-UNDERLYING-TYPE: function_ref @$s7erasure14testTypeErasedQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <AnyP> |
| 32 | + |
| 33 | + |
| 34 | +// Check with -enable-experimental-feature OpaqueTypeErasure |
| 35 | + |
| 36 | +// RUN: %target-swift-emit-module-interface(%t/test2/erasure.swiftinterface) %s -module-name erasure -enable-experimental-feature OpaqueTypeErasure -enable-library-evolution -disable-availability-checking |
| 37 | +// RUN: %FileCheck %s --check-prefix CHECK-INTERFACE2 < %t/test2/erasure.swiftinterface |
| 38 | +// CHECK-INTERFACE2: swift-module-flags:{{.*}} -enable-experimental-feature OpaqueTypeErasure |
| 39 | + |
| 40 | +// RUN: %target-swift-frontend -disable-availability-checking -I %t/test2/ -emit-sil %S/Inputs/import_with_opaque_type_erasure.swift | %FileCheck %s --check-prefix CHECK-UNDERLYING-TYPE2 |
| 41 | +// CHECK-UNDERLYING-TYPE2-LABEL: s31import_with_opaque_type_erasure6erasedQrvg |
| 42 | +// CHECK-UNDERLYING-TYPE2: bb0(%0 : $*AnyP): |
| 43 | +// CHECK-UNDERLYING-TYPE2: function_ref @$s7erasure14testTypeErasedQryF : $@convention(thin) @substituted <τ_0_0> () -> @out τ_0_0 for <AnyP> |
0 commit comments