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

@throws annotation ignored on primary constructor #1420

Closed
scabug opened this issue Oct 13, 2008 · 3 comments
Closed

@throws annotation ignored on primary constructor #1420

scabug opened this issue Oct 13, 2008 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Oct 13, 2008

The @throws annotation on a primary constructor gets associated with the class instead of a method, and is then ignored when generating bytecode. A patch which appears sufficient to remedy this is attached.

@scabug
Copy link
Author

scabug commented Oct 13, 2008

Imported From: https://issues.scala-lang.org/browse/SI-1420?orig=1
Reporter: @paulp
Attachments:

  • throws.diff (created on Oct 13, 2008 3:57:46 PM UTC, 802 bytes)

@scabug
Copy link
Author

scabug commented Oct 16, 2008

@lrytz said:
Annotating the primary constructor is already possible, have a look at the Scala specification, chapter 5.3

class A @throws(classOf[java.io.IOException]) ()

case class B @throws(classOf[java.io.IOException]) (i: Int)

@scabug
Copy link
Author

scabug commented Oct 16, 2008

@paulp said:
I'm sorry I didn't figure that out. I realize I shouldn't be relying too much on anything but the spec, but it'd be nice if an example of this syntax could be added to http://www.scala-lang.org/node/106 . The existing examples all put the annotation on a line by itself (which I did try) but it doesn't parse.

jon:scala-2.7.2.RC3 paulp$$ cat /tmp/an.scala 
case class B 
@throws(classOf[java.io.IOException])(i: Int)

jon:scala-2.7.2.RC3 paulp$$ bin/scalac /tmp/an.scala 
/tmp/an.scala:2: error: expected start of definition
@throws(classOf[java.io.IOException])(i: Int)
                                     ^
one error found

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

No branches or pull requests

2 participants