-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 doesn't work with @targetName #18922
Comments
We will work on this issue in today's Spree |
this is a duplicate of #18612 |
the other issue does not specifically mention |
as for the solution, should it be the argument to selectDynamic that is rewritten, or should the implementation of reflect.Selectable contain a lookup table from scala method name to bytecode name? And in this situation we can't even know at all if the original argument has a target name or not def doClose(closable: { def close(): Unit }): Unit =
import reflect.Selectable.reflectiveSelectable
closable.close() leading to a crash: class Resource:
@scala.annotation.targetName("foo")
def close(): Unit = println("closed")
scala> doClose(Resource())
java.lang.NoSuchMethodException: rs$line$2$Resource.close()
at java.base/java.lang.Class.getMethod(Class.java:2395)
at scala.reflect.Selectable.applyDynamic(Selectable.scala:38)
at scala.reflect.Selectable.applyDynamic$(Selectable.scala:11)
at scala.reflect.Selectable$DefaultSelectable.applyDynamic(Selectable.scala:51)
at rs$line$1$.doClose(rs$line$1:3) it would seem perhaps that structural types should not be allowed to conform to methods that have |
That's my point of opening this second issue. I was planning of fixing the first issue by encoding the parameter using |
Ok I've reopened if we consider that the #18612 can be fixed with just name transformer (and not fix the wider issue in general about not knowing what exactly the bytecode name will be) |
Compiler version
3.3.1
Minimized code
Output
Expectation
It should resolve to the correct field independently of the presence of the
@targetName
annotationThe text was updated successfully, but these errors were encountered: