Skip to content

Commit 67e7eba

Browse files
committed
[Sema] Synthesize pre-type-checked == for uninhabited enums.
1 parent eb217bf commit 67e7eba

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/Sema/DerivedConformanceEquatableHashable.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,23 @@ deriveBodyEquatable_enum_uninhabited_eq(AbstractFunctionDecl *eqDecl, void *) {
381381
SmallVector<ASTNode, 0> cases;
382382

383383
// switch (a, b) { }
384-
auto aRef = new (C) DeclRefExpr(aParam, DeclNameLoc(), /*implicit*/ true);
385-
auto bRef = new (C) DeclRefExpr(bParam, DeclNameLoc(), /*implicit*/ true);
384+
auto aRef = new (C) DeclRefExpr(aParam, DeclNameLoc(), /*implicit*/ true,
385+
AccessSemantics::Ordinary,
386+
aParam->getType());
387+
auto bRef = new (C) DeclRefExpr(bParam, DeclNameLoc(), /*implicit*/ true,
388+
AccessSemantics::Ordinary,
389+
bParam->getType());
390+
TupleTypeElt abTupleElts[2] = { aParam->getType(), bParam->getType() };
386391
auto abExpr = TupleExpr::create(C, SourceLoc(), {aRef, bRef}, {}, {},
387392
SourceLoc(), /*HasTrailingClosure*/ false,
388-
/*implicit*/ true);
393+
/*implicit*/ true,
394+
TupleType::get(abTupleElts, C));
389395
auto switchStmt = SwitchStmt::create(LabeledStmtInfo(), SourceLoc(), abExpr,
390396
SourceLoc(), cases, SourceLoc(), C);
391397
statements.push_back(switchStmt);
392398

393399
auto body = BraceStmt::create(C, SourceLoc(), statements, SourceLoc());
394-
return { body, /*isTypeChecked=*/false };
400+
return { body, /*isTypeChecked=*/true };
395401
}
396402

397403
/// Derive the body for an '==' operator for an enum that has no associated

0 commit comments

Comments
 (0)