-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow structural anonymous classes #9201
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
Conversation
Thanks for this. AFAIK, this was the last programmability gap that prevented me from porting my library to dotty. I currently don't have time to do this, but will get on that when I can. |
is implemented by the base trait `reflect.Selectable` of `Vehicle`, which | ||
defines the necessary `selectDynamic` member. | ||
|
||
`Vehicle` could also extend some other subclass of `scala.Selectable` that implements `selectDynamic` and `applyDynamic` differently. But if it does not extend a `Selectable` at all, the code would no longer typecheck: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you write scala.Selectable
but above you write reflect.Selectable
(and also in the tests). I assume this is a typo, but perhaps scala.Selectable
is also a thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, scala.reflect.Selectable is the java-reflection-based implementation of the scala.Selectable mechanism https://github.com/lampepfl/dotty/blob/master/library/src/scala/Selectable.scala https://github.com/lampepfl/dotty/blob/master/library/src/scala/reflect/Selectable.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks for the clarification. (I never use these due to performance anxiety associated with reflection, so I had forgotten about that).
Would it be possible to use dynamic invocation in such cases, is it difficult to allow:
|
We now allow structural dispatch on classes that extend the
scala.Selectable
trait. If a class extendsscala.reflect.Selectable
structural dispatch is resolved using Java reflection.