|
1 | 1 | // RUN: %empty-directory(%t) |
2 | | -// RUN: %target-build-swift -Xfrontend -disable-availability-checking %s -o %t/a.out |
| 2 | +// RUN: %target-build-swift %s -o %t/a.out |
3 | 3 | // RUN: %target-run %t/a.out | %FileCheck %s |
4 | 4 |
|
5 | 5 | // REQUIRES: executable_test |
6 | 6 | // REQUIRES: objc_interop |
7 | 7 |
|
8 | 8 | protocol MyProtocol {} |
9 | 9 |
|
| 10 | +@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) |
10 | 11 | func returnsClass1() -> some MyProtocol { |
11 | 12 | class MyClass1: MyProtocol {} |
12 | 13 | return MyClass1() |
13 | 14 | } |
14 | 15 |
|
15 | | -var returnsClass2: some MyProtocol { |
16 | | - class MyClass2: MyProtocol {} |
17 | | - return MyClass2() |
| 16 | +@available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) |
| 17 | +struct Outer { |
| 18 | + static var returnsClass2: some MyProtocol { |
| 19 | + class MyClass2: MyProtocol {} |
| 20 | + return MyClass2() |
| 21 | + } |
18 | 22 | } |
19 | 23 |
|
20 | | -print(returnsClass1()) |
21 | 24 | // CHECK: a.(unknown context at ${{[0-9a-z]+}}).(unknown context at ${{[0-9a-z]+}}).MyClass1 |
22 | | - |
23 | | -print(returnsClass2) |
24 | | -// CHECK: a.(unknown context at ${{[0-9a-z]+}}).(unknown context at ${{[0-9a-z]+}}).MyClass2 |
| 25 | +// CHECK: a.Outer.(unknown context at ${{[0-9a-z]+}}).(unknown context at ${{[0-9a-z]+}}).MyClass2 |
| 26 | +if #available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) { |
| 27 | + print(returnsClass1()) |
| 28 | + print(Outer.returnsClass2) |
| 29 | +} else { |
| 30 | + // Make FileCheck happy if this test runs on an older OS. |
| 31 | + print("a.(unknown context at $0).(unknown context at $0).MyClass1") |
| 32 | + print("a.Outer.(unknown context at $0).(unknown context at $0).MyClass2") |
| 33 | +} |
0 commit comments