Skip to content

Commit 083ab8b

Browse files
committed
DI: More tests for self-consumed analysis
1 parent d6bb97a commit 083ab8b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/SILOptimizer/definite_init_failable_initializers_diagnostics.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,61 @@ class ErrantClass : ErrantBaseClass {
5151
} catch {}
5252
} // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
5353

54+
init(invalidEscapeDesignated2: ()) throws {
55+
x = 10
56+
y = 10
57+
do {
58+
try super.init()
59+
} catch {
60+
try super.init() // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
61+
}
62+
} // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
63+
64+
init(invalidEscapeDesignated3: ()) {
65+
x = 10
66+
y = 10
67+
do {
68+
try super.init()
69+
} catch {
70+
print(self.x) // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
71+
self.y = 20 // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
72+
}
73+
} // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
74+
75+
init(invalidEscapeDesignated4: ()) throws {
76+
x = 10
77+
y = 10
78+
do {
79+
try super.init()
80+
} catch let e {
81+
print(self.x) // expected-error {{'self' used inside 'catch' block reachable from super.init call}}
82+
throw e
83+
}
84+
}
85+
5486
convenience init(invalidEscapeConvenience: ()) {
5587
do {
5688
try self.init()
5789
} catch {}
5890
} // expected-error {{'self' used inside 'catch' block reachable from self.init call}}
5991

92+
convenience init(invalidEscapeConvenience2: ()) throws {
93+
do {
94+
try self.init()
95+
} catch {
96+
try self.init() // expected-error {{'self' used inside 'catch' block reachable from self.init call}}
97+
}
98+
} // expected-error {{'self' used inside 'catch' block reachable from self.init call}}
99+
100+
convenience init(invalidEscapeConvenience3: ()) throws {
101+
do {
102+
try self.init()
103+
} catch let e {
104+
print(self) // expected-error {{'self' used inside 'catch' block reachable from self.init call}}
105+
throw e
106+
}
107+
}
108+
60109
init(noEscapeDesignated: ()) throws {
61110
x = 10
62111
y = 10

0 commit comments

Comments
 (0)