From e7c61089df1773832b242b892bc7d4dbe5fcbc0f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 15 Aug 2013 15:02:18 -0700 Subject: Removed some dead code in Uncurry. --- .../scala/tools/nsc/transform/UnCurry.scala | 25 ++++------------------ 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index e2ce2743f7..ca123f8782 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -64,7 +64,6 @@ abstract class UnCurry extends InfoTransform class UnCurryTransformer(unit: CompilationUnit) extends TypingTransformer(unit) { private var needTryLift = false - private var inPattern = false private var inConstructorFlag = 0L private val byNameArgs = mutable.HashSet[Tree]() private val noApply = mutable.HashSet[Tree]() @@ -79,12 +78,6 @@ abstract class UnCurry extends InfoTransform @inline private def useNewMembers[T](owner: Symbol)(f: List[Tree] => T): T = f(newMembers.remove(owner).getOrElse(Nil).toList) - @inline private def withInPattern[T](value: Boolean)(body: => T): T = { - inPattern = value - try body - finally inPattern = !value - } - private def newFunction0(body: Tree): Tree = { val result = localTyper.typedPos(body.pos)(Function(Nil, body)).asInstanceOf[Function] log("Change owner from %s to %s in %s".format(currentOwner, result.symbol, result.body)) @@ -119,16 +112,6 @@ abstract class UnCurry extends InfoTransform && (isByName(tree.symbol)) ) - /** Uncurry a type of a tree node. - * This function is sensitive to whether or not we are in a pattern -- when in a pattern - * additional parameter sections of a case class are skipped. - */ - def uncurryTreeType(tp: Type): Type = tp match { - case MethodType(params, MethodType(params1, restpe)) if inPattern => - uncurryTreeType(MethodType(params, restpe)) - case _ => - uncurry(tp) - } // ------- Handling non-local returns ------------------------------------------------- @@ -327,7 +310,7 @@ abstract class UnCurry extends InfoTransform } else { def mkArray = mkArrayValue(args drop (formals.length - 1), varargsElemType) - if (isJava || inPattern) mkArray + if (isJava) mkArray else if (args.isEmpty) gen.mkNil // avoid needlessly double-wrapping an empty argument list else arrayToSequence(mkArray, varargsElemType) } @@ -474,7 +457,7 @@ abstract class UnCurry extends InfoTransform else super.transform(tree) case UnApply(fn, args) => - val fn1 = withInPattern(value = false)(transform(fn)) + val fn1 = transform(fn) val args1 = transformTrees(fn.symbol.name match { case nme.unapply => args case nme.unapplySeq => transformArgs(tree.pos, fn.symbol, args, analyzer.unapplyTypeList(fn.pos, fn.symbol, fn.tpe, args)) @@ -510,7 +493,7 @@ abstract class UnCurry extends InfoTransform else super.transform(tree) case CaseDef(pat, guard, body) => - val pat1 = withInPattern(value = true)(transform(pat)) + val pat1 = transform(pat) treeCopy.CaseDef(tree, pat1, transform(guard), transform(body)) case fun @ Function(_, _) => @@ -532,7 +515,7 @@ abstract class UnCurry extends InfoTransform } ) assert(result.tpe != null, result.shortClass + " tpe is null:\n" + result) - result setType uncurryTreeType(result.tpe) + result modifyType uncurry } def postTransform(tree: Tree): Tree = exitingUncurry { -- cgit v1.2.3