Skip to content

Commit dcf80e6

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 9bd603b commit dcf80e6

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
@@ -1419,11 +1419,12 @@ namespace {
14191419

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

0 commit comments

Comments
 (0)