Skip to content

Commit df1ce43

Browse files
authored
Merge pull request #72057 from hamishknight/add-test
[test] Add test case for rdar://123790296
2 parents e98186b + f7130f2 commit df1ce43

File tree

1 file changed

+39
-58
lines changed

1 file changed

+39
-58
lines changed
Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,4 @@
1-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INSTANCE_VAR_INIT | %FileCheck %s -check-prefix=STRUCT_STATIC
2-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_STATIC_VAR_INIT | %FileCheck %s -check-prefix=STRUCT_STATIC
3-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_LAZY_VAR_INIT | %FileCheck %s -check-prefix=STRUCT_INSTANCE
4-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INSTANCE_VAR_BODY | %FileCheck %s -check-prefix=STRUCT_INSTANCE
5-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_STATIC_VAR_BODY | %FileCheck %s -check-prefix=STRUCT_STATIC
6-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INITIALIZER_DEFAULTPARAM | %FileCheck %s -check-prefix=STRUCT_STATIC
7-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INITIALIZER_BODY | %FileCheck %s -check-prefix=STRUCT_INSTANCE
8-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INSTANCE_FUNC_DEFAULTPARAM | %FileCheck %s -check-prefix=STRUCT_STATIC
9-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INSTANCE_FUNC_BODY | %FileCheck %s -check-prefix=STRUCT_INSTANCE
10-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_STATIC_FUNC_DEFAULTPARAM | %FileCheck %s -check-prefix=STRUCT_STATIC
11-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_STATIC_FUNC_BODY | %FileCheck %s -check-prefix=STRUCT_STATIC
12-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INSTANCE_SUBSCRIPT_DEFAULTPARAM | %FileCheck %s -check-prefix=STRUCT_STATIC
13-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INSTANCE_SUBSCRIPT_BODY | %FileCheck %s -check-prefix=STRUCT_INSTANCE
14-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_STATIC_SUBSCRIPT_DEFAULTPARAM | %FileCheck %s -check-prefix=STRUCT_STATIC
15-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_STATIC_SUBSCRIPT_BODY | %FileCheck %s -check-prefix=STRUCT_STATIC
16-
17-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_STATIC_VAR_INIT | %FileCheck %s -check-prefix=ENUM_STATIC
18-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INSTANCE_VAR_BODY | %FileCheck %s -check-prefix=ENUM_INSTANCE
19-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_STATIC_VAR_BODY | %FileCheck %s -check-prefix=ENUM_STATIC
20-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INITIALIZER_DEFAULTPARAM | %FileCheck %s -check-prefix=ENUM_STATIC
21-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INITIALIZER_BODY | %FileCheck %s -check-prefix=ENUM_INSTANCE
22-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INSTANCE_FUNC_DEFAULTPARAM | %FileCheck %s -check-prefix=ENUM_STATIC
23-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INSTANCE_FUNC_BODY | %FileCheck %s -check-prefix=ENUM_INSTANCE
24-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_STATIC_FUNC_DEFAULTPARAM | %FileCheck %s -check-prefix=ENUM_STATIC
25-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_STATIC_FUNC_BODY | %FileCheck %s -check-prefix=ENUM_STATIC
26-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INSTANCE_SUBSCRIPT_DEFAULTPARAM | %FileCheck %s -check-prefix=ENUM_STATIC
27-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_INSTANCE_SUBSCRIPT_BODY | %FileCheck %s -check-prefix=ENUM_INSTANCE
28-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_STATIC_SUBSCRIPT_DEFAULTPARAM | %FileCheck %s -check-prefix=ENUM_STATIC
29-
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ENUM_STATIC_SUBSCRIPT_BODY | %FileCheck %s -check-prefix=ENUM_STATIC
30-
1+
// RUN: %batch-code-completion
312

323
// STRUCT_INSTANCE-NOT: init()
334
// STRUCT_INSTANCE-NOT: staticVar
@@ -53,29 +24,29 @@ struct MyStruct {
5324
var instanceVar: Int { 1 }
5425
func instanceFunc() -> Int { 1 }
5526

56-
var testInstanceVarInit: String = (#^STRUCT_INSTANCE_VAR_INIT^#)
57-
static var testStaticVarInit: String = (#^STRUCT_STATIC_VAR_INIT^#)
58-
lazy var testLazyVarInit: String = (#^STRUCT_LAZY_VAR_INIT^#)
27+
var testInstanceVarInit: String = (#^STRUCT_INSTANCE_VAR_INIT?check=STRUCT_STATIC^#)
28+
static var testStaticVarInit: String = (#^STRUCT_STATIC_VAR_INIT?check=STRUCT_STATIC^#)
29+
lazy var testLazyVarInit: String = (#^STRUCT_LAZY_VAR_INIT?check=STRUCT_INSTANCE^#)
5930
var testInstanceVar: String {
60-
#^STRUCT_INSTANCE_VAR_BODY^#
31+
#^STRUCT_INSTANCE_VAR_BODY?check=STRUCT_INSTANCE^#
6132
}
6233
static var testStaticVar: String {
63-
#^STRUCT_STATIC_VAR_BODY^#
34+
#^STRUCT_STATIC_VAR_BODY?check=STRUCT_STATIC^#
6435
}
65-
init(testInit: String = #^STRUCT_INITIALIZER_DEFAULTPARAM^#) {
66-
#^STRUCT_INITIALIZER_BODY^#
36+
init(testInit: String = #^STRUCT_INITIALIZER_DEFAULTPARAM?check=STRUCT_STATIC^#) {
37+
#^STRUCT_INITIALIZER_BODY?check=STRUCT_INSTANCE^#
6738
}
68-
func testInstanceMethod(x: String = #^STRUCT_INSTANCE_FUNC_DEFAULTPARAM^#) {
69-
#^STRUCT_INSTANCE_FUNC_BODY^#
39+
func testInstanceMethod(x: String = #^STRUCT_INSTANCE_FUNC_DEFAULTPARAM?check=STRUCT_STATIC^#) {
40+
#^STRUCT_INSTANCE_FUNC_BODY?check=STRUCT_INSTANCE^#
7041
}
71-
static func testStaticMethod(x: String = #^STRUCT_STATIC_FUNC_DEFAULTPARAM^#) {
72-
#^STRUCT_STATIC_FUNC_BODY^#
42+
static func testStaticMethod(x: String = #^STRUCT_STATIC_FUNC_DEFAULTPARAM?check=STRUCT_STATIC^#) {
43+
#^STRUCT_STATIC_FUNC_BODY?check=STRUCT_STATIC^#
7344
}
74-
subscript(testInstanceSubscript idx: String = #^STRUCT_INSTANCE_SUBSCRIPT_DEFAULTPARAM^#) {
75-
#^STRUCT_INSTANCE_SUBSCRIPT_BODY^#
45+
subscript(testInstanceSubscript idx: String = #^STRUCT_INSTANCE_SUBSCRIPT_DEFAULTPARAM?check=STRUCT_STATIC^#) {
46+
#^STRUCT_INSTANCE_SUBSCRIPT_BODY?check=STRUCT_INSTANCE^#
7647
}
77-
static subscript(testStaticSubscript idx: String = #^STRUCT_STATIC_SUBSCRIPT_DEFAULTPARAM^#) {
78-
#^STRUCT_STATIC_SUBSCRIPT_BODY^#
48+
static subscript(testStaticSubscript idx: String = #^STRUCT_STATIC_SUBSCRIPT_DEFAULTPARAM?check=STRUCT_STATIC^#) {
49+
#^STRUCT_STATIC_SUBSCRIPT_BODY?check=STRUCT_STATIC^#
7950
}
8051
}
8152

@@ -110,26 +81,36 @@ enum MyEnum {
11081
var instanceVar: Int { 1 }
11182
func instanceFunc() -> Int { 1 }
11283

113-
static var testStaticVarInit: String = (#^ENUM_STATIC_VAR_INIT^#)
84+
static var testStaticVarInit: String = (#^ENUM_STATIC_VAR_INIT?check=ENUM_STATIC^#)
11485
var testInstanceVar: String {
115-
#^ENUM_INSTANCE_VAR_BODY^#
86+
#^ENUM_INSTANCE_VAR_BODY?check=ENUM_INSTANCE^#
11687
}
11788
static var testStaticVar: String {
118-
#^ENUM_STATIC_VAR_BODY^#
89+
#^ENUM_STATIC_VAR_BODY?check=ENUM_STATIC^#
90+
}
91+
init(testInit: String = #^ENUM_INITIALIZER_DEFAULTPARAM?check=ENUM_STATIC^#) {
92+
#^ENUM_INITIALIZER_BODY?check=ENUM_INSTANCE^#
11993
}
120-
func init(testInit: String = #^ENUM_INITIALIZER_DEFAULTPARAM^#) {
121-
#^ENUM_INITIALIZER_BODY^#
94+
func testInstanceMethod(x: String = #^ENUM_INSTANCE_FUNC_DEFAULTPARAM?check=ENUM_STATIC^#) {
95+
#^ENUM_INSTANCE_FUNC_BODY?check=ENUM_INSTANCE^#
12296
}
123-
func testInstanceMethod(x: String = #^ENUM_INSTANCE_FUNC_DEFAULTPARAM^#) {
124-
#^ENUM_INSTANCE_FUNC_BODY^#
97+
static func testStaticMethod(x: String = #^ENUM_STATIC_FUNC_DEFAULTPARAM?check=ENUM_STATIC^#) {
98+
#^ENUM_STATIC_FUNC_BODY?check=ENUM_STATIC^#
12599
}
126-
static func testStaticMethod(x: String = #^ENUM_STATIC_FUNC_DEFAULTPARAM^#) {
127-
#^ENUM_STATIC_FUNC_BODY^#
100+
subscript(testInstanceSubscript idx: String = #^ENUM_INSTANCE_SUBSCRIPT_DEFAULTPARAM?check=ENUM_STATIC^#) {
101+
#^ENUM_INSTANCE_SUBSCRIPT_BODY?check=ENUM_INSTANCE^#
128102
}
129-
subscript(testInstanceSubscript idx: String = #^ENUM_INSTANCE_SUBSCRIPT_DEFAULTPARAM^#) {
130-
#^ENUM_INSTANCE_SUBSCRIPT_BODY^#
103+
static subscript(testStaticSubscript idx: String = #^ENUM_STATIC_SUBSCRIPT_DEFAULTPARAM?check=ENUM_STATIC^#) {
104+
#^ENUM_STATIC_SUBSCRIPT_BODY?check=ENUM_STATIC^#
131105
}
132-
static subscript(testStaticSubscript idx: String = #^ENUM_STATIC_SUBSCRIPT_DEFAULTPARAM^#) {
133-
#^ENUM_STATIC_SUBSCRIPT_BODY^#
106+
}
107+
108+
// rdar://123790296
109+
func testBindingFromDefer(_ x: Int?) {
110+
guard let bar = x else { return }
111+
defer {
112+
#^BINDING_FROM_DEFER^#
113+
// BINDING_FROM_DEFER-DAG: Decl[LocalVar]/Local: x[#Int?#]; name=x
114+
// BINDING_FROM_DEFER-DAG: Decl[LocalVar]/Local: bar[#Int#]; name=bar
134115
}
135116
}

0 commit comments

Comments
 (0)