Skip to content

Commit 53c4566

Browse files
authored
Merge pull request #82098 from tshortli/revert-availability-tests-move
Revert "Move some availability tests into a new test/Availability directory"
2 parents a5d92bc + de1017f commit 53c4566

File tree

61 files changed

+89
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+89
-88
lines changed

test/Constraints/availability.swift

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 4
2+
3+
// Ensure that we do not select the unavailable failable init as the
4+
// only solution and then fail to typecheck.
5+
protocol P {}
6+
7+
class C : P {
8+
@available(swift, obsoleted: 4)
9+
public init?(_ c: C) {
10+
}
11+
12+
public init<T : P>(_ c: T) {}
13+
}
14+
15+
func f(c: C) {
16+
let _: C? = C(c)
17+
}
18+
19+
// rdar://problem/60047439 - unable to disambiguate expression based on availability
20+
func test_contextual_member_with_availability() {
21+
struct A {
22+
static var foo: A = A()
23+
}
24+
25+
struct B {
26+
@available(*, unavailable, renamed: "bar")
27+
static var foo: B = B()
28+
}
29+
30+
struct Test {
31+
init(_: A) {}
32+
init(_: B) {}
33+
}
34+
35+
_ = Test(.foo) // Ok
36+
}
37+
38+
@available(*, unavailable)
39+
func unavailableFunction(_ x: Int) -> Bool { true } // expected-note {{'unavailableFunction' has been explicitly marked unavailable here}}
40+
41+
/// https://github.com/apple/swift/issues/55700
42+
/// Availability checking not working in the `where` clause of a `for` loop
43+
func f_55700(_ arr: [Int]) {
44+
for x in arr where unavailableFunction(x) {} // expected-error {{'unavailableFunction' is unavailable}}
45+
}
46+
47+
// rdar://101814209
48+
public struct Box<T> {
49+
@usableFromInline
50+
let value: T
51+
}
52+
53+
@available(macOS, unavailable)
54+
extension Box where T == Int {
55+
@usableFromInline
56+
init(value: T) {
57+
self.value = value
58+
}
59+
}
60+
61+
@available(macOS, unavailable)
62+
@_alwaysEmitIntoClient public func aeicFunction() {
63+
// Select the unavailable @usableFromInline init over the synthesized internal
64+
// memberwise initializer.
65+
_ = Box(value: 42)
66+
}
67+
68+
// rdar://87403752 - ambiguity with member declared in unavailable extension
69+
struct HasUnavailableExtesion {
70+
}
71+
72+
@available(*, unavailable)
73+
extension HasUnavailableExtesion {
74+
static var foo: Self = HasUnavailableExtesion()
75+
}
76+
77+
func test_contextual_member_with_unavailable_extension() {
78+
struct A {
79+
static var foo: A = A()
80+
}
81+
82+
struct Test {
83+
init(_: A) {}
84+
init(_: HasUnavailableExtesion) {}
85+
}
86+
87+
_ = Test(.foo) // Ok `A.foo` since `foo` from `HasUnavailableExtesion` is unavailable
88+
}

test/Misc/verify-swift-feature-testing.test-sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ EXCEPTIONAL_FILES = [
2020
# Tests for ModuleInterfaceExportAs being ignored
2121
pathlib.Path("test/ModuleInterface/swift-export-as.swift"),
2222
# Uses the pseudo-feature AvailabilityMacro=
23-
pathlib.Path("test/Availability/availability_define.swift"),
23+
pathlib.Path("test/Sema/availability_define.swift"),
2424
# Tests behavior when you try to use a feature without enabling it
2525
pathlib.Path("test/attr/feature_requirement.swift"),
2626
# Tests completion with features both enabled and disabled

test/Availability/availability.swift renamed to test/Sema/availability.swift

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -86,90 +86,3 @@ struct DeferBody {
8686
// expected-error@-1 {{'No' is unavailable}}
8787
}
8888
}
89-
90-
// Ensure that we do not select the unavailable failable init as the
91-
// only solution and then fail to typecheck.
92-
protocol P {}
93-
94-
class C : P {
95-
@available(swift, obsoleted: 4)
96-
public init?(_ c: C) {
97-
}
98-
99-
public init<T : P>(_ c: T) {}
100-
}
101-
102-
func f(c: C) {
103-
let _: C? = C(c)
104-
}
105-
106-
// rdar://problem/60047439 - unable to disambiguate expression based on availability
107-
func test_contextual_member_with_availability() {
108-
struct A {
109-
static var foo: A = A()
110-
}
111-
112-
struct B {
113-
@available(*, unavailable, renamed: "bar")
114-
static var foo: B = B()
115-
}
116-
117-
struct Test {
118-
init(_: A) {}
119-
init(_: B) {}
120-
}
121-
122-
_ = Test(.foo) // Ok
123-
}
124-
125-
@available(*, unavailable)
126-
func unavailableFunction(_ x: Int) -> Bool { true } // expected-note {{'unavailableFunction' has been explicitly marked unavailable here}}
127-
128-
/// https://github.com/apple/swift/issues/55700
129-
/// Availability checking not working in the `where` clause of a `for` loop
130-
func f_55700(_ arr: [Int]) {
131-
for x in arr where unavailableFunction(x) {} // expected-error {{'unavailableFunction' is unavailable}}
132-
}
133-
134-
// rdar://101814209
135-
public struct Box<T> {
136-
@usableFromInline
137-
let value: T
138-
}
139-
140-
@available(macOS, unavailable)
141-
extension Box where T == Int {
142-
@usableFromInline
143-
init(value: T) {
144-
self.value = value
145-
}
146-
}
147-
148-
@available(macOS, unavailable)
149-
@_alwaysEmitIntoClient public func aeicFunction() {
150-
// Select the unavailable @usableFromInline init over the synthesized internal
151-
// memberwise initializer.
152-
_ = Box(value: 42)
153-
}
154-
155-
// rdar://87403752 - ambiguity with member declared in unavailable extension
156-
struct HasUnavailableExtesion {
157-
}
158-
159-
@available(*, unavailable)
160-
extension HasUnavailableExtesion {
161-
static var foo: Self = HasUnavailableExtesion()
162-
}
163-
164-
func test_contextual_member_with_unavailable_extension() {
165-
struct A {
166-
static var foo: A = A()
167-
}
168-
169-
struct Test {
170-
init(_: A) {}
171-
init(_: HasUnavailableExtesion) {}
172-
}
173-
174-
_ = Test(.foo) // Ok `A.foo` since `foo` from `HasUnavailableExtesion` is unavailable
175-
}

0 commit comments

Comments
 (0)