scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

annotations on type alias are lost due to normalization in uncurry or before #6779

Open scabug opened 11 years ago

scabug commented 11 years ago

Simple Test Case:

package test.annotation

import javax.xml.bind.annotation._
import javax.xml.bind.annotation.XmlElement._
import scala.reflect.BeanInfo

@XmlRootElement(name = "item")
@XmlType /* this annotation is needed for Spring's Jaxb2Marshaller.supports method */
@BeanInfo
class test {

}
eric@Erics-MacBook-Pro:~$ scalac -deprecation test.scala
eric@Erics-MacBook-Pro:~$

https://github.com/scala/scala/blob/master/src/library/scala/reflect/package.scala

  @deprecated("Use `@scala.beans.BeanInfo` instead", "2.10.0")
  type BeanInfo = scala.beans.BeanInfo

Does the type get replaced before the deprecation is checked?

scabug commented 11 years ago

Imported From: https://issues.scala-lang.org/browse/SI-6779?orig=1 Reporter: Eric Peters (ericpeters) Affected Versions: 2.10.0-RC3, 2.10.2-RC2

scabug commented 11 years ago

@paulp said: "Does the type get replaced before the deprecation is checked?"

Yep. It seems that for annotations, type aliases are normalized in typer, but deprecations aren't checked for until refchecks. I don't know if the eager normalization is necessary.

scabug commented 11 years ago

@paulp said: Also, this suggests a more serious problem than missed deprecation warnings. Any annotations on a type alias which represents an annotation may be lost before they are processed.

scabug commented 11 years ago

@paulp said: Here is another one; it's a bit subtle that this is a bug because it does issue a deprecation warning. The problem is that it's the deprecation warning for scala.annotation.cloneable, not scala.cloneable. So again the type is being replaced too early.

scala> @scala.cloneable class Foo()
<console>:7: warning: class cloneable in package annotation is deprecated: instead of `@cloneable class C`, use `class C extends Cloneable`
       @scala.cloneable class Foo()
                              ^
defined class Foo