Skip to content

Commit 7f2b236

Browse files
committed
[NFC] test: Move super in closure tests out of test/Parse
This is diagnosed during semantic pre-checking, not parsing.
1 parent 1b0d383 commit 7f2b236

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

test/Parse/super.swift

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -60,41 +60,3 @@ class D : B {
6060
[1]
6161
}
6262
}
63-
64-
class Closures : B {
65-
func captureWeak() {
66-
let g = { [weak self] () -> Void in // expected-note * {{'self' explicitly captured here}}
67-
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
68-
}
69-
g()
70-
}
71-
72-
func captureUnowned() {
73-
let g = { [unowned self] () -> Void in // expected-note * {{'self' explicitly captured here}}
74-
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
75-
}
76-
g()
77-
}
78-
79-
func nestedInner() {
80-
let g = { () -> Void in
81-
let h = { [weak self] () -> Void in // expected-note * {{'self' explicitly captured here}}
82-
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
83-
nil ?? super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
84-
}
85-
h()
86-
}
87-
g()
88-
}
89-
90-
func nestedOuter() {
91-
let g = { [weak self] () -> Void in // expected-note * {{'self' explicitly captured here}}
92-
let h = { () -> Void in
93-
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
94-
nil ?? super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
95-
}
96-
h()
97-
}
98-
g()
99-
}
100-
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
class Base {
4+
var foo: Int
5+
6+
init() {}
7+
}
8+
9+
class Derived : Base {
10+
func captureWeak() {
11+
let g = { [weak self] () -> Void in // expected-note * {{'self' explicitly captured here}}
12+
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
13+
}
14+
g()
15+
}
16+
17+
func captureUnowned() {
18+
let g = { [unowned self] () -> Void in // expected-note * {{'self' explicitly captured here}}
19+
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
20+
}
21+
g()
22+
}
23+
24+
func nestedInner() {
25+
let g = { () -> Void in
26+
let h = { [weak self] () -> Void in // expected-note * {{'self' explicitly captured here}}
27+
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
28+
nil ?? super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
29+
}
30+
h()
31+
}
32+
g()
33+
}
34+
35+
func nestedOuter() {
36+
let g = { [weak self] () -> Void in // expected-note * {{'self' explicitly captured here}}
37+
let h = { () -> Void in
38+
super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
39+
nil ?? super.foo() // expected-error {{using 'super' in a closure where 'self' is explicitly captured is not yet supported}}
40+
}
41+
h()
42+
}
43+
g()
44+
}
45+
}

0 commit comments

Comments
 (0)