Skip to content

Conversation

@xeno-by
Copy link
Contributor

@xeno-by xeno-by commented Aug 5, 2012

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.

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.
@xeno-by
Copy link
Contributor Author

xeno-by commented Aug 5, 2012

review by @adriaanm or @odersky

@xeno-by
Copy link
Contributor Author

xeno-by commented Aug 5, 2012

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.

@scala-jenkins
Copy link

@scala-jenkins
Copy link

@scala-jenkins
Copy link

@scala-jenkins
Copy link

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.
@odersky
Copy link
Contributor

odersky commented Aug 6, 2012

non-symbolic methods on Any (Any_equals, Any_hashCode) should be mapped to same-named Objetc methods.
Optimize for speed by forming subclasses.

@xeno-by
Copy link
Contributor Author

xeno-by commented Aug 6, 2012

Will be resubmitted jointly with #1048, #1052, #1054 and #1057.

@xeno-by xeno-by closed this Aug 6, 2012
@xeno-by
Copy link
Contributor Author

xeno-by commented Aug 6, 2012

Superceded by #1067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants