Skip to content

Commit b866edd

Browse files
authored
Merge pull request #7708 from CodaFi/fully-reloaded
[SR-3896] Add missing r-value coercion for type(of:)'s argument
2 parents 7b06b3d + 10f680b commit b866edd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6321,6 +6321,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
63216321
auto arg = apply->getArg();
63226322
if (auto tuple = dyn_cast<TupleExpr>(arg))
63236323
arg = tuple->getElements()[0];
6324+
arg = cs.coerceToRValue(arg);
63246325
auto replacement = new (tc.Context)
63256326
DynamicTypeExpr(apply->getFn()->getLoc(),
63266327
apply->getArg()->getStartLoc(),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 4
2+
3+
// Make sure an r-value coercion is performed on the argument in Swift 4 mode.
4+
var x: Int = 1
5+
_ = type(of: x)
6+

0 commit comments

Comments
 (0)