Skip to content

Commit ff2a5e0

Browse files
committed
[NFC] test: Move unqualified init expression tests out of test/Parse
1 parent d7b52e9 commit ff2a5e0

File tree

2 files changed

+135
-134
lines changed

2 files changed

+135
-134
lines changed

test/Parse/init_deinit.swift

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -117,137 +117,3 @@ func barFunc() {
117117
return
118118
} ()
119119
}
120-
121-
// https://github.com/apple/swift/issues/43464
122-
123-
class Aaron {
124-
init(x: Int) {
125-
func foo() {
126-
// Make sure we recover and assume 'self.init'.
127-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{11-11=self.}}
128-
// expected-error@+1 {{type of expression is ambiguous without a type annotation}}
129-
_ = init
130-
}
131-
}
132-
convenience init() {
133-
// Make sure we recover and assume 'self.init'.
134-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{5-5=self.}}
135-
// expected-error@+1 {{cannot convert value of type 'Bool' to expected argument type 'Int'}}
136-
init(x: true)
137-
138-
// FIXME: self.init considered initializer delegation in nested function?
139-
// expected-error@+2 {{initializer delegation ('self.init') cannot be nested in another expression}}
140-
// expected-error@+1 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{22-22=self.}}
141-
func foo() { _ = init() }
142-
}
143-
144-
required init(y: Int) {}
145-
146-
static func aaronFn() {
147-
// Make sure we recover and assume 'self.init'.
148-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
149-
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
150-
_ = init(z: 0)
151-
}
152-
153-
// Make sure we recover and assume 'self.init'.
154-
// expected-error@+3 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{45-45=self.}}
155-
// expected-error@+2 {{cannot convert value of type 'Aaron' to specified type 'Int'}}
156-
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
157-
static var aaronVar: Aaron { let _: Int = init(z: 0) }
158-
}
159-
160-
class Theodosia: Aaron {
161-
init() {
162-
// Make sure we recover and assume 'super.init'.
163-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'super.'?}} {{5-5=super.}}
164-
// expected-error@+1 {{cannot convert value of type 'Bool' to expected argument type 'Int'}}
165-
init(x: true)
166-
167-
// Make sure we recover and assume 'self.init'.
168-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{22-22=self.}}
169-
// expected-error@+1 {{type of expression is ambiguous without a type annotation}}
170-
func foo() { _ = init }
171-
}
172-
173-
required init(y: Int) {}
174-
175-
static func theodosiaFn() {
176-
// Make sure we recover and assume 'self.init'.
177-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
178-
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
179-
_ = init(z: 0)
180-
181-
// FIXME: We could optimistically parse this as an expression instead
182-
// expected-error@+2 {{initializers may only be declared within a type}}
183-
// expected-error@+1 {{expected parameter type following ':'}}
184-
init(z: 0)
185-
}
186-
187-
static var theodosiaVar: Aaron {
188-
// Make sure we recover and assume 'self.init'.
189-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
190-
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
191-
_ = init(z: 0)
192-
}
193-
}
194-
195-
struct AaronStruct {
196-
init(x: Int) {}
197-
init() {
198-
// Make sure we recover and assume 'self.init'.
199-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{5-5=self.}}
200-
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
201-
init(y: 1)
202-
203-
func foo() {
204-
// Make sure we recover and assume 'self.init'.
205-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{11-11=self.}}
206-
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
207-
_ = init(y: 1)
208-
}
209-
}
210-
211-
static func aaronFn() {
212-
// Make sure we recover and assume 'self.init'.
213-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
214-
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
215-
_ = init(y: 1)
216-
217-
// FIXME: We could optimistically parse this as an expression instead
218-
// expected-error@+2 {{initializers may only be declared within a type}}
219-
// expected-error@+1 {{expected parameter type following ':'}}
220-
init(y: 1)
221-
}
222-
223-
static var aaronVar: Aaron {
224-
// Make sure we recover and assume 'self.init'.
225-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
226-
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
227-
_ = init(y: 1)
228-
229-
// FIXME: We could optimistically parse this as an expression instead
230-
// expected-error@+3 {{initializers may only be declared within a type}}
231-
// expected-error@+2 {{consecutive statements on a line must be separated by ';'}}
232-
// expected-error@+1 {{non-void function should return a value}}
233-
return init()
234-
}
235-
}
236-
237-
enum AaronEnum: Int {
238-
case A = 1
239-
240-
init(x: Int) {
241-
// Make sure we recover and assume 'self.init'.
242-
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{5-5=self.}}
243-
// expected-error@+1 {{cannot convert value of type 'String' to expected argument type 'Int'}}
244-
init(rawValue: "")!
245-
}
246-
}
247-
248-
do {
249-
func foo() {
250-
// expected-error@+1 {{initializer expression requires explicit access}} {none}}
251-
_ = init()
252-
}
253-
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// https://github.com/apple/swift/issues/43464
4+
5+
class Aaron {
6+
init(x: Int) {
7+
func foo() {
8+
// Make sure we recover and assume 'self.init'.
9+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{11-11=self.}}
10+
// expected-error@+1 {{type of expression is ambiguous without a type annotation}}
11+
_ = init
12+
}
13+
}
14+
convenience init() {
15+
// Make sure we recover and assume 'self.init'.
16+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{5-5=self.}}
17+
// expected-error@+1 {{cannot convert value of type 'Bool' to expected argument type 'Int'}}
18+
init(x: true)
19+
20+
// FIXME: self.init considered initializer delegation in nested function?
21+
// expected-error@+2 {{initializer delegation ('self.init') cannot be nested in another expression}}
22+
// expected-error@+1 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{22-22=self.}}
23+
func foo() { _ = init() }
24+
}
25+
26+
required init(y: Int) {}
27+
28+
static func aaronFn() {
29+
// Make sure we recover and assume 'self.init'.
30+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
31+
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
32+
_ = init(z: 0)
33+
}
34+
35+
// Make sure we recover and assume 'self.init'.
36+
// expected-error@+3 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{45-45=self.}}
37+
// expected-error@+2 {{cannot convert value of type 'Aaron' to specified type 'Int'}}
38+
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
39+
static var aaronVar: Aaron { let _: Int = init(z: 0) }
40+
}
41+
42+
class Theodosia: Aaron {
43+
init() {
44+
// Make sure we recover and assume 'super.init'.
45+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'super.'?}} {{5-5=super.}}
46+
// expected-error@+1 {{cannot convert value of type 'Bool' to expected argument type 'Int'}}
47+
init(x: true)
48+
49+
// Make sure we recover and assume 'self.init'.
50+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{22-22=self.}}
51+
// expected-error@+1 {{type of expression is ambiguous without a type annotation}}
52+
func foo() { _ = init }
53+
}
54+
55+
required init(y: Int) {}
56+
57+
static func theodosiaFn() {
58+
// Make sure we recover and assume 'self.init'.
59+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
60+
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
61+
_ = init(z: 0)
62+
63+
// FIXME: We could optimistically parse this as an expression instead
64+
// expected-error@+2 {{initializers may only be declared within a type}}
65+
// expected-error@+1 {{expected parameter type following ':'}}
66+
init(z: 0)
67+
}
68+
69+
static var theodosiaVar: Aaron {
70+
// Make sure we recover and assume 'self.init'.
71+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
72+
// expected-error@+1 {{incorrect argument label in call (have 'z:', expected 'y:')}}
73+
_ = init(z: 0)
74+
}
75+
}
76+
77+
struct AaronStruct {
78+
init(x: Int) {}
79+
init() {
80+
// Make sure we recover and assume 'self.init'.
81+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{5-5=self.}}
82+
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
83+
init(y: 1)
84+
85+
func foo() {
86+
// Make sure we recover and assume 'self.init'.
87+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{11-11=self.}}
88+
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
89+
_ = init(y: 1)
90+
}
91+
}
92+
93+
static func aaronFn() {
94+
// Make sure we recover and assume 'self.init'.
95+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
96+
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
97+
_ = init(y: 1)
98+
99+
// FIXME: We could optimistically parse this as an expression instead
100+
// expected-error@+2 {{initializers may only be declared within a type}}
101+
// expected-error@+1 {{expected parameter type following ':'}}
102+
init(y: 1)
103+
}
104+
105+
static var aaronVar: Aaron {
106+
// Make sure we recover and assume 'self.init'.
107+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{9-9=self.}}
108+
// expected-error@+1 {{incorrect argument label in call (have 'y:', expected 'x:')}}
109+
_ = init(y: 1)
110+
111+
// FIXME: We could optimistically parse this as an expression instead
112+
// expected-error@+3 {{initializers may only be declared within a type}}
113+
// expected-error@+2 {{consecutive statements on a line must be separated by ';'}}
114+
// expected-error@+1 {{non-void function should return a value}}
115+
return init()
116+
}
117+
}
118+
119+
enum AaronEnum: Int {
120+
case A = 1
121+
122+
init(x: Int) {
123+
// Make sure we recover and assume 'self.init'.
124+
// expected-error@+2 {{initializer expression requires explicit access; did you mean to prepend it with 'self.'?}} {{5-5=self.}}
125+
// expected-error@+1 {{cannot convert value of type 'String' to expected argument type 'Int'}}
126+
init(rawValue: "")!
127+
}
128+
}
129+
130+
do {
131+
func foo() {
132+
// expected-error@+1 {{initializer expression requires explicit access}} {none}}
133+
_ = init()
134+
}
135+
}

0 commit comments

Comments
 (0)