Skip to content

Commit f074305

Browse files
committed
[PreCheck] Allow pre-check to walk into patterns when multi-statement inference is disabled
This restores original pre-check behavior and is important for diagnostics like `'_' can only appear in a pattern or on the left side of an assignment`.
1 parent 87f41a9 commit f074305

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Sema/PreCheckExpr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,12 @@ namespace {
14151415
bool walkToDeclPre(Decl *D) override { return isa<PatternBindingDecl>(D); }
14161416

14171417
std::pair<bool, Pattern *> walkToPatternPre(Pattern *pattern) override {
1418-
return {false, pattern};
1418+
// With multi-statement closure inference enabled, constraint generation
1419+
// is responsible for pattern verification and type-checking, so there
1420+
// is no need to walk into patterns in that mode.
1421+
bool shouldWalkIntoPatterns =
1422+
!Ctx.TypeCheckerOpts.EnableMultiStatementClosureInference;
1423+
return {shouldWalkIntoPatterns, pattern};
14191424
}
14201425
};
14211426
} // end anonymous namespace

0 commit comments

Comments
 (0)