summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/Erasure.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2016-05-19 08:33:31 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2016-05-19 08:33:31 +0200
commit960e4d76a382ff009c66346289db10b2ee598aa5 (patch)
treed15ddddd1bd1cea4fe6afc811a0771e9113eb24a /src/compiler/scala/tools/nsc/transform/Erasure.scala
parent41c9a17e4f211fc24a931949a0819a0474cc004a (diff)
parenta5fab1f588a6042ca924a78d225e85d0acddf5db (diff)
downloadscala-960e4d76a382ff009c66346289db10b2ee598aa5.tar.gz
scala-960e4d76a382ff009c66346289db10b2ee598aa5.tar.bz2
scala-960e4d76a382ff009c66346289db10b2ee598aa5.zip
Merge pull request #5176 from lrytz/t9671
SI-9671, SI-7397 fix null.asInstanceOf[Int] when pt erases to Object
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/Erasure.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index bc614dfc31..5e903946c1 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -606,10 +606,8 @@ abstract class Erasure extends AddInterfaces
// !!! Make pending/run/t5866b.scala work. The fix might be here and/or in unbox1.
if (isPrimitiveValueType(targ.tpe) || isErasedValueType(targ.tpe)) {
val noNullCheckNeeded = targ.tpe match {
- case ErasedValueType(_, underlying) =>
- isPrimitiveValueClass(underlying.typeSymbol)
- case _ =>
- true
+ case ErasedValueType(_, underlying) => isPrimitiveValueType(underlying)
+ case _ => true
}
if (noNullCheckNeeded) unbox(qual1, targ.tpe)
else {
@@ -1143,6 +1141,10 @@ abstract class Erasure extends AddInterfaces
else {
val tree1 = preErase(tree)
tree1 match {
+ case TypeApply(fun, targs @ List(targ)) if fun.symbol == Any_asInstanceOf && targ.tpe == UnitTpe =>
+ // SI-9066 prevent transforming `o.asInstanceOf[Unit]` to `o.asInstanceOf[BoxedUnit]`.
+ // adaptMember will then replace the call by a reference to BoxedUnit.UNIT.
+ treeCopy.TypeApply(tree1, transform(fun), targs).clearType()
case EmptyTree | TypeTree() =>
tree1 setType specialScalaErasure(tree1.tpe)
case ArrayValue(elemtpt, trees) =>