File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
src/compiler/scala/tools/nsc/transform Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -275,7 +275,17 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
275
275
/* ### HANDLING METHODS NORMALLY COMPILED TO OPERATORS ### */
276
276
277
277
val testForNumber : Tree => Tree = {
278
- qual1 => (qual1 IS_OBJ BoxedNumberClass .tpe) OR (qual1 IS_OBJ BoxedCharacterClass .tpe)
278
+ // Can't shortcut on BoxedNumber because BoxesRunTime
279
+ // is unforgiving of other Numbers showing up.
280
+ qual1 => (
281
+ (qual1 IS_OBJ BoxedIntClass .tpe)
282
+ OR (qual1 IS_OBJ BoxedLongClass .tpe)
283
+ OR (qual1 IS_OBJ BoxedDoubleClass .tpe)
284
+ OR (qual1 IS_OBJ BoxedFloatClass .tpe)
285
+ OR (qual1 IS_OBJ BoxedByteClass .tpe)
286
+ OR (qual1 IS_OBJ BoxedShortClass .tpe)
287
+ OR (qual1 IS_OBJ BoxedCharacterClass .tpe)
288
+ )
279
289
}
280
290
val testForBoolean : Tree => Tree = {
281
291
qual1 => (qual1 IS_OBJ BoxedBooleanClass .tpe)
Original file line number Diff line number Diff line change
1
+ 1 scala.runtime.RichInt
2
+ 1 scala.runtime.RichInt
3
+ 1 scala.math.BigInt
4
+ 1 scala.runtime.RichDouble
5
+ 1 scala.runtime.RichFloat
6
+ 1
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def f (x : { def toInt : Int }) = println(x.toInt + " " + x.getClass.getName)
3
+
4
+ def main (args : Array [String ]): Unit = {
5
+ f(1 )
6
+ f(1 .toInt)
7
+ f(BigInt (1 ))
8
+ f(1d )
9
+ f(1f )
10
+ println((1 : { def toInt : Int }).toInt)
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments