@@ -486,21 +486,26 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
486
486
// with just `ArrayValue(...).$asInstanceOf[...]`
487
487
//
488
488
// See scala/bug#6611; we must *only* do this for literal vararg arrays.
489
- case Apply (appMeth, Apply (wrapRefArrayMeth, (arg @ StripCast (ArrayValue (_, _))) :: Nil ) :: _ :: Nil )
490
- if wrapRefArrayMeth.symbol == currentRun.runDefinitions.Predef_wrapRefArray && appMeth.symbol == ArrayModule_genericApply =>
491
- super .transform(arg)
492
- case Apply (appMeth, (ap1 @ Apply (wrapRefArrayMeth, (arg @ StripCast (ArrayValue (elemtpt, elems))) :: Nil )) :: classTagEvidence :: Nil )
493
- if wrapRefArrayMeth.symbol == currentRun.runDefinitions.Predef_genericWrapRefArray && appMeth.symbol == ArrayModule_genericApply &&
489
+ case Apply (appMeth, Apply (wrapRefArrayMeth, (arg @ StripCast (ArrayValue (elemtpt, elems))) :: Nil ) :: classTagEvidence :: Nil )
490
+ if (wrapRefArrayMeth.symbol == currentRun.runDefinitions.Predef_genericWrapRefArray || wrapRefArrayMeth.symbol == currentRun.runDefinitions.Predef_wrapRefArray ) && appMeth.symbol == ArrayModule_genericApply &&
494
491
! elemtpt.tpe.typeSymbol.isBottomClass =>
495
- val arr = localTyper.typedPos(tree.pos)(gen.mkMethodCall(classTagEvidence, definitions.ClassTagClass .info.decl(nme.newArray), Nil , Literal (Constant (elems.size)) :: Nil ))
496
- localTyper.typedPos(tree.pos) {
497
- gen.evalOnce(arr, currentOwner, unit) { arr =>
498
- val stats = mutable.ListBuffer [Tree ]()
499
- foreachWithIndex(elems) { (elem, i) =>
500
- stats += gen.mkMethodCall(gen.mkCast(arr(), definitions.arrayType(elemtpt.tpe)), definitions.Array_update , Nil , Literal (Constant (i)) :: elem :: Nil )
492
+ classTagEvidence.attachments.get[analyzer.MacroExpansionAttachment ] match {
493
+ case Some (att) if att.expandee.symbol.name == nme.materializeClassTag && tree.isInstanceOf [ApplyToImplicitArgs ] =>
494
+ super .transform(arg)
495
+ case None =>
496
+ localTyper.typedPos(tree.pos) {
497
+ gen.evalOnce(classTagEvidence, currentOwner, unit) { ev =>
498
+ val arr = localTyper.typedPos(tree.pos)(gen.mkMethodCall(classTagEvidence, definitions.ClassTagClass .info.decl(nme.newArray), Nil , Literal (Constant (elems.size)) :: Nil ))
499
+ gen.evalOnce(arr, currentOwner, unit) { arr =>
500
+ val stats = mutable.ListBuffer [Tree ]()
501
+ foreachWithIndex(elems) { (elem, i) =>
502
+ stats += gen.mkMethodCall(gen.mkAttributedRef(definitions.ScalaRunTimeModule ), currentRun.runDefinitions.arrayUpdateMethod,
503
+ Nil , arr() :: Literal (Constant (i)) :: elem :: Nil )
504
+ }
505
+ super .transform(Block (stats.toList, arr()))
506
+ }
507
+ }
501
508
}
502
- Block (stats.toList, arr())
503
- }
504
509
}
505
510
case Apply (appMeth, elem0 :: Apply (wrapArrayMeth, (rest @ ArrayValue (elemtpt, _)) :: Nil ) :: Nil )
506
511
if wrapArrayMeth.symbol == Predef_wrapArray (elemtpt.tpe) && appMeth.symbol == ArrayModule_apply (elemtpt.tpe) =>
0 commit comments