Fix <rdar://problem/23086402> Swift compiler crash in CSDiag

This commit is contained in:
Chris Lattner
2015-11-15 14:13:23 -08:00
parent ea06af5afb
commit 13792f915e
2 changed files with 31 additions and 10 deletions

View File

@@ -2530,18 +2530,24 @@ static void eraseOpenedExistentials(Expr *&expr) {
public:
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
if (auto openExistentialExpr = dyn_cast<OpenExistentialExpr>(expr)) {
auto archetypeVal = openExistentialExpr->getOpaqueValue();
auto base = openExistentialExpr->getExistentialValue();
if (auto OOE = dyn_cast<OpenExistentialExpr>(expr)) {
auto archetypeVal = OOE->getOpaqueValue();
auto base = OOE->getExistentialValue();
// Walk the base expression to ensure we erase any existentials within
// it.
base = base->walk(*this);
bool inserted = OpenExistentials.insert({archetypeVal, base}).second;
assert(inserted);
(void) inserted;
return { true, openExistentialExpr->getSubExpr() };
assert(inserted && "OpaqueValue appears multiple times?");
(void)inserted;
return { true, OOE->getSubExpr() };
}
if (auto opaqueValueExpr = dyn_cast<OpaqueValueExpr>(expr)) {
auto value = OpenExistentials.find(opaqueValueExpr);
assert(value != OpenExistentials.end());
if (auto OVE = dyn_cast<OpaqueValueExpr>(expr)) {
auto value = OpenExistentials.find(OVE);
assert(value != OpenExistentials.end() &&
"didn't see this OVE in a containing OpenExistentialExpr?");
return { true, value->second };
}
@@ -2572,7 +2578,7 @@ static void eraseOpenedExistentials(Expr *&expr) {
}
};
expr->walk(ExistentialEraser());
expr = expr->walk(ExistentialEraser());
}
/// Rewrite any type variables & archetypes in the specified type with

View File

@@ -683,3 +683,18 @@ func r22387625() {
let _= 5 // expected-error{{postfix '=' is reserved}} {{8-8= }}
let _ =5 // expected-error{{prefix '=' is reserved}} {{10-10= }}
}
// <rdar://problem/23086402> Swift compiler crash in CSDiag
protocol A23086402 {
var b: B23086402 { get }
}
protocol B23086402 {
var c: [String] { get }
}
func test23086402(a: A23086402) {
print(a.b.c + "") // expected-error {{cannot convert value of type '[String]' to expected argument type '[Any]'}}
}