|
1 |
| -// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.15 -emit-ir %s -swift-version 5 | %IRGenFileCheck %s |
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.15 -emit-module -emit-module-path=%t/opaque_result_with_conditional_availability_types.swiftmodule %S/Inputs/opaque_result_with_conditional_availability_types.swift |
| 3 | +// RUN: %target-build-swift -target %target-cpu-apple-macosx10.15 -c -parse-as-library -o %t/opaque_result_with_conditional_availability_types.o %S/Inputs/opaque_result_with_conditional_availability_types.swift |
| 4 | +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.15 -I%t -emit-ir %s -swift-version 5 | %IRGenFileCheck %s |
2 | 5 | // REQUIRES: OS=macosx
|
3 | 6 |
|
| 7 | +import opaque_result_with_conditional_availability_types |
| 8 | + |
4 | 9 | protocol P {
|
5 | 10 | func hello()
|
6 | 11 | }
|
@@ -173,3 +178,37 @@ func test_multiple_generic<T: P>(_ t: T) -> some P {
|
173 | 178 | // CHECK: universal: ; preds = %cond-0-0
|
174 | 179 | // CHECK-NEXT: ret i8** {{.*}} @"$s43opaque_result_with_conditional_availability1CVAA1PAAWP"
|
175 | 180 | // CHECK-NEXT: }
|
| 181 | + |
| 182 | + |
| 183 | +// rdar://103179745 |
| 184 | +struct LocalStruct: SomeProtocol { |
| 185 | + func foo() -> some SomeProtocol { |
| 186 | + return self |
| 187 | + } |
| 188 | +} |
| 189 | + |
| 190 | +func test_cross_module() -> some SomeProtocol { |
| 191 | + if #available(macOS 100, *) { |
| 192 | + return PublicStruct(LocalStruct()).modify() |
| 193 | + } else { |
| 194 | + return PublicStruct(LocalStruct()) |
| 195 | + } |
| 196 | +} |
| 197 | + |
| 198 | +// CHECK: define private i8** @"get_underlying_witness 43opaque_result_with_conditional_availabilityAA17test_cross_moduleQryFQOx0a1_b1_c1_d1_E6_types12SomeProtocolHC"(i8* %0) |
| 199 | +// CHECK-NEXT: entry: |
| 200 | +// CHECK-NEXT: %1 = alloca { %swift.type*, i8** }, align 8 |
| 201 | +// CHECK-NEXT: br label %conditional-0 |
| 202 | +// CHECK: conditional-0: ; preds = %entry |
| 203 | +// CHECK-NEXT: br label %cond-0-0 |
| 204 | +// CHECK: cond-0-0: ; preds = %conditional-0 |
| 205 | +// CHECK: %{{.*}} = call i32 @__isPlatformVersionAtLeast(i32 1, i32 100, i32 0, i32 0) |
| 206 | +// CHECK: %{{.*}} = icmp ne i32 %{{.*}}, 0 |
| 207 | +// CHECK: br i1 %{{.*}}, label %result-0, label %universal |
| 208 | +// CHECK: result-0: ; preds = %cond-0-0 |
| 209 | +// CHECK-NEXT: %{{.*}} = call i8** @"$s49opaque_result_with_conditional_availability_types12PublicStructVAcA12SomeProtocolAAWl"() |
| 210 | +// CHECK: ret i8** %{{.*}} |
| 211 | +// CHECK: universal: ; preds = %cond-0-0 |
| 212 | +// CHECK-NEXT: [[R0:%.*]] = call i8** @"$s49opaque_result_with_conditional_availability_types12PublicStructVAcA12SomeProtocolAAWl"() |
| 213 | +// CHECK-NEXT: ret i8** [[R0]] |
| 214 | +// CHECK: } |
0 commit comments