-
Notifications
You must be signed in to change notification settings - Fork 3.1k
first step in making mirrors work with primitives #1057
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
In Scala there are some methods that only exist in symbol tables, but don't have corresponding method entries in Java class files. To the best of my knowledge, these methods can be subdivided into four groups: 1) stuff weaved onto Any, AnyVal and AnyRef, 2) magic methods that Scala exposes to fix Java arrays, 3) compile-time methods (such as classOf and all kinds of macros), 4) miscellaneous stuff (currently only String_+). To support these magic symbols, I've modified the `checkMemberOf` validator to special case Any/AnyVal/AnyRef methods and adjusted MethodMirror and ConstructorMirror classes to use special invokers for those instead of relying on Java reflection.
|
This pull request depends on a #1048, which is wildly popular these days. It also won't merge cleanly with other pull requests, but this really can't be helped. However instead of integrating the offending commit into some pull request so that no merge is necessary, I decided to put it up as a standalone unit of discussion. Anyways, as experience shows, it's a good idea to unite all approved reflection pull request into an ultimate pull request rather than trying to merge them one by one. |
|
Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/75/ |
|
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/778/ |
|
jenkins job pr-rangepos: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/75/ |
|
jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/778/ |
mirrors now carry a class tag of the receiver, so that they can detect value classes being reflected upon and adjust accordingly (e.g. allow Int_+ for ints, but disallow it for Integers). Suprisingly enough derived value classes (SIP-15 guys that inherit from AnyVal) have been working all along, so no modification were required to fix them.
|
non-symbolic methods on Any (Any_equals, Any_hashCode) should be mapped to same-named Objetc methods. |
|
Superceded by #1067 |
mirrors now carry a class tag of the receiver, so that they can detect
value classes being reflected upon and adjust accordingly (e.g. allow
Int_+ for ints, but disallow it for Integers). This is a first step
in fixing SI-6179.
However magic methods on primitives (e.g. Int_+ or Boolean_||) are not
implemented yet. There are a lot of them, and bruteforce solution
would produce a lot of code. Hence we'd better take time to think of a
better way to do it. Anyhow this commit is an improvement, because
it replaces a cryptic error message with a clearly stated error.
Suprisingly enough derived value classes (SIP-15 guys that inherit from AnyVal)
have been working all along, so no modification were required to fix them.