Skip to content

@targetName can be used on trait/class/object #11969

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

Closed
griggt opened this issue Apr 1, 2021 · 5 comments
Closed

@targetName can be used on trait/class/object #11969

griggt opened this issue Apr 1, 2021 · 5 comments

Comments

@griggt
Copy link
Contributor

griggt commented Apr 1, 2021

Compiler version

3.0.0-RC2

Minimized code

import annotation.targetName

@targetName("Foo") class Bar
@targetName("Huh") object Bar
@targetName("Wow") trait OhMy

Output

$ ls -l *.class
-rw-r--r-- 1 tgrigg tgrigg 280 Apr  1 11:15  Foo.class
-rw-r--r-- 1 tgrigg tgrigg 554 Apr  1 11:15 'Huh$.class'
-rw-r--r-- 1 tgrigg tgrigg 133 Apr  1 11:15  Wow.class

Expectation

I expected this usage of @targetName to be disallowed.

@smarter
Copy link
Member

smarter commented Apr 1, 2021

Actually there's a few testcases that exercise that, and I guess it makes sense for classes that are supposed to be used infix like some hypothetical class <+>[A, B]: https://github.com/lampepfl/dotty/blob/master/tests/run/alpha-modules-2/7723_1.scala https://github.com/lampepfl/dotty/blob/master/tests/run/alpha-modules-1/7721_1.scala

@smarter smarter closed this as completed Apr 1, 2021
@griggt
Copy link
Contributor Author

griggt commented Apr 1, 2021

Does this code need to account for @targetName then (it seems like at present it doesn't?)

https://github.com/lampepfl/dotty/blob/ea0002d4f2870a3bc1582af10023b614e094a78e/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala#L144-L168

@smarter
Copy link
Member

smarter commented Apr 1, 2021

Hmm, that may be missing indeed, along with dealing with compactified names.

@griggt
Copy link
Contributor Author

griggt commented Apr 1, 2021

I forgot about compactification (I did the PR!), thanks.

@griggt
Copy link
Contributor Author

griggt commented Apr 1, 2021

For anyone curious, this was noticed while testing WIP on :javap for the REPL.

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

2 participants