Skip to content

Commit dc4b89f

Browse files
committed
Stop unconditionally type checking in lifetime dependent return
1 parent a15f8fd commit dc4b89f

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,16 +1719,10 @@ Stmt *PreCheckReturnStmtRequest::evaluate(Evaluator &evaluator, ReturnStmt *RS,
17191719
auto *nilExpr = dyn_cast<NilLiteralExpr>(E->getSemanticsProvidingExpr());
17201720
if (!nilExpr) {
17211721
if (ctor->hasLifetimeDependentReturn()) {
1722-
// Typecheck the expression unconditionally.
1723-
TypeChecker::typeCheckExpression(E, DC, {});
1724-
1725-
auto *checkE = E;
1726-
if (auto *load = dyn_cast<LoadExpr>(checkE))
1727-
checkE = load->getSubExpr();
17281722
bool isSelf = false;
1729-
if (auto DRE = dyn_cast<DeclRefExpr>(checkE))
1730-
isSelf = DRE->getDecl() == ctor->getImplicitSelfDecl();
1731-
1723+
if (auto *UDRE = dyn_cast<UnresolvedDeclRefExpr>(E)) {
1724+
isSelf = UDRE->getName().isSimpleName(ctx.Id_self);
1725+
}
17321726
if (!isSelf) {
17331727
ctx.Diags.diagnose(
17341728
RS->getStartLoc(),

0 commit comments

Comments
 (0)