From d9d5dcd1e21c215826a915db47eaf993621e0441 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 24 Jun 2012 18:56:02 +0200 Subject: SI-4176 A repeat dose of repeated parameter type sanitization. - During eta expansion, treat parameters of type A* as Seq[A] - Do the same for method/class parameters as referred to by an Ident. Also fixes SI-5967, which shows up during pattern matching. --- .../scala/tools/nsc/typechecker/EtaExpansion.scala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index e1fb683aa9..a4d9cdaffe 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -107,11 +107,20 @@ trait EtaExpansion { self: Analyzer => */ def expand(tree: Tree, tpe: Type): Tree = tpe match { case mt @ MethodType(paramSyms, restpe) if !mt.isImplicit => - val params = paramSyms map (sym => - ValDef(Modifiers(SYNTHETIC | PARAM), - sym.name.toTermName, TypeTree(sym.tpe) , EmptyTree)) + val params: List[(ValDef, Boolean)] = paramSyms.map { + sym => + val origTpe = sym.tpe + val isRepeated = definitions.isRepeatedParamType(origTpe) + // SI-4176 Don't leak A* in eta-expanded function types. See t4176b.scala + val droppedStarTpe = if (settings.etaExpandKeepsStar.value) origTpe else dropRepeatedParamType(origTpe) + val valDef = ValDef(Modifiers(SYNTHETIC | PARAM), sym.name.toTermName, TypeTree(droppedStarTpe), EmptyTree) + (valDef, isRepeated) + } atPos(tree.pos.makeTransparent) { - Function(params, expand(Apply(tree, params map gen.paramToArg), restpe)) + val args = params.map { + case (valDef, isRepeated) => gen.paramToArg(Ident(valDef.name), isRepeated) + } + Function(params.map(_._1), expand(Apply(tree, args), restpe)) } case _ => tree -- cgit v1.2.3