Skip to content

Commit 8dddc89

Browse files
committed
[PreCheck] Avoid patterns that appear in closures when multi-statement inference is enabled
Scope down previous check to avoid walking into patterns that appear in multi-statement closures if the inference is enabled.
1 parent 7b0f68c commit 8dddc89

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/Sema/PreCheckExpr.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,11 +1420,12 @@ namespace {
14201420

14211421
std::pair<bool, Pattern *> walkToPatternPre(Pattern *pattern) override {
14221422
// With multi-statement closure inference enabled, constraint generation
1423-
// is responsible for pattern verification and type-checking, so there
1424-
// is no need to walk into patterns in that mode.
1425-
bool shouldWalkIntoPatterns =
1426-
!Ctx.TypeCheckerOpts.EnableMultiStatementClosureInference;
1427-
return {shouldWalkIntoPatterns, pattern};
1423+
// is responsible for pattern verification and type-checking in the body
1424+
// of the closure, so there is no need to walk into patterns.
1425+
bool walkIntoPatterns =
1426+
!(isa<ClosureExpr>(DC) &&
1427+
Ctx.TypeCheckerOpts.EnableMultiStatementClosureInference);
1428+
return {walkIntoPatterns, pattern};
14281429
}
14291430
};
14301431
} // end anonymous namespace

0 commit comments

Comments
 (0)