Details

      Description

      I've seen this failure so many zillions of times (when recompiling via ant) and finally it is reduced.

      % ./build/pack/bin/scalac src/compiler/scala/tools/nsc/interpreter/ReplReporter.scala src/compiler/scala/tools/nsc/interpreter/ReplConfig.scala
      
      Cannot use package as value: interpreter.this
      	at scala.Predef$.assert(Predef.scala:161)
      	at scala.tools.nsc.Global.assert(Global.scala:176)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:941)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1150)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:721)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1150)
      	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:894)
      

        Activity

        Hide
        Paul Phillips added a comment -

        Sorry, I fixed or at least worked around this between when I reported it and now. I'll check in my workaround shortly, but it doesn't count as a fix so I'll leave this open for miguel.

        Show
        Paul Phillips added a comment - Sorry, I fixed or at least worked around this between when I reported it and now. I'll check in my workaround shortly, but it doesn't count as a fix so I'll leave this open for miguel.
        Hide
        Paul Phillips added a comment -

        See 2b90e85b68 .

        Show
        Paul Phillips added a comment - See 2b90e85b68 .
        Hide
        Jason Zaugg added a comment -

        Here's better look at the original problem.

        2.10.x ~/code/scala for f in sandbox/t5604/*.scala; do echo;echo // $f; cat $f; done
        
        // sandbox/t5604/T.scala
        package t6504
        
        trait T {
          def foo: Boolean = false
        }
        
        // sandbox/t5604/Test.scala
        package t6504
        
        object Test {
          def blerg(a: Any): Any = if (foo) blerg(0)
        }
        
        // sandbox/t5604/pack.scala
        package t6504
        
        object `package` extends T {
        }
        2.10.x ~/code/scala scala-hash '2b90e85b68~1' -d sandbox/t5604/out.jar sandbox/t5604/*.scala
        2.10.x ~/code/scala scala-hash '2b90e85b68~1' -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala 
        error: 
             while compiling:  sandbox/t5604/Test.scala
               current phase:  icode
             library version:  version 2.10.0-20120327-073128-d078b58961
            compiler version:  version 2.10.0-20120327-073128-d078b58961
          reconstructed args:  -classpath sandbox/t5604/out.jar
        
        uncaught exception during compilation: java.lang.AssertionError
        error: java.lang.AssertionError: assertion failed: 
             while compiling:  sandbox/t5604/Test.scala
               current phase:  icode
             library version:  version 2.10.0-20120327-073128-d078b58961
            compiler version:  version 2.10.0-20120327-073128-d078b58961
          reconstructed args:  -classpath sandbox/t5604/out.jar
        
        Cannot use package as value: t6504.this
        	at scala.Predef$.assert(Predef.scala:161)
        	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:948)
        
        
        2.10.x ~/code/scala scala-hash '2b90e85b68' -d sandbox/t5604/out.jar sandbox/t5604/*.scala
        2.10.x ~/code/scala scala-hash '2b90e85b68' -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala 
        Bug: found package class where package object expected.  Converting.
        
        
        2.10.x ~/code/scala scala-hash '2.10.x' -d sandbox/t5604/out.jar sandbox/t5604/*.scala
        2.10.x ~/code/scala scala-hash '2.10.x' -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala 
        

        In summary: the bug is triggered by recompiling a trait that is mixed into a package object, without recompiling that package object at the same time. Paul's workaround changed the crash to an error, but that has since disappeared, suggesting the underlying issue might be resolved.

        Show
        Jason Zaugg added a comment - Here's better look at the original problem. 2.10.x ~/code/scala for f in sandbox/t5604/*.scala; do echo;echo // $f; cat $f; done // sandbox/t5604/T.scala package t6504 trait T { def foo: Boolean = false } // sandbox/t5604/Test.scala package t6504 object Test { def blerg(a: Any): Any = if (foo) blerg(0) } // sandbox/t5604/pack.scala package t6504 object `package` extends T { } 2.10.x ~/code/scala scala-hash '2b90e85b68~1' -d sandbox/t5604/out.jar sandbox/t5604/*.scala 2.10.x ~/code/scala scala-hash '2b90e85b68~1' -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala error: while compiling: sandbox/t5604/Test.scala current phase: icode library version: version 2.10.0-20120327-073128-d078b58961 compiler version: version 2.10.0-20120327-073128-d078b58961 reconstructed args: -classpath sandbox/t5604/out.jar uncaught exception during compilation: java.lang.AssertionError error: java.lang.AssertionError: assertion failed: while compiling: sandbox/t5604/Test.scala current phase: icode library version: version 2.10.0-20120327-073128-d078b58961 compiler version: version 2.10.0-20120327-073128-d078b58961 reconstructed args: -classpath sandbox/t5604/out.jar Cannot use package as value: t6504.this at scala.Predef$.assert(Predef.scala:161) at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:948) 2.10.x ~/code/scala scala-hash '2b90e85b68' -d sandbox/t5604/out.jar sandbox/t5604/*.scala 2.10.x ~/code/scala scala-hash '2b90e85b68' -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala Bug: found package class where package object expected. Converting. 2.10.x ~/code/scala scala-hash '2.10.x' -d sandbox/t5604/out.jar sandbox/t5604/*.scala 2.10.x ~/code/scala scala-hash '2.10.x' -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala In summary: the bug is triggered by recompiling a trait that is mixed into a package object, without recompiling that package object at the same time. Paul's workaround changed the crash to an error, but that has since disappeared, suggesting the underlying issue might be resolved.
        Hide
        Jason Zaugg added a comment - - edited

        That was optimistic. In fact, since https://github.com/scala/scala/commit/v2.10.0-M4~118#L10L1211, the underlying problem is only logged under -Ydebug.

        Show
        Jason Zaugg added a comment - - edited That was optimistic. In fact, since https://github.com/scala/scala/commit/v2.10.0-M4~118#L10L1211 , the underlying problem is only logged under -Ydebug .
        Hide
        Jason Zaugg added a comment -

        Making a small change to that file, to fully qualify the reference to the reference to the package object member, triggers a nastier problem.

        for f in sandbox/t5604/*.scala; do echo;echo // $f; cat $f; done
        
        // sandbox/t5604/T.scala
        package t6504
        
        trait T {
          def foo: Boolean = false
        }
        
        // sandbox/t5604/Test.scala
        package t6504
        
        object Test {
          def blerg(a: Any): Any = if (t6504.foo) blerg(0)
        }
        
        // sandbox/t5604/pack.scala
        package t6504
        
        object `package` extends T {
        }
        2.10.x ~/code/scala export hash=2.10.x && (scala-hash "$hash" -version; rm sandbox/t5604/out.jar 2>/dev/null; scala-hash "$hash" -d sandbox/t5604/out.jar sandbox/t5604/*.scala && scala-hash "$hash" -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala )
        Scala compiler version 2.10.0-20120920-130603-c8e6f8e64c -- Copyright 2002-2012, LAMP/EPFL
        error: 
             while compiling: sandbox/t5604/Test.scala
                during phase: jvm
             library version: version 2.10.0-20120920-130603-c8e6f8e64c
            compiler version: version 2.10.0-20120920-130603-c8e6f8e64c
          reconstructed args: -classpath sandbox/t5604/out.jar
        
          last tree to typer: TypeTree(trait T)
                      symbol: trait T in package t6504 (flags: <interface> abstract <trait> <lateinterface>)
           symbol definition: abstract trait T extends Object
                         tpe: t6504.T
               symbol owners: trait T -> package t6504
              context owners: object Test -> package t6504
        
        == Enclosing template or block ==
        
        Template( // val <local Test>: <notype> in object Test, tree.tpe=t6504.Test.type
          "java.lang.Object" // parents
          ValDef(
            private
            "_"
            <tpt>
            <empty>
          )
          // 2 statements
          DefDef( // def blerg(a: Object): Object in object Test
            <method> <triedcooking>
            "blerg"
            []
            // 1 parameter list
            ValDef( // a: Object
              <param>
              "a"
              <tpt> // tree.tpe=Object
              <empty>
            )
            <tpt> // tree.tpe=Object
            Block( // tree.tpe=Object
              ValDef( // val _$this: t6504.Test.type
                <synthetic>
                "_$this"
                <tpt> // tree.tpe=t6504.Test.type
                This("Test")class Test extends Object in package t6504, tree.tpe=t6504.Test.type
              )
              LabelDef( // def _blerg(x$1: t6504.Test.type,a: Object): Object, tree.tpe=Object
                // 2 paramss
                "_$this" // val _$this: t6504.Test.type, tree.tpe=t6504.Test.type
                "a" // a: Object, tree.tpe=Object
                If( // tree.tpe=Object
                  Apply( // def foo(): Boolean in trait T, tree.tpe=Boolean
                    t6504.$asInstanceOf[t6504.T]()."foo" // def foo(): Boolean in trait T, tree.tpe=()Boolean
                    Nil
                  )
                  Apply( // def _blerg(x$1: t6504.Test.type,a: Object): Object, tree.tpe=Object
                    "_blerg" // def _blerg(x$1: t6504.Test.type,a: Object): Object, tree.tpe=(x$1: t6504.Test.type, a: Object)Object
                    // 2 arguments
                    This("Test")class Test extends Object in package t6504, tree.tpe=t6504.Test.type
                    Apply( // def box(x: Int): Integer in object Int, tree.tpe=Object
                      "scala"."Int"."box" // def box(x: Int): Integer in object Int, tree.tpe=(x: Int)Integer
                      0
                    )
                  )
                  "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: runtime.BoxedUnit in object BoxedUnit, tree.tpe=runtime.BoxedUnit
                )
              )
            )
          )
          DefDef( // def <init>(): t6504.Test.type in object Test
            <method>
            "<init>"
            []
            List(Nil)
            <tpt> // tree.tpe=t6504.Test.type
            Block( // tree.tpe=Unit
              Apply( // def <init>(): Object in class Object, tree.tpe=Object
                Test.super."<init>" // def <init>(): Object in class Object, tree.tpe=()Object
                Nil
              )
              ()
            )
          )
        )
        
        == Expanded type of tree ==
        
        TypeRef(TypeSymbol(abstract trait T extends Object))
        
        uncaught exception during compilation: java.lang.ArrayIndexOutOfBoundsException
        error: java.lang.ArrayIndexOutOfBoundsException: -1
        	at scala.tools.asm.Frame.merge(Unknown Source)
        	at scala.tools.asm.Frame.merge(Unknown Source)
        	at scala.tools.asm.MethodWriter.visitMaxs(Unknown Source)
        	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genMethod(GenASM.scala:1638)
        	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1471)
        	at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:182)
        	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1574)
        	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1548)
        	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1544)
        	at scala.tools.nsc.Global$Run.compile(Global.scala:1654)
        	at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
        	at scala.tools.nsc.Main$.doCompile(Main.scala:79)
        	at scala.tools.nsc.Driver.process(Driver.scala:54)
        	at scala.tools.nsc.Driver.main(Driver.scala:67)
        	at scala.tools.nsc.Main.main(Main.scala)
        
        Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
        	at scala.tools.asm.Frame.merge(Unknown Source)
        	at scala.tools.asm.Frame.merge(Unknown Source)
        	at scala.tools.asm.MethodWriter.visitMaxs(Unknown Source)
        	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genMethod(GenASM.scala:1638)
        	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1471)
        	at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:182)
        	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1574)
        	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1548)
        	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1544)
        	at scala.tools.nsc.Global$Run.compile(Global.scala:1654)
        	at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
        	at scala.tools.nsc.Main$.doCompile(Main.scala:79)
        	at scala.tools.nsc.Driver.process(Driver.scala:54)
        	at scala.tools.nsc.Driver.main(Driver.scala:67)
        	at scala.tools.nsc.Main.main(Main.scala)
        
        Show
        Jason Zaugg added a comment - Making a small change to that file, to fully qualify the reference to the reference to the package object member, triggers a nastier problem. for f in sandbox/t5604/*.scala; do echo;echo // $f; cat $f; done // sandbox/t5604/T.scala package t6504 trait T { def foo: Boolean = false } // sandbox/t5604/Test.scala package t6504 object Test { def blerg(a: Any): Any = if (t6504.foo) blerg(0) } // sandbox/t5604/pack.scala package t6504 object `package` extends T { } 2.10.x ~/code/scala export hash=2.10.x && (scala-hash "$hash" -version; rm sandbox/t5604/out.jar 2>/dev/null; scala-hash "$hash" -d sandbox/t5604/out.jar sandbox/t5604/*.scala && scala-hash "$hash" -classpath sandbox/t5604/out.jar sandbox/t5604/T*.scala ) Scala compiler version 2.10.0-20120920-130603-c8e6f8e64c -- Copyright 2002-2012, LAMP/EPFL error: while compiling: sandbox/t5604/Test.scala during phase: jvm library version: version 2.10.0-20120920-130603-c8e6f8e64c compiler version: version 2.10.0-20120920-130603-c8e6f8e64c reconstructed args: -classpath sandbox/t5604/out.jar last tree to typer: TypeTree(trait T) symbol: trait T in package t6504 (flags: <interface> abstract <trait> <lateinterface>) symbol definition: abstract trait T extends Object tpe: t6504.T symbol owners: trait T -> package t6504 context owners: object Test -> package t6504 == Enclosing template or block == Template( // val <local Test>: <notype> in object Test, tree.tpe=t6504.Test.type "java.lang.Object" // parents ValDef( private "_" <tpt> <empty> ) // 2 statements DefDef( // def blerg(a: Object): Object in object Test <method> <triedcooking> "blerg" [] // 1 parameter list ValDef( // a: Object <param> "a" <tpt> // tree.tpe=Object <empty> ) <tpt> // tree.tpe=Object Block( // tree.tpe=Object ValDef( // val _$this: t6504.Test.type <synthetic> "_$this" <tpt> // tree.tpe=t6504.Test.type This("Test")class Test extends Object in package t6504, tree.tpe=t6504.Test.type ) LabelDef( // def _blerg(x$1: t6504.Test.type,a: Object): Object, tree.tpe=Object // 2 paramss "_$this" // val _$this: t6504.Test.type, tree.tpe=t6504.Test.type "a" // a: Object, tree.tpe=Object If( // tree.tpe=Object Apply( // def foo(): Boolean in trait T, tree.tpe=Boolean t6504.$asInstanceOf[t6504.T]()."foo" // def foo(): Boolean in trait T, tree.tpe=()Boolean Nil ) Apply( // def _blerg(x$1: t6504.Test.type,a: Object): Object, tree.tpe=Object "_blerg" // def _blerg(x$1: t6504.Test.type,a: Object): Object, tree.tpe=(x$1: t6504.Test.type, a: Object)Object // 2 arguments This("Test")class Test extends Object in package t6504, tree.tpe=t6504.Test.type Apply( // def box(x: Int): Integer in object Int, tree.tpe=Object "scala"."Int"."box" // def box(x: Int): Integer in object Int, tree.tpe=(x: Int)Integer 0 ) ) "scala"."runtime"."BoxedUnit"."UNIT" // final val UNIT: runtime.BoxedUnit in object BoxedUnit, tree.tpe=runtime.BoxedUnit ) ) ) ) DefDef( // def <init>(): t6504.Test.type in object Test <method> "<init>" [] List(Nil) <tpt> // tree.tpe=t6504.Test.type Block( // tree.tpe=Unit Apply( // def <init>(): Object in class Object, tree.tpe=Object Test.super."<init>" // def <init>(): Object in class Object, tree.tpe=()Object Nil ) () ) ) ) == Expanded type of tree == TypeRef(TypeSymbol(abstract trait T extends Object)) uncaught exception during compilation: java.lang.ArrayIndexOutOfBoundsException error: java.lang.ArrayIndexOutOfBoundsException: -1 at scala.tools.asm.Frame.merge(Unknown Source) at scala.tools.asm.Frame.merge(Unknown Source) at scala.tools.asm.MethodWriter.visitMaxs(Unknown Source) at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genMethod(GenASM.scala:1638) at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1471) at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:182) at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1574) at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1548) at scala.tools.nsc.Global$Run.compileSources(Global.scala:1544) at scala.tools.nsc.Global$Run.compile(Global.scala:1654) at scala.tools.nsc.Driver.doCompile(Driver.scala:33) at scala.tools.nsc.Main$.doCompile(Main.scala:79) at scala.tools.nsc.Driver.process(Driver.scala:54) at scala.tools.nsc.Driver.main(Driver.scala:67) at scala.tools.nsc.Main.main(Main.scala) Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at scala.tools.asm.Frame.merge(Unknown Source) at scala.tools.asm.Frame.merge(Unknown Source) at scala.tools.asm.MethodWriter.visitMaxs(Unknown Source) at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genMethod(GenASM.scala:1638) at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1471) at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:182) at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1574) at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1548) at scala.tools.nsc.Global$Run.compileSources(Global.scala:1544) at scala.tools.nsc.Global$Run.compile(Global.scala:1654) at scala.tools.nsc.Driver.doCompile(Driver.scala:33) at scala.tools.nsc.Main$.doCompile(Main.scala:79) at scala.tools.nsc.Driver.process(Driver.scala:54) at scala.tools.nsc.Driver.main(Driver.scala:67) at scala.tools.nsc.Main.main(Main.scala)
        Hide
        Paul Phillips added a comment -

        After I bad run of situations where I thought "I know exactly what to do" and I did not actually know exactly what to do, this time I thought that and I was right.

        Just running a test or two.

        Show
        Paul Phillips added a comment - After I bad run of situations where I thought "I know exactly what to do" and I did not actually know exactly what to do, this time I thought that and I was right. Just running a test or two.
        Show
        Paul Phillips added a comment - https://github.com/scala/scala/pull/1376
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/1383
        Hide
        Adriaan Moors added a comment -
        Show
        Adriaan Moors added a comment - fixed for 2.11 in https://github.com/paulp/scala/commit/e6f10b07d44f0ddde26246b4a41527a84eede81c – potential backport pending

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development