Skip to content

Commit e360d7f

Browse files
committed
Fix the open-existential remover to not die on the OVEs in collection upcasts.
1 parent ed01f89 commit e360d7f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3150,6 +3150,17 @@ static void eraseOpenedExistentials(Expr *&expr) {
31503150
"didn't see this OVE in a containing OpenExistentialExpr?");
31513151
return { true, value->second };
31523152
}
3153+
3154+
// Handle collection upcasts specially so that we don't blow up on
3155+
// their embedded OVEs.
3156+
if (auto CDE = dyn_cast<CollectionUpcastConversionExpr>(expr)) {
3157+
if (auto result = CDE->getSubExpr()->walk(*this)) {
3158+
CDE->setSubExpr(result);
3159+
return { false, CDE };
3160+
} else {
3161+
return { true, CDE };
3162+
}
3163+
}
31533164

31543165
return { true, expr };
31553166
}

validation-test/Sema/type_checker_crashers/rdar27815848.swift renamed to validation-test/Sema/type_checker_crashers_fixed/rdar27815848.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
class C {}
44
class D : C {}

0 commit comments

Comments
 (0)