Scala Programming Language
  1. Scala Programming Language
  2. SI-5026

2.getClass() == 4.getClass() crashes the compiler

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      2.getClass() == 4.getClass() causes the compiler (or repl) to crash.

      I also tried 2.getClass() != 4.getClass(), which crashes, and 2.getClass().equals(4.getClass()), which does not crash.

      java.lang.UnsupportedOperationException: Position.line
      at scala.tools.nsc.util.Position$class.line(Position.scala:173)
      at scala.tools.nsc.util.NoPosition$.line(Position.scala:196)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.getTempLocal$1(GenICode.scala:1562)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genEqEqPrimitive(GenICode.scala:1614)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genRefEq$1(GenICode.scala:1516)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genCond(GenICode.scala:1527)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genPrimitiveOp(GenICode.scala:441)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:902)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:163)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:143)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:143)
      at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
      at scala.collection.immutable.List.foldLeft(List.scala:45)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genStat(GenICode.scala:143)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1052)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:114)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
      at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
      at scala.collection.immutable.List.foreach(List.scala:45)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:136)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:88)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
      at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
      at scala.collection.immutable.List.foreach(List.scala:45)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:79)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:65)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:61)
      at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
      at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
      at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
      at scala.collection.Iterator$class.foreach(Iterator.scala:660)
      at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:316)
      at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:297)
      at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:54)
      at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
      at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:756)
      at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:731)
      at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:873)
      at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:576)
      at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:543)
      at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:694)
      at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:745)
      at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:651)
      at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:542)
      at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:550)
      at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
      at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:67)
      at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
      at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
      at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

        Activity

        Hide
        Commit Message Bot added a comment -

        (extempore in r25726) Stripped a bunch of hostile code.

        Closes SI-5026, no review.

        Show
        Commit Message Bot added a comment - (extempore in r25726 ) Stripped a bunch of hostile code. Closes SI-5026 , no review.
        Hide
        Eric Tanter added a comment -

        This bug is still present in release 2.9.1

        Show
        Eric Tanter added a comment - This bug is still present in release 2.9.1
        Hide
        Eric Tanter added a comment -

        This bug is still present in 2.9.1
        (I'm on mac os x)

        Show
        Eric Tanter added a comment - This bug is still present in 2.9.1 (I'm on mac os x)
        Hide
        Kato Kazuyoshi added a comment - - edited

        Yeah, it still exists on 2.9.1-1.

        % scala
        Welcome to Scala version 2.9.1-1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31).
        Type in expressions to have them evaluated.
        Type :help for more information.
        scala> 2.getClass() == 4.getClass()
        java.lang.UnsupportedOperationException: Position.line        at scala.tools.nsc.util.Position$class.line(Position.scala:173)
                at scala.tools.nsc.util.NoPosition$.line(Position.scala:196)
        ...
        

        But I can't reproduce it on 8c95273b70288e4e3a547fa43f2dbdb40a71b9ea.

        % ./build/pack/bin/scala
        Welcome to Scala version 2.10.0-20120422-061223-8c95273b70 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31).
        Type in expressions to have them evaluated.
        Type :help for more information.
        
        scala> 2.getClass() == 4.getClass()
        res0: Boolean = true
        
        scala> 2.getClass() != 4.getClass()
        res1: Boolean = false
        
        scala> 2.getClass().equals(4.getClass())
        res2: Boolean = true
        
        scala> 
        
        Show
        Kato Kazuyoshi added a comment - - edited Yeah, it still exists on 2.9.1-1. % scala Welcome to Scala version 2.9.1-1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31). Type in expressions to have them evaluated. Type :help for more information. scala> 2.getClass() == 4.getClass() java.lang.UnsupportedOperationException: Position.line at scala.tools.nsc.util.Position$class.line(Position.scala:173) at scala.tools.nsc.util.NoPosition$.line(Position.scala:196) ... But I can't reproduce it on 8c95273b70288e4e3a547fa43f2dbdb40a71b9ea. % ./build/pack/bin/scala Welcome to Scala version 2.10.0-20120422-061223-8c95273b70 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31). Type in expressions to have them evaluated. Type :help for more information. scala> 2.getClass() == 4.getClass() res0: Boolean = true scala> 2.getClass() != 4.getClass() res1: Boolean = false scala> 2.getClass().equals(4.getClass()) res2: Boolean = true scala>
        Hide
        Eric Tanter added a comment -

        ok, good to know. Sorry for the noise!

        Show
        Eric Tanter added a comment - ok, good to know. Sorry for the noise!

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Karl Voelker
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development