From cbca4943884d23f0a588471ea68e733170d069af Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 7 Nov 2014 13:18:40 +0100 Subject: [sammy] support repeated params Generate correct trees to refer to repeated params using `gen.paramToArg`. Based on retronym's review feedback. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5eee60031e..258029cbd7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2726,7 +2726,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper * which must be fully defined. Would be nice to have some kind of mechanism to insert type vars in a block of code, * and have the instantiation of the first occurrence propagate to the rest of the block. * - * TODO: repeated and by-name params + * TODO: by-name params * scala> trait LazySink { def accept(a: => Any): Unit } * defined trait LazySink * @@ -2741,19 +2741,6 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper * scala> f.accept(println("!")) * ! * ! - * This looks like a bug: - * - * scala> trait RepeatedSink { def accept(a: Any*): Unit } - * defined trait RepeatedSink - * - * scala> val f: RepeatedSink = (a) => println(a) - * f: RepeatedSink = $anonfun$1@4799abc2 - * - * scala> f.accept(1) - * WrappedArray(WrappedArray(1)) - * - * scala> f.accept(1, 2) - * WrappedArray(WrappedArray(1, 2)) */ def synthesizeSAMFunction(sam: Symbol, fun: Function, resPt: Type, samClassTp: Type, mode: Mode): Tree = { // assert(fun.vparams forall (vp => isFullyDefined(vp.tpt.tpe))) -- by construction, as we take them from sam's info @@ -2848,7 +2835,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper Nil, List(fun.vparams), TypeTree(samMethTp.finalResultType) setPos sampos.focus, - Apply(Ident(bodyName), fun.vparams map (p => Ident(p.name))) + Apply(Ident(bodyName), fun.vparams map gen.paramToArg) ) val serializableParentAddendum = -- cgit v1.2.3