Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@annotation(typeOf[String]) crashes in pickler with AssertionError #7426

Closed
scabug opened this issue Apr 27, 2013 · 4 comments
Closed

@annotation(typeOf[String]) crashes in pickler with AssertionError #7426

scabug opened this issue Apr 27, 2013 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Apr 27, 2013

Reproduce code:

import scala.annotation.StaticAnnotation
import scala.reflect.runtime.universe._

final class foo(t:Any) extends StaticAnnotation
trait OperationMapping{
  @foo(typeOf[String]) def bar : Int
}

Expected result:
compiles fine.

Actual Result

error: uncaught exception during compilation: java.lang.AssertionError
error: java.lang.AssertionError: assertion failed: 
     while compiling: pickleTypeOfString.scala
        during phase: pickler
     library version: version 2.10.1
    compiler version: version 2.10.1
  reconstructed args: 

  last tree to typer: EmptyTree
              symbol: null
   symbol definition: null
                 tpe: <notype>
       symbol owners: 
      context owners: trait OperationMapping -> package <empty>

== Enclosing template or block ==

ClassDef( // abstract trait OperationMapping extends AnyRef
  <interface> abstract <defaultparam/trait>
  "OperationMapping"
  []
  Template( // val <local OperationMapping>: <notype> in trait OperationMapping, tree.tpe=OperationMapping
    "java.lang.Object" // parents
    ValDef(
      private
      "_"
      <tpt>
      <empty>
    )
    DefDef( // def bar: Int in trait OperationMapping
      <method> <deferred> @{ foo(scala.reflect.runtime.`package`.universe.typeOf[String]({
  val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
  val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[OperationMapping].getClassLoader());
  $u.TypeTag.apply[String]($m, {
    final class $typecreator1 extends TypeCreator {
      def <init>(): $typecreator1 = {
        $typecreator1.super.<init>();
        ()
      };
      def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
        val $u: U = $m$untyped.universe;
        val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
        $u.TypeRef.apply($u.SingleType.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticModule("scala.Predef")), $u.build.selectType($m.staticModule("scala.Predef").asModule.moduleClass, "String"), immutable.this.Nil)
      }
    };
    new $typecreator1()
  })
})) }
      "bar"
      []
      Nil
      <tpt> // tree.tpe=Int
      <empty>
    )
  )
)

== Expanded type of tree ==

<notype>


	at scala.tools.nsc.symtab.classfile.Pickler$Pickle.writeArray(Pickler.scala:1107)
	at scala.tools.nsc.symtab.classfile.Pickler$PicklePhase.scala$tools$nsc$symtab$classfile$Pickler$PicklePhase$$pickle$1(Pickler.scala:56)
	at scala.tools.nsc.symtab.classfile.Pickler$PicklePhase.scala$tools$nsc$symtab$classfile$Pickler$PicklePhase$$pickle$1(Pickler.scala:50)
	at scala.tools.nsc.symtab.classfile.Pickler$PicklePhase.apply(Pickler.scala:81)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:430)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
	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.AssertionError: assertion failed: 
     while compiling: pickleTypeOfString.scala
        during phase: pickler
     library version: version 2.10.1
    compiler version: version 2.10.1
  reconstructed args: 

  last tree to typer: EmptyTree
              symbol: null
   symbol definition: null
                 tpe: <notype>
       symbol owners: 
      context owners: trait OperationMapping -> package <empty>

== Enclosing template or block ==

ClassDef( // abstract trait OperationMapping extends AnyRef
  <interface> abstract <defaultparam/trait>
  "OperationMapping"
  []
  Template( // val <local OperationMapping>: <notype> in trait OperationMapping, tree.tpe=OperationMapping
    "java.lang.Object" // parents
    ValDef(
      private
      "_"
      <tpt>
      <empty>
    )
    DefDef( // def bar: Int in trait OperationMapping
      <method> <deferred> @{ foo(scala.reflect.runtime.`package`.universe.typeOf[String]({
  val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
  val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[OperationMapping].getClassLoader());
  $u.TypeTag.apply[String]($m, {
    final class $typecreator1 extends TypeCreator {
      def <init>(): $typecreator1 = {
        $typecreator1.super.<init>();
        ()
      };
      def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
        val $u: U = $m$untyped.universe;
        val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
        $u.TypeRef.apply($u.SingleType.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticModule("scala.Predef")), $u.build.selectType($m.staticModule("scala.Predef").asModule.moduleClass, "String"), immutable.this.Nil)
      }
    };
    new $typecreator1()
  })
})) }
      "bar"
      []
      Nil
      <tpt> // tree.tpe=Int
      <empty>
    )
  )
)

== Expanded type of tree ==

<notype>


	at scala.tools.nsc.symtab.classfile.Pickler$Pickle.writeArray(Pickler.scala:1107)
	at scala.tools.nsc.symtab.classfile.Pickler$PicklePhase.scala$tools$nsc$symtab$classfile$Pickler$PicklePhase$$pickle$1(Pickler.scala:56)
	at scala.tools.nsc.symtab.classfile.Pickler$PicklePhase.scala$tools$nsc$symtab$classfile$Pickler$PicklePhase$$pickle$1(Pickler.scala:50)
	at scala.tools.nsc.symtab.classfile.Pickler$PicklePhase.apply(Pickler.scala:81)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:463)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:430)
	at scala.collection.Iterator$class.foreach(Iterator.scala:727)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:430)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1661)
	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)
@scabug
Copy link
Author

@scabug scabug commented Apr 27, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7426?orig=1
Reporter: @cvogt
Affected Versions: 2.10.1, 2.11.0-M2

@scabug
Copy link
Author

@scabug scabug commented Apr 27, 2013

@paulp said:
Minimized. Unrelated to reflection, actually due to the "tree pickler" being undocumented, untested, and carrying heavy duplication. We should not be depending on that code.

class foo(x: Any) extends annotation.StaticAnnotation
@foo(new AnyRef { }) trait A

@scabug
Copy link
Author

@scabug scabug commented Apr 27, 2013

@scabug
Copy link
Author

@scabug scabug commented May 1, 2013

@cvogt said:
this is an issue for slick, so we should get it in 2.10

@scabug scabug closed this May 14, 2013
@scabug scabug added this to the 2.10.2-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants