summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-01-15 11:51:36 -0800
committerJames Iry <jamesiry@gmail.com>2013-01-15 11:51:36 -0800
commitc6065591c981e38aedf50618faee945a8b1e5423 (patch)
treecb376c88f416ce21455a79ad9a36dd1db9758654 /src
parent765386ff970af8d53aaa66a42b030e83043d471d (diff)
downloadscala-c6065591c981e38aedf50618faee945a8b1e5423.tar.gz
scala-c6065591c981e38aedf50618faee945a8b1e5423.tar.bz2
scala-c6065591c981e38aedf50618faee945a8b1e5423.zip
SI-5568 Comment improvements for getClass on primitive intersection.
Based on code review here are a few comment cleanups and the removal of some dead test code.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index 58494cb18e..41aada473a 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -341,7 +341,7 @@ abstract class Erasure extends AddInterfaces
}
}
- // Each value class has its own getClass for ultra-precise class object typing.
+ // Each primitive value class has its own getClass for ultra-precise class object typing.
private lazy val primitiveGetClassMethods = Set[Symbol](Any_getClass, AnyVal_getClass) ++ (
ScalaValueClasses map (_.tpe member nme.getClass_)
)
@@ -1159,10 +1159,14 @@ abstract class Erasure extends AddInterfaces
// Rewrite 5.getClass to ScalaRunTime.anyValClass(5)
global.typer.typed(gen.mkRuntimeCall(nme.anyValClass, List(qual, typer.resolveClassTag(tree.pos, qual.tpe.widen))))
} else if (primitiveGetClassMethods.contains(fn.symbol)) {
- // if we got here then we're trying to send a primitive getClass method to
- // a) an Any, or
- // b) a non-primitive, e.g. because the qualifier's type is a refinement type where part of the refinement is a primitive.
- // if we use Object_getClass then things work out because we will call getClass on the boxed form of the Any or primitive
+ // if we got here then we're trying to send a primitive getClass method to either
+ // a) an Any, in which cage Object_getClass works because Any erases to object. Or
+ //
+ // b) a non-primitive, e.g. because the qualifier's type is a refinement type where one parent
+ // of the refinement is a primitive and another is AnyRef. In that case
+ // we get a primitive form of _getClass trying to target a boxed value
+ // so we need replace that method name with Object_getClass to get correct behavior.
+ // See SI-5568.
tree setSymbol Object_getClass
} else {
debugwarn(s"The symbol '${fn.symbol}' was interecepted but didn't match any cases, that means the intercepted methods set doesn't match the code")