Skip to content

Commit 511c245

Browse files
committed
[Type checker] Eliminate a dynamically-dead diagnostic.
Between syntactic restrictions and later checks for spurious '&' expressions, we don't need to check for '&' expressions when coercing to an rvalue. Plus, 'inout' doesn't imply 'not lvalue', so we'd never get here.
1 parent 01b45a2 commit 511c245

File tree

2 files changed

+0
-10
lines changed

2 files changed

+0
-10
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,6 @@ NOTE(previous_precedence_group_decl,none,
733733

734734
ERROR(tuple_conversion_not_expressible,none,
735735
"cannot express tuple conversion %0 to %1", (Type, Type))
736-
ERROR(load_of_explicit_lvalue,none,
737-
"%0 variable is not being passed by reference", (Type))
738736

739737
//------------------------------------------------------------------------------
740738
// Expression Type Checking Errors

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,14 +2896,6 @@ Expr *TypeChecker::coerceToRValue(Expr *expr,
28962896
return tryExpr;
28972897
}
28982898

2899-
// Can't load from an inout value.
2900-
if (auto inoutExpr = dyn_cast<InOutExpr>(expr)) {
2901-
diagnose(expr->getLoc(), diag::load_of_explicit_lvalue,
2902-
exprTy->castTo<InOutType>()->getObjectType())
2903-
.fixItRemove(SourceRange(inoutExpr->getLoc()));
2904-
return coerceToRValue(inoutExpr->getSubExpr(), getType, setType);
2905-
}
2906-
29072899
// Walk into tuples to update the subexpressions.
29082900
if (auto tuple = dyn_cast<TupleExpr>(expr)) {
29092901
bool anyChanged = false;

0 commit comments

Comments
 (0)