@@ -21,7 +21,6 @@ object InterceptedMethods {
2121 * - `x.##` for ## in NullClass becomes `0`
2222 * - `x.##` for ## in Any becomes calls to ScalaRunTime.hash,
2323 * using the most precise overload available
24- * - `x.getClass` for getClass in primitives becomes `x.getClass` with getClass in class Object.
2524 */
2625class InterceptedMethods extends MiniPhase {
2726 import tpd ._
@@ -62,11 +61,6 @@ class InterceptedMethods extends MiniPhase {
6261 }
6362
6463 override def transformApply (tree : Apply )(implicit ctx : Context ): Tree = {
65- def unknown = {
66- assert(false , s " The symbol ' ${tree.fun.symbol.showLocated}' was intercepted but didn't match any cases, " +
67- s " that means the intercepted methods set doesn't match the code " )
68- tree
69- }
7064 lazy val qual = tree.fun match {
7165 case Select (qual, _) => qual
7266 case ident @ Ident (_) =>
@@ -78,32 +72,9 @@ class InterceptedMethods extends MiniPhase {
7872 }
7973 }
8074
81- val Any_!= = defn.Any_!=
82- val rewritten : Tree = tree.fun.symbol match {
83- case Any_!= =>
84- qual.select(defn.Any_== ).appliedToArgs(tree.args).select(defn.Boolean_! ).withSpan(tree.span)
85- /*
86- /* else if (isPrimitiveValueClass(qual.tpe.typeSymbol)) {
87- // todo: this is needed to support value classes
88- // Rewrite 5.getClass to ScalaRunTime.anyValClass(5)
89- global.typer.typed(gen.mkRuntimeCall(nme.anyValClass,
90- List(qual, typer.resolveClassTag(tree.pos, qual.tpe.widen))))
91- }*/
92- */
93- case t if t.name == nme.getClass_ && defn.ScalaValueClasses ().contains(t.owner) =>
94- // if we got here then we're trying to send a primitive getClass method to either
95- // a) an Any, in which cage Object_getClass works because Any erases to object. Or
96- //
97- // b) a non-primitive, e.g. because the qualifier's type is a refinement type where one parent
98- // of the refinement is a primitive and another is AnyRef. In that case
99- // we get a primitive form of _getClass trying to target a boxed value
100- // so we need replace that method name with Object_getClass to get correct behavior.
101- // See SI-5568.
102- qual.selectWithSig(defn.Any_getClass ).appliedToNone.withSpan(tree.span)
103- case _ =>
104- tree
105- }
106- ctx.log(s " $phaseName rewrote $tree to $rewritten" )
107- rewritten
75+ if tree.fun.symbol == defn.Any_!= then
76+ qual.select(defn.Any_== ).appliedToArgs(tree.args).select(defn.Boolean_! ).withSpan(tree.span)
77+ else
78+ tree
10879 }
10980}
0 commit comments