-
-
Notifications
You must be signed in to change notification settings - Fork 670
Do precise subtype tests in instanceof #2588
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
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.
I don't really get this stuff, so I can't help much :)
So I wasn't quite happy with the previous take and decided to refactor this more. Now, |
Addresses #2577. One rather trivial part of the issue was that previously, since interfaces are not derived from
Object
but their implementing classes are, ansomeInterface as Object instanceof SomeInterface
would fail. Another was that the check for when a cast may possibly succeed was overly simplistic, thus required more elaborate infrastructure.The seemingly obvious alternative that doesn't work is to simply fall back to do dynamic checks if the relationship between the types is arbitrarily complicated (and hence possibly costly to compute), since that breaks assumptions about such checks being precomputable.
Making a draft for now while I untie the knot in my brain before figuring out how to best test the changes. Is perfectly possible that I missed something, hence I'd appreciate any amount of eyes on the new logic :)