@@ -10,7 +10,7 @@ import dotty.tools.dotc.core.StdNames._
1010import dotty .tools .dotc .core .NameKinds
1111import dotty .tools .dotc .core .Mode
1212import dotty .tools .dotc .core .Symbols ._
13- import dotty .tools .dotc .core .Types .Type
13+ import dotty .tools .dotc .core .Types ._
1414import dotty .tools .dotc .core .tasty .TreePickler .Hole
1515import dotty .tools .dotc .core .tasty .{PositionPickler , TastyPickler , TastyPrinter , TastyString }
1616import dotty .tools .dotc .core .tasty .TreeUnpickler .UnpickleMode
@@ -128,15 +128,19 @@ object PickledQuotes {
128128 }
129129
130130 private def functionAppliedTo (fn : Tree , args : List [Tree ])(implicit ctx : Context ): Tree = {
131- val argVals = args.map(arg => SyntheticValDef (NameKinds .UniqueName .fresh(" x" .toTermName), arg).withSpan(arg.span))
132- def argRefs () = argVals.map(argVal => ref(argVal.symbol))
131+ val (argVals, argRefs) = args.map(arg => arg.tpe match {
132+ case tpe : SingletonType if isIdempotentExpr(arg) => (Nil , arg)
133+ case _ =>
134+ val argVal = SyntheticValDef (NameKinds .UniqueName .fresh(" x" .toTermName), arg).withSpan(arg.span)
135+ (argVal :: Nil , ref(argVal.symbol))
136+ }).unzip
133137 def rec (fn : Tree ): Tree = fn match {
134138 case Inlined (call, bindings, expansion) =>
135139 // this case must go before closureDef to avoid dropping the inline node
136140 cpy.Inlined (fn)(call, bindings, rec(expansion))
137141 case closureDef(ddef) =>
138142 val paramSyms = ddef.vparamss.head.map(param => param.symbol)
139- val paramToVals = paramSyms.zip(argRefs() ).toMap
143+ val paramToVals = paramSyms.zip(argRefs).toMap
140144 new TreeTypeMap (
141145 oldOwners = ddef.symbol :: Nil ,
142146 newOwners = ctx.owner :: Nil ,
@@ -145,9 +149,9 @@ object PickledQuotes {
145149 case Block (stats, expr) =>
146150 seq(stats, rec(expr)).withSpan(fn.span)
147151 case _ =>
148- fn.select(nme.apply).appliedToArgs(argRefs() ).withSpan(fn.span)
152+ fn.select(nme.apply).appliedToArgs(argRefs).withSpan(fn.span)
149153 }
150- Block (argVals, rec(fn))
154+ seq (argVals.flatten , rec(fn))
151155 }
152156
153157 private def classToType (clazz : Class [_])(implicit ctx : Context ): Type = {
0 commit comments