diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-04-15 16:41:03 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-04-20 10:13:02 +0200 |
commit | c600c15488b97e7b1f72e6b7811f53f03a493c1c (patch) | |
tree | 7bdba1077d32d370b166beca1de1c427d8821aff /src | |
parent | d6f66ec0f38e42c19f79cbe9d32d29c65dee1e05 (diff) | |
download | scala-c600c15488b97e7b1f72e6b7811f53f03a493c1c.tar.gz scala-c600c15488b97e7b1f72e6b7811f53f03a493c1c.tar.bz2 scala-c600c15488b97e7b1f72e6b7811f53f03a493c1c.zip |
SI-6710 / PR 5072 follow-up: fix Unit.box / Unit.unbox
The backend replaces .box / .unbox methods by corresponding invocations
to BoxesRunTime, but not for Unit.
This commit restores the body of `Unit.box` and `Unit.unbox`.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala | 8 | ||||
-rw-r--r-- | src/library/scala/Unit.scala | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala index 6d3d458324..cea264c57a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala @@ -658,16 +658,16 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { genInvokeDynamicLambda(attachment.target, attachment.arity, attachment.functionalInterface, attachment.sam) generatedType = methodBTypeFromSymbol(fun.symbol).returnType - case Apply(fun @ _, List(expr)) if currentRun.runDefinitions.isBox(fun.symbol) => + case Apply(fun, List(expr)) if currentRun.runDefinitions.isBox(fun.symbol) => val nativeKind = tpeTK(expr) genLoad(expr, nativeKind) val MethodNameAndType(mname, methodType) = srBoxesRuntimeBoxToMethods(nativeKind) bc.invokestatic(srBoxesRunTimeRef.internalName, mname, methodType.descriptor, app.pos) - generatedType = boxResultType(fun.symbol) // was typeToBType(fun.symbol.tpe.resultType) + generatedType = boxResultType(fun.symbol) - case Apply(fun @ _, List(expr)) if currentRun.runDefinitions.isUnbox(fun.symbol) => + case Apply(fun, List(expr)) if currentRun.runDefinitions.isUnbox(fun.symbol) => genLoad(expr) - val boxType = unboxResultType(fun.symbol) // was typeToBType(fun.symbol.owner.linkedClassOfClass.tpe) + val boxType = unboxResultType(fun.symbol) generatedType = boxType val MethodNameAndType(mname, methodType) = srBoxesRuntimeUnboxToMethods(boxType) bc.invokestatic(srBoxesRunTimeRef.internalName, mname, methodType.descriptor, app.pos) diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 397d7b823b..eb6d1d0ddf 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -30,7 +30,7 @@ object Unit extends AnyValCompanion { * @param x the Unit to be boxed * @return a scala.runtime.BoxedUnit offering `x` as its underlying value. */ - def box(x: Unit): scala.runtime.BoxedUnit = ??? + def box(x: Unit): scala.runtime.BoxedUnit = scala.runtime.BoxedUnit.UNIT /** Transform a boxed type into a value type. Note that this * method is not typesafe: it accepts any Object, but will throw @@ -40,7 +40,7 @@ object Unit extends AnyValCompanion { * @throws ClassCastException if the argument is not a scala.runtime.BoxedUnit * @return the Unit value () */ - def unbox(x: java.lang.Object): Unit = ??? + def unbox(x: java.lang.Object): Unit = x.asInstanceOf[scala.runtime.BoxedUnit] /** The String representation of the scala.Unit companion object. */ override def toString = "object scala.Unit" |