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
@throws annotation synthesized for class files compiled from Java is broken #7009
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7009?orig=1 |
@gkossakowski said: rm -rf classes/*
Grzegorzs-MacBook-Pro:scala-throws grek$ cat Foo.scala
package test
class Foo[T] extends Exception
Grzegorzs-MacBook-Pro:scala-throws grek$ scalac Foo.scala -d classes/
Grzegorzs-MacBook-Pro:scala-throws grek$ cat Xyz.java
package test;
public class Xyz {
public void abc() throws Foo {}
}
Grzegorzs-MacBook-Pro:scala-throws grek$
Grzegorzs-MacBook-Pro:scala-throws grek$ javac -cp /usr/local/Cellar/scala/2.10.0/libexec/lib/scala-library.jar:classes/ -d classes/ Xyz.java
Grzegorzs-MacBook-Pro:scala-throws grek$ scala -classpath classes/
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._, definitions._ also imported **
** Try :help, :vals, power.<tab> **
scala> rootMirror.getClassByName(newTermName("test.Xyz")).info.member(newTermName("abc"))
res0: $r.intp.global.Symbol = method abc
scala> res0.annotations
res1: List[$r.intp.global.AnnotationInfo] = List(throws(classOf[test.Foo]))
scala> val Literal(const) = res1.head.args.head
const: $r.intp.global.Constant = Constant(test.Foo)
scala> const.typeValue
res2: $r.intp.global.Type = test.Foo
scala> res2.typeParams
res3: List[$r.intp.global.Symbol] = List(type T)
scala> exit
warning: there were 1 deprecation warnings; re-run with -deprecation for details |
@gkossakowski said:
That's why code above compiles; |
@gkossakowski said: |
@gkossakowski said: |
Power REPL shows the problem. See below for comments.
As you can see, we get higher-kinded (unapplied) type for annotation. This is broken and I believe it caused by PR-1347 which introduced type parameter for scala.throws annotation but forgot to change
parseExceptions
inClassfileParser.scala
.This might be related to spurious API changes in sbt's incremental compiler reported here:
sbt/sbt#642 (comment)
The text was updated successfully, but these errors were encountered: