diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/CleanUp.scala | 12 | ||||
-rw-r--r-- | test/files/run/t5356.check | 6 | ||||
-rw-r--r-- | test/files/run/t5356.scala | 12 |
3 files changed, 29 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 575fe8f295..f04867b889 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -275,7 +275,17 @@ abstract class CleanUp extends Transform with ast.TreeDSL { /* ### HANDLING METHODS NORMALLY COMPILED TO OPERATORS ### */ val testForNumber: Tree => Tree = { - qual1 => (qual1 IS_OBJ BoxedNumberClass.tpe) OR (qual1 IS_OBJ BoxedCharacterClass.tpe) + // Can't shortcut on BoxedNumber because BoxesRunTime + // is unforgiving of other Numbers showing up. + qual1 => ( + (qual1 IS_OBJ BoxedIntClass.tpe) + OR (qual1 IS_OBJ BoxedLongClass.tpe) + OR (qual1 IS_OBJ BoxedDoubleClass.tpe) + OR (qual1 IS_OBJ BoxedFloatClass.tpe) + OR (qual1 IS_OBJ BoxedByteClass.tpe) + OR (qual1 IS_OBJ BoxedShortClass.tpe) + OR (qual1 IS_OBJ BoxedCharacterClass.tpe) + ) } val testForBoolean: Tree => Tree = { qual1 => (qual1 IS_OBJ BoxedBooleanClass.tpe) diff --git a/test/files/run/t5356.check b/test/files/run/t5356.check new file mode 100644 index 0000000000..21c4aef07b --- /dev/null +++ b/test/files/run/t5356.check @@ -0,0 +1,6 @@ +1 scala.runtime.RichInt +1 scala.runtime.RichInt +1 scala.math.BigInt +1 scala.runtime.RichDouble +1 scala.runtime.RichFloat +1 diff --git a/test/files/run/t5356.scala b/test/files/run/t5356.scala new file mode 100644 index 0000000000..f7696c6088 --- /dev/null +++ b/test/files/run/t5356.scala @@ -0,0 +1,12 @@ +object Test { + def f(x: { def toInt: Int }) = println(x.toInt + " " + x.getClass.getName) + + def main(args: Array[String]): Unit = { + f(1) + f(1.toInt) + f(BigInt(1)) + f(1d) + f(1f) + println((1: { def toInt: Int }).toInt) + } +} |