Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5626

Compiler crash (no-symbol does not have an owner) when instantiating a case class defined in a refinement

    Details

      Description

      scala> val blob = new { case class Foo(i : Int, s : String) }
      blob: Object{type Foo <: Product with Serializable{val i: Int; val s: String; def copy(i: Int,s: String): this.Foo; def copy$default$1: Int @scala.annotation.unchecked.uncheckedVariance; def copy$default$2: String @scala.annotation.unchecked.uncheckedVariance; def _1: Int; def _2: String}; final object Foo extends AbstractFunction2[Int,String,this.Foo] with Serializable} = $anon$1@445a0688
       
      scala> val foo = blob.Foo(23, "foo")
      error: no-symbol does not have an owner (this is a bug: scala version 2.10.0-20120326-112931-2a917f4830)
       
           while compiling:  <console>
             current phase:  erasure
           library version:  version 2.10.0-20120326-112931-2a917f4830
          compiler version:  version 2.10.0-20120326-112931-2a917f4830
        reconstructed args:  -classpath /usr/java/default/lib/tools.jar
       
      unhandled exception while transforming <console>
      error: 
           while compiling:  <console>
             current phase:  explicitouter
           library version:  version 2.10.0-20120326-112931-2a917f4830
          compiler version:  version 2.10.0-20120326-112931-2a917f4830
        reconstructed args:  -classpath /usr/java/default/lib/tools.jar
       
      uncaught exception during compilation: scala.reflect.internal.FatalError
      scala.reflect.internal.FatalError: 
           while compiling:  <console>
             current phase:  erasure
           library version:  version 2.10.0-20120326-112931-2a917f4830
          compiler version:  version 2.10.0-20120326-112931-2a917f4830
        reconstructed args:  -classpath /usr/java/default/lib/tools.jar
       
      no-symbol does not have an owner (this is a bug: scala version 2.10.0-20120326-112931-2a917f4830)
              at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:38)
              at scala.tools.nsc.Global.abort(Global.scala:191)
              at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:2677)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.outerSelect(ExplicitOuter.scala:226)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.outerValue(ExplicitOuter.scala:212)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:496)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:1399)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:1399)
              at scala.collection.immutable.List.loop$1(List.scala:163)
              at scala.collection.immutable.List.mapConserve(List.scala:179)
              at scala.reflect.api.Trees$Transformer.transformTrees(Trees.scala:1399)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1365)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:53)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:519)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$4.apply(Trees.scala:1307)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$4.apply(Trees.scala:1306)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1305)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:53)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:556)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1417)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1415)
              at scala.collection.immutable.List.loop$1(List.scala:163)
              at scala.collection.immutable.List.mapConserve(List.scala:179)
              at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:1415)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1325)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransformers$TypingTransformer$$super$transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:49)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:470)
              at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:1401)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1297)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1296)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1295)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:53)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:556)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1417)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1415)
              at scala.collection.immutable.List.loop$1(List.scala:163)
              at scala.collection.immutable.List.mapConserve(List.scala:179)
              at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:1415)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1325)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransformers$TypingTransformer$$super$transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:49)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:470)
              at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:1401)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1297)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1296)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1295)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:53)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:556)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1417)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1415)
              at scala.collection.immutable.List.loop$1(List.scala:163)
              at scala.collection.immutable.List.mapConserve(List.scala:179)
              at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:1415)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1325)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransformers$TypingTransformer$$super$transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$1.apply(TypingTransformers.scala:49)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:470)
              at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:1401)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1297)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$2.apply(Trees.scala:1296)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1295)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:53)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:556)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1417)
              at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$2.apply(Trees.scala:1415)
              at scala.collection.immutable.List.loop$1(List.scala:163)
              at scala.collection.immutable.List.mapConserve(List.scala:179)
              at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:1415)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$1.apply(Trees.scala:1291)
              at scala.reflect.api.Trees$Transformer$$anonfun$transform$1.apply(Trees.scala:1291)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
              at scala.reflect.api.Trees$Transformer.transform(Trees.scala:1290)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.scala$tools$nsc$transform$TypingTransformers$TypingTransformer$$super$transform(TypingTransformers.scala:49)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$2.apply(TypingTransformers.scala:51)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer$$anonfun$transform$2.apply(TypingTransformers.scala:51)
              at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:1424)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
              at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:51)
              at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.transform(ExplicitOuter.scala:269)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:556)
              at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:262)
              at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transformUnit(ExplicitOuter.scala:564)
              at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30)
              at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:425)
              at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:391)
              at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:385)
              at scala.collection.Iterator$class.foreach(Iterator.scala:695)
              at scala.collection.AbstractIterator.foreach(Iterator.scala:1122)
              at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:385)
              at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1307)
              at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1280)
              at scala.tools.nsc.Global$Run.compileSources(Global.scala:1274)
              at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:442)
              at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:828)
              at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:786)
              at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:941)
              at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:613)
              at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:580)
              at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:777)
              at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:828)
              at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:734)
              at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:598)
              at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:605)
              at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:608)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:905)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:870)
              at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:870)
              at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:155)
              at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:870)
              at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:79)
              at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:92)
              at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101)
              at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
      

        Attachments

          Activity

          Hide
          rytz Lukas Rytz added a comment -

          Minimized:

          class C {
            val blob = {
              new { case class Foo() }
           
          //  without anonymous class (same bug)
          //    class Inner { case class Foo() }
          //    new Inner
            }
            val foo = blob.Foo()
          }
          

          RefChecks ("toConstructor") changes the "C.this.blob.Foo.apply()" to "new Inner.this.Foo()" which is wrong:

          1. class Inner is not an outer class, if something it should be "new C.this.blob.Foo()"
          2. I tried various things using "asSeenFrom" and "memberType" using the class symbol "C", but was not able to get the required type, I always get "Inner.this.Foo")
          3. However, "new C.this.blob.Foo()" is actually wrong, since that is not a class type (in Typers, checkStablePrefixClassType)

          So we should keep the companion-apply in this case, not replace it by a "new" (this fixes the bug).

          Paul figured out the condition to catch this case (mailing list). When selecting "blob.Foo", the symbol for module "Foo" lives in the refinement type. Calling "companionClass" will not return the class symbol for "Foo", but the abstract type "Foo" in the refinement. That's how we conclude that the class type is not accessible.

          Show
          rytz Lukas Rytz added a comment - Minimized: class C { val blob = { new { case class Foo() }   // without anonymous class (same bug) // class Inner { case class Foo() } // new Inner } val foo = blob.Foo() } RefChecks ("toConstructor") changes the "C.this.blob.Foo.apply()" to "new Inner.this.Foo()" which is wrong: class Inner is not an outer class, if something it should be "new C.this.blob.Foo()" I tried various things using "asSeenFrom" and "memberType" using the class symbol "C", but was not able to get the required type, I always get "Inner.this.Foo") However, "new C.this.blob.Foo()" is actually wrong, since that is not a class type (in Typers, checkStablePrefixClassType) So we should keep the companion-apply in this case, not replace it by a "new" (this fixes the bug). Paul figured out the condition to catch this case ( mailing list ). When selecting "blob.Foo", the symbol for module "Foo" lives in the refinement type. Calling "companionClass" will not return the class symbol for "Foo", but the abstract type "Foo" in the refinement. That's how we conclude that the class type is not accessible.
          Show
          rytz Lukas Rytz added a comment - fixed in https://github.com/scala/scala/commit/0c5de3cf31e11614eb93c6a1ae31b87d01ac7db5

            People

            • Assignee:
              rytz Lukas Rytz
              Reporter:
              milessabin Miles Sabin
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: