@@ -21,7 +21,6 @@ object InterceptedMethods {
21
21
* - `x.##` for ## in NullClass becomes `0`
22
22
* - `x.##` for ## in Any becomes calls to ScalaRunTime.hash,
23
23
* using the most precise overload available
24
- * - `x.getClass` for getClass in primitives becomes `x.getClass` with getClass in class Object.
25
24
*/
26
25
class InterceptedMethods extends MiniPhase {
27
26
import tpd ._
@@ -62,11 +61,6 @@ class InterceptedMethods extends MiniPhase {
62
61
}
63
62
64
63
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
- }
70
64
lazy val qual = tree.fun match {
71
65
case Select (qual, _) => qual
72
66
case ident @ Ident (_) =>
@@ -78,32 +72,9 @@ class InterceptedMethods extends MiniPhase {
78
72
}
79
73
}
80
74
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
108
79
}
109
80
}
0 commit comments