Skip to content

Commit 59ae630

Browse files
committed
Avoid boxing the type argument of asInstanceOf
1 parent be9e090 commit 59ae630

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,12 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
407407

408408
case tree @ TypeApply(fn, args) =>
409409
traverse(fn)
410-
for case arg: TypeTree <- args do
411-
transformTT(arg, boxed = true, exact = false) // type arguments in type applications are boxed
410+
fn match
411+
case Select(qual, nme.asInstanceOf_) =>
412+
// No need to box type arguments of an asInstanceOf call. See #20224.
413+
case _ =>
414+
for case arg: TypeTree <- args do
415+
transformTT(arg, boxed = true, exact = false) // type arguments in type applications are boxed
412416

413417
case tree: TypeDef if tree.symbol.isClass =>
414418
inContext(ctx.withOwner(tree.symbol)):

0 commit comments

Comments
 (0)