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

inaccurate warning regarding meta annotations #9550

Closed
scabug opened this issue Nov 5, 2015 · 2 comments
Closed

inaccurate warning regarding meta annotations #9550

scabug opened this issue Nov 5, 2015 · 2 comments

Comments

@scabug
Copy link

scabug commented Nov 5, 2015

Compiling the following code with scala 2.11.7

class Bippy(@transient str: String) {
  override def toString = str
}

elicits the following warning:

Bippy.scala:1: warning: no valid targets for annotation on value str - it is discarded unused. You may specify targets with meta-annotations, e.g. @(transient @param)
class Bippy(@transient str: String) {
             ^
one warning found

However, javap shows that the field is indeed marked transient, so the warning is inaccurate:

Compiled from "Bippy.scala"
public class Bippy {
  private final transient java.lang.String str;
  public java.lang.String toString();
  public Bippy(java.lang.String);
}

Attempting to eliminate the warning by adding @(transient @field) does no good. In fact, the compiler is only happy when I mark the field @(transient @param) which is not what I want. Why would I want the parameter to be marked transient? It is the field that matters. In fact, looking at the source, scala.transient is already annotated with @field so no extra meta-annotation should be needed.

The superfluous warning just needs to go away.

@scabug
Copy link
Author

scabug commented Nov 5, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9550?orig=1
Reporter: Jeff Olson (jdolson)
Affected Versions: 2.11.7

@som-snytt
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants