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

Annotations on abstract vals should emit a warning before they silently disappear #6375

Open
scabug opened this issue Sep 15, 2012 · 7 comments

Comments

@scabug
Copy link

scabug commented Sep 15, 2012

Annotation on a val is by default added to the underlying field of a val.

If a val in question is abstract, there's no underlying field, so the annotation goes to waste. Writing @( @scala.annotation.meta.getter) would attach the annotation to the getter as desired, but it's not obvious.

Therefore I propose we emit a warning when an annotation is going to silently disappear.

@scabug
Copy link
Author

scabug commented Sep 15, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6375?orig=1
Reporter: @xeno-by

@scabug
Copy link
Author

scabug commented Sep 15, 2012

@xeno-by said:
Related: #6325

@scabug
Copy link
Author

scabug commented Dec 22, 2012

@paulp said:
scala/scala#1803

@scabug
Copy link
Author

scabug commented May 17, 2013

@paulp said:
dc1b7d5

@scabug
Copy link
Author

scabug commented Jun 12, 2015

Guillaume Massé (masgui) said (edited on Jun 12, 2015 7:31:25 PM UTC):
The parser wont accept annotation with paramers:

cat A.scala

import scala.annotation.meta.param
import scala.annotation.StaticAnnotation
class Foo(a: Int) extends StaticAnnotation
case class Anotated(@(Foo(1) @param) p1: Int)

/nix/store/22dsrlsqp33kqarh4cb9d7dis4kwgvma-scala-2.10.4/bin/scalac A.scala

A.scala:4: error: ')' expected but '(' found.
case class Anotated(@(Foo(1) @param) p1: Int)
                         ^
A.scala:4: error: identifier expected but ')' found.
case class Anotated(@(Foo(1) @param) p1: Int)
                                   ^
A.scala:4: error: ':' expected but eof found.
case class Anotated(@(Foo(1) @param) p1: Int)
                                             ^
three errors found

/nix/store/8ws1mx6fvgf3hijc49356vmm2q4zxzcj-scala-2.11.6/bin/scalac A.scala

A.scala:4: error: ')' expected but '(' found.
case class Anotated(@(Foo(1) @param) p1: Int)
                         ^
A.scala:4: error: identifier expected but ')' found.
case class Anotated(@(Foo(1) @param) p1: Int)
                                   ^
A.scala:4: error: ':' expected but eof found.
case class Anotated(@(Foo(1) @param) p1: Int)
                                             ^
three errors found

@scabug
Copy link
Author

scabug commented Aug 11, 2016

@lrytz said:
scala/scala#5141 drops the warnings (commit 4b657bbe384bd364035060d3702d321b488e9263). Commit message: "Drop warning on potentially discarded annotations, I don't think this warrants a warning".

@scabug
Copy link
Author

scabug commented Aug 11, 2016

@paulp said:
Is the theory that people often annotate members with the intention of that annotation being silently discarded?

Scoreboard: Implementor convenience N+1, User 0

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

1 participant