Skip to content

Commit eab7c6a

Browse files
committed
Disable the crash in non-asserts builds when closures don't have a discriminator
We found another case where we aren't getting a closure discriminator, so disable this again in non-asserts builds while we investigate. Tracked by rdar://143590572.
1 parent e24598b commit eab7c6a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/AST/Expr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,12 @@ unsigned AbstractClosureExpr::getDiscriminator() const {
19341934
evaluateOrDefault(
19351935
ctx.evaluator, LocalDiscriminatorsRequest{getParent()}, 0);
19361936

1937+
#if NDEBUG
1938+
static constexpr bool useFallbackDiscriminator = true;
1939+
#else
1940+
static constexpr bool useFallbackDiscriminator = false;
1941+
#endif
1942+
19371943
// If we don't have a discriminator, and either
19381944
// 1. We have ill-formed code and we're able to assign a discriminator, or
19391945
// 2. We are in a macro expansion buffer
@@ -1943,7 +1949,8 @@ unsigned AbstractClosureExpr::getDiscriminator() const {
19431949
if (getRawDiscriminator() == InvalidDiscriminator &&
19441950
(ctx.Diags.hadAnyError() ||
19451951
getParentSourceFile()->getFulfilledMacroRole() != std::nullopt ||
1946-
getParent()->isModuleScopeContext())) {
1952+
getParent()->isModuleScopeContext() ||
1953+
useFallbackDiscriminator)) {
19471954
auto discriminator = ctx.getNextDiscriminator(getParent());
19481955
ctx.setMaxAssignedDiscriminator(getParent(), discriminator + 1);
19491956
const_cast<AbstractClosureExpr *>(this)->

0 commit comments

Comments
 (0)