Skip to content

Commit d05e79d

Browse files
authored
Merge pull request #38139 from hamishknight/null-check
2 parents f808b8d + 0d4eb97 commit d05e79d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/IDE/Refactoring.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,8 @@ struct CallbackCondition {
45364536

45374537
/// A bool condition expression.
45384538
explicit CallbackCondition(const Expr *E) {
4539-
if (!E->getType()->isBool())
4539+
// FIXME: Sema should produce ErrorType.
4540+
if (!E->getType() || !E->getType()->isBool())
45404541
return;
45414542

45424543
auto CondType = ConditionType::IS_TRUE;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
func callbackIntWithError(_ completion: (Int8, Error?) -> Void) {}
2+
3+
// rdar://79864182
4+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 | %FileCheck -check-prefix=INVALID-COND %s
5+
callbackIntWithError { x, err in
6+
if x {
7+
print("ok")
8+
}
9+
}
10+
// INVALID-COND: let x = try await callbackIntWithError()
11+
// INVALID-COND-NEXT: if x {
12+
// INVALID-COND-NEXT: print("ok")
13+
// INVALID-COND-NEXT: }
14+

0 commit comments

Comments
 (0)