Skip to content

Commit 04bf10b

Browse files
authored
Merge pull request #58524 from hamishknight/condtrail
2 parents 8a886d8 + c5a53ef commit 04bf10b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,6 +3740,7 @@ static void checkStmtConditionTrailingClosure(ASTContext &ctx, const Expr *E) {
37403740
case ExprKind::Array:
37413741
case ExprKind::Dictionary:
37423742
case ExprKind::InterpolatedStringLiteral:
3743+
case ExprKind::Closure:
37433744
// If a trailing closure appears as a child of one of these types of
37443745
// expression, don't diagnose it as there is no ambiguity.
37453746
return {E->isImplicit(), E};

test/expr/closure/trailing.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,13 @@ func rdar85343171() {
475475
// Okay, as trailing closure is nested in argument list.
476476
if foo(bar {}) {}
477477
}
478+
479+
// rdar://92521618 - Spurious warning on trailing closure nested within a
480+
// closure initializer.
481+
482+
func rdar92521618() {
483+
func foo(_ fn: () -> Void) -> Int? { 0 }
484+
485+
if let _ = { foo {} }() {}
486+
guard let _ = { foo {} }() else { return }
487+
}

0 commit comments

Comments
 (0)