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

Scalac crashes when I use @elidable for trait

    Details

      Description

      Compile following code with -Xelide-below OFF and then Scalac crashed.

      import scala.annotation.elidable
      
      trait A {
        @elidable(elidable.FINEST) def xx()
      }
      
      class B extends A {
        override def xx() {
          println("xx")
        }
      }
      
      object Main {
      
        def main(args: Array[String]): Unit = {
          val a:A = new B
          a.xx()
        }
      
      }
      
      error: java.lang.Error: Illegal tree in gen: ()
      	at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:139)
      	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.Global$Run.compile(Global.scala:1038)
      	at scala.tools.nsc.Main$.process(Main.scala:106)
      	at scala.tools.nsc.Main$.main(Main.scala:123)
      	at scala.tools.nsc.Main.main(Main.scala)
      
      Exception in thread "main" java.lang.Error: Illegal tree in gen: ()
      	at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:139)
      	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.Global$Run.compile(Global.scala:1038)
      	at scala.tools.nsc.Main$.process(Main.scala:106)
      	at scala.tools.nsc.Main$.main(Main.scala:123)
      	at scala.tools.nsc.Main.main(Main.scala)
      

      If I change trait A to abstract class A, it's OK.

        Activity

        Hide
        Paul Phillips added a comment -

        Ah, epfl builds under -optimise. I don't have time to look, but that is almost certainly the extra ingredient in its failure.

        Show
        Paul Phillips added a comment - Ah, epfl builds under -optimise. I don't have time to look, but that is almost certainly the extra ingredient in its failure.
        Hide
        Paul Phillips added a comment -

        I think things work sensibly and robustly as of 98cf4014a3 . All expressions are elidable, and replacements have the same type. Feedback welcome.

        Show
        Paul Phillips added a comment - I think things work sensibly and robustly as of 98cf4014a3 . All expressions are elidable, and replacements have the same type. Feedback welcome.
        Hide
        A. P. Marki added a comment -

        +1 on eliding for Nothing. I guess it would have been a high bar to introduce

        def ??! : Nothing = throw new NoLongerImplementedError
        

        into Predef.

        And yet there is a certain symmetry:

        def yagni = ???
        def yagni = feature()
        @deprecated("Useless","1.0") def yagni = feature()
        @deprecated("Useless","1.0") def yagni = ??!
        
        Show
        A. P. Marki added a comment - +1 on eliding for Nothing. I guess it would have been a high bar to introduce def ??! : Nothing = throw new NoLongerImplementedError into Predef. And yet there is a certain symmetry: def yagni = ??? def yagni = feature() @deprecated("Useless","1.0") def yagni = feature() @deprecated("Useless","1.0") def yagni = ??!
        Hide
        Paul Phillips added a comment -

        Then, as the impact of the misfeature continues to be felt, it can be transitioned to ?!! and finally !!!, at which point no argument will be brooked.

        Show
        Paul Phillips added a comment - Then, as the impact of the misfeature continues to be felt, it can be transitioned to ?!! and finally !!!, at which point no argument will be brooked.
        Hide
        Szabolcs Berecz added a comment -

        The tests do pass, so all is well.
        I like this solution because it will do the right thing in case an annotated method is called through reflection or the method is in a jar (compiled separately from the code calling the annotated method).

        I opened a pull request (https://github.com/scala/scala/pull/233) to update the docs for @elided to better match the reality. I consider this issue closable when this commit is merged.

        Show
        Szabolcs Berecz added a comment - The tests do pass, so all is well. I like this solution because it will do the right thing in case an annotated method is called through reflection or the method is in a jar (compiled separately from the code calling the annotated method). I opened a pull request ( https://github.com/scala/scala/pull/233 ) to update the docs for @elided to better match the reality. I consider this issue closable when this commit is merged.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development