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

Unpickle error reading try catch statement in annotation. #11371

Open
Prithvirajbilla opened this Issue Jan 17, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@Prithvirajbilla
Copy link

Prithvirajbilla commented Jan 17, 2019

scala version: 2.12.8
Java version: 1.8.0_112

The following code produces the issue. Unpickler is not able to read try catch statement and returns a runtime exception.

scala> class Superhero(power:String) extends scala.annotation.StaticAnnotation
defined class Superhero

scala> @Superhero(power = { try { "Awesome"} catch { case default => "NotAwesome" }})
     | class Spiderman {}
       @Superhero(power = { try { "Awesome"} catch { case default => "NotAwesome" }})
                                                          ^
java.lang.RuntimeException: malformed Scala signature of $read at 320; expected a case def (<empty>)
	at scala.reflect.internal.pickling.UnPickler$Scan.errorBadSignature(UnPickler.scala:699)
	at scala.reflect.internal.pickling.UnPickler$Scan.readCaseDefRef(UnPickler.scala:671)
	at scala.reflect.internal.pickling.UnPickler$Scan.caseRef$1(UnPickler.scala:537)
......

@SethTisue SethTisue added this to the Backlog milestone Jan 17, 2019

@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Jan 17, 2019

does the language spec restrict what kind of code can appear in this position?

@som-snytt

This comment has been minimized.

Copy link

som-snytt commented Jan 18, 2019

This happens during REPL reflection; compilation succeeds.

scala 2.13.0-M5> @deprecated(try "", "") class C
                             ^
                 warning: A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.
java.lang.ClassCastException: scala.reflect.internal.Types$UniqueThisType cannot be cast to scala.reflect.internal.Trees$Tree
scala 2.12.6> @deprecated(try "", "") class C
<console>:11: warning: A try without a catch or finally is equivalent to putting its body in a block; no exceptions are handled.
              @deprecated(try "", "") class C
                          ^
java.lang.ClassCastException: scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$8 cannot be cast to scala.reflect.internal.Trees$Tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment