-
Notifications
You must be signed in to change notification settings - Fork 1.1k
reflect.Selectable does not mangle operator names #4528
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
Comments
@sjrd How does Scala.js name mangling interact with scala.Dynamic ? |
Badly. In scalac, even calls to |
Ouch! So it'd make sense to follow @Blaisorblade suggestion and move the mangling to library code, since Scala.js can overwrite the library code if needed? |
I think so, yes. |
OK, that means something like https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/util/NameTransformer.scala (but that operates on String instead of SimpleName) needs to be moved to dotty-library. |
@sjrd BTW, does it make sense to keep writes to |
Writes to properties are supposed to call the |
this is further complicated by |
I have the impression it's too late to change anything here now. |
May I ask why? |
I thought the issue would apply to all selectables, where changing the encoding might break existing user-defined implementations. But I see this is just reflect.Selectable, so OK. I was fooled by the needs-spec label. Can someone explain why this needs a spec? Also I should not be the one assigned to this, I think. |
FWIW, on Scala 3.5.0 the generated code does call //> using scala 3.5.0
type T = {val a: Int; def a_=(x: Int): Unit}
import scala.reflect.Selectable.reflectiveSelectable
@main def run() =
(new {var a = 10}.asInstanceOf[T]).a = 11 Generates:
Full output:
|
Haven't tried other characters.
Decompiling a bigger example reminds us that the generated method is called
a_$eq
and nota_=
, while the generated code indeed tries to calla_=
(per jad decompilation):Since structural types are intended to be mapped also to other backends (see applications to databases in #1886), it's not clear the encoding should be done by the compiler; we might want to mangle the name inside
reflectiveSelectable
.EDIT: Discovered while testing fix to #4496 and checking all variants.
The text was updated successfully, but these errors were encountered: