Skip to content

Commit a4a427e

Browse files
committed
Adding additional test cases
This patch adds four new test cases 1. Calling the comp-handler function on an instance of this class 2. Calling the comp-handler function on a nested struct instance 3. Calling the comp-handler function on a different struct instance 4. Storing a comp-handler function is just fine
1 parent 8516c0c commit a4a427e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

test/attr/attr_completionhandlerasync.swift

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct SomeStruct: SomeProto {
6161
@completionHandlerAsync("protoFunc", completionHandlerIndex: 0)
6262
func protoFunc(continuation: @escaping () -> Void) {}
6363

64+
// expected-note@+1{{'structFunc()' declared here}}
6465
func structFunc() async { }
6566

6667
@completionHandlerAsync("structFunc", completionHandlerIndex: 0)
@@ -178,7 +179,15 @@ let asyncGlobalClosure = { () async -> () in
178179
}
179180

180181
class ClassCallingAsyncStuff {
181-
// expected-note@+1 3 {{'asyncFunc()' declared here}}
182+
struct NestedStruct {
183+
@completionHandlerAsync("structFunc()")
184+
func structCompFunc(handler: @escaping () -> ()) { }
185+
186+
// expected-note@+1{{'structFunc()' declared here}}
187+
func structFunc() async {}
188+
}
189+
190+
// expected-note@+1 4 {{'asyncFunc()' declared here}}
182191
func asyncFunc() async {}
183192

184193
@completionHandlerAsync("asyncFunc()")
@@ -204,5 +213,21 @@ class ClassCallingAsyncStuff {
204213
func instanceFunc(other: ClassCallingAsyncStuff) async {
205214
// expected-error@+1{{cannot find 'c' in scope}}
206215
c.compHandlerFunc() { }
216+
217+
// expected-warning@+1{{consider using asynchronous alternative function}}
218+
other.compHandlerFunc() { }
219+
}
220+
221+
func structFunc(other: NestedStruct) async {
222+
// expected-warning@+1{{consider using asynchronous alternative function}}
223+
other.structCompFunc() { }
224+
}
225+
226+
func structFunc(other: SomeStruct) async {
227+
// expected-warning@+1{{consider using asynchronous alternative function}}
228+
other.structFunc() { }
207229
}
230+
231+
// no warning
232+
let funFunc = goodFunc1
208233
}

0 commit comments

Comments
 (0)