diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-16 17:06:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-16 17:06:47 +0000 |
commit | 3778505276e442ab7001b639f66a15efd5a30566 (patch) | |
tree | 42626da33016a1eea63b6fc07264eec2d656c9ea | |
parent | 581fad662c4d7e33613df8d2089a3a730001dc38 (diff) | |
download | scala-3778505276e442ab7001b639f66a15efd5a30566.tar.gz scala-3778505276e442ab7001b639f66a15efd5a30566.tar.bz2 scala-3778505276e442ab7001b639f66a15efd5a30566.zip |
Addendum to previous patch.
In one of those unlikely accidents, I managed to lose the call to
evalOnce while still fixing the reported bug in a different way
(function composition led to the target only being called once anyway.)
No review.
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/CleanUp.scala | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 69c84eb397..095ea88a72 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -347,7 +347,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { /* ### CALLING THE APPLY ### */ def callAsReflective(paramTypes: List[Type], resType: Type): Tree = { - val evalFn: Tree => Tree = qual1 => { + gen.evalOnce(qual, currentOwner, unit) { qual1 => /* Some info about the type of the method being called. */ val methSym = ad.symbol val boxedResType = toBoxedType(resType) // Int -> Integer @@ -382,7 +382,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { /* Some info about the argument at the call site. */ val qualSym = qual.tpe.typeSymbol - val args = qual1 :: params + val args = qual1() :: params def isDefinitelyArray = (qualSym == ArrayClass) def isMaybeArray = (qualSym == ObjectClass) || isDefinitelyArray def isMaybeBoxed = platform isMaybeBoxed qualSym @@ -404,11 +404,11 @@ abstract class CleanUp extends Transform with ast.TreeDSL { /** Normal non-Array call */ def genDefaultCall = { // reflective method call machinery - val invokeName = MethodClass.tpe member nme.invoke_ // reflect.Method.invoke(...) - def cache = safeREF(reflectiveMethodCache(ad.symbol.name.toString, paramTypes)) // cache Symbol - def lookup = Apply(cache, List(qual1 GETCLASS)) // get Method object from cache - def invokeArgs = ArrayValue(TypeTree(ObjectClass.tpe), params) // args for invocation - def invocation = (lookup DOT invokeName)(qual1, invokeArgs) // .invoke(qual1, ...) + val invokeName = MethodClass.tpe member nme.invoke_ // reflect.Method.invoke(...) + def cache = safeREF(reflectiveMethodCache(ad.symbol.name.toString, paramTypes)) // cache Symbol + def lookup = Apply(cache, List(qual1() GETCLASS)) // get Method object from cache + def invokeArgs = ArrayValue(TypeTree(ObjectClass.tpe), params) // args for invocation + def invocation = (lookup DOT invokeName)(qual1(), invokeArgs) // .invoke(qual1, ...) // exception catching machinery val invokeExc = currentOwner.newValue(ad.pos, mkTerm("")) setInfo InvocationTargetExceptionClass.tpe @@ -423,7 +423,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { def genValueCall(operator: Symbol) = fixResult(REF(operator) APPLY args) def genValueCallWithTest = { val (operator, test) = getPrimitiveReplacementForStructuralCall(methSym.name) - IF (test(qual1)) THEN genValueCall(operator) ELSE genDefaultCall + IF (test(qual1())) THEN genValueCall(operator) ELSE genDefaultCall } /** A native Array call. */ @@ -442,7 +442,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { * so we have to generate both kinds of code. */ def genArrayCallWithTest = - IF ((qual1 GETCLASS()) DOT nme.isArray) THEN genArrayCall ELSE genDefaultCall + IF ((qual1() GETCLASS()) DOT nme.isArray) THEN genArrayCall ELSE genDefaultCall localTyper typed ( if (isMaybeBoxed && isJavaValueMethod) genValueCallWithTest @@ -451,7 +451,6 @@ abstract class CleanUp extends Transform with ast.TreeDSL { else genDefaultCall ) } - evalFn(qual) } if (settings.refinementMethodDispatch.value == "invoke-dynamic") { |