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

selectDynamic not encodes given name #18612

Closed
goshacodes opened this issue Sep 28, 2023 · 4 comments · Fixed by #18928
Closed

selectDynamic not encodes given name #18612

goshacodes opened this issue Sep 28, 2023 · 4 comments · Fixed by #18928
Labels
area:typer itype:bug Spree Suitable for a future Spree

Comments

@goshacodes
Copy link

goshacodes commented Sep 28, 2023

Compiler version

3.3.0

Minimized code

class X extends scala.reflect.Selectable:
  val `+` = "1"
  
 val x = X()

This one is not working:

x.selectDynamic("+")
Caused by: java.lang.NoSuchMethodException: Playground$X.+()

But this one works:

x.selectDynamic("$plus")

Expectation

This one works

x.selectDynamic("+")

Also I wonder is there a way of encoding given name by hand?
As I understood this blocks scalamock migration to Scala 3, since MethodSymbol#name returned encoded name, while Symbol#name gives raw name, so I can't use reflection to get a field, I need to encode it somehow.

@goshacodes goshacodes added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 28, 2023
@sjrd
Copy link
Member

sjrd commented Sep 28, 2023

FYI: scala.reflect.NameTransformer.encode(name) encodes the given name.

@goshacodes
Copy link
Author

goshacodes commented Sep 28, 2023

Thank you! So is it a bug, if there is a thing for encoding names?

@som-snytt
Copy link
Contributor

Seems like a bug not to work with the decoded name. But should it also work with the encoded name?

@dwijnand dwijnand added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 2, 2023
@mbovel mbovel added the Spree Suitable for a future Spree label Nov 11, 2023
@scala-center-bot
Copy link

This issue was picked for the Issue Spree No. 39 of November 14th, 2023 which takes place in 7 days. @hamzaremmal, @AnotherMedo, @KuceraMartin will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants