diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-10-20 22:28:31 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-10-20 22:28:31 +0000 |
commit | 0816035d762b428f5c1698765c4709014a0ba3bd (patch) | |
tree | 182f2159e62d788c570e980fe33f5928f37f5e53 | |
parent | ac7b8020ebc4ba25542314dd4521765700c29f92 (diff) | |
download | scala-0816035d762b428f5c1698765c4709014a0ba3bd.tar.gz scala-0816035d762b428f5c1698765c4709014a0ba3bd.tar.bz2 scala-0816035d762b428f5c1698765c4709014a0ba3bd.zip |
cleaned up addEvidenceParams a bit
implemented my own feedback from
https://codereview.scala-lang.org/fisheye/cru/SR-1022#CFR-23393
no review
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index bf305ffc97..f65481e29a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -596,22 +596,18 @@ abstract class TreeBuilder { AppliedTypeTree(rootScalaDot(newTypeName("Function" + argtpes.length)), argtpes ::: List(restpe)) /** Append implicit parameter section if `contextBounds` nonempty */ - def addEvidenceParams(owner: Name, vparamss: List[List[ValDef]], contextBounds: List[Tree]): List[List[ValDef]] = + def addEvidenceParams(owner: Name, vparamss: List[List[ValDef]], contextBounds: List[Tree]): List[List[ValDef]] = { if (contextBounds.isEmpty) vparamss else { val mods = Modifiers(if (owner.isTypeName) PARAMACCESSOR | LOCAL | PRIVATE else PARAM) def makeEvidenceParam(tpt: Tree) = ValDef(mods | IMPLICIT, freshTermName(nme.EVIDENCE_PARAM_PREFIX), tpt, EmptyTree) val evidenceParams = contextBounds map makeEvidenceParam - if (vparamss.isEmpty) - List(evidenceParams) - else { - val lastParams = vparamss(vparamss.size - 1) - if (!lastParams.isEmpty && (lastParams(0).mods hasFlag IMPLICIT)) - // append lastParams to evidenceParams - (vparamss take (vparamss.size - 1)) ::: List(evidenceParams ::: lastParams) - else - vparamss ::: List(evidenceParams) - } - } + val vparamssLast = if(vparamss.nonEmpty) vparamss.last else Nil + if(vparamssLast.nonEmpty && vparamssLast.head.mods.hasFlag(IMPLICIT)) + vparamss.init ::: List(evidenceParams ::: vparamssLast) + else + vparamss ::: List(evidenceParams) + } + } } |