Skip to content

Commit c581497

Browse files
committed
[CSClosure] NFC: Add a test-case for rdar://92757114
Used to produce a fallback `type of expression ...` diagnostic
1 parent 9a0978a commit c581497

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/expr/closure/multi_statement.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-experimental-static-assert
23

34
func isInt<T>(_ value: T) -> Bool {
@@ -380,6 +381,37 @@ func test_diagnosing_on_missing_member_in_case() {
380381
}
381382
}
382383

384+
// rdar://92757114 - fallback diagnostic when member doesn't exist in a nested closure
385+
func test_diagnose_missing_member_in_inner_closure() {
386+
struct B {
387+
static var member: any StringProtocol = ""
388+
}
389+
390+
struct Cont<T, E: Error> {
391+
func resume(returning value: T) {}
392+
}
393+
394+
func withCont<T>(function: String = #function,
395+
_ body: (Cont<T, Never>) -> Void) -> T {
396+
fatalError()
397+
}
398+
399+
func test(vals: [Int]?) -> [Int] {
400+
withCont { continuation in
401+
guard let vals = vals else {
402+
return continuation.resume(returning: [])
403+
}
404+
405+
B.member.get(0, // expected-error {{value of type 'any StringProtocol' has no member 'get'}}
406+
type: "type",
407+
withinSecs: Int(60*60)) { arr in
408+
let result = arr.compactMap { $0 }
409+
return continuation.resume(returning: result)
410+
}
411+
}
412+
}
413+
}
414+
383415
// Type finder shouldn't bring external closure result type
384416
// into the scope of an inner closure e.g. while solving
385417
// init of pattern binding `x`.

0 commit comments

Comments
 (0)