-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
review: fix: Subtyping relationships for arrays #5466
Conversation
3652bb5
to
37c2ccb
Compare
throw new SpoonException("There are no source level array type declarations"); | ||
} | ||
Class<?> actualClass = base.getActualClass(); | ||
// Arrays of different shapes are not subtypes |
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.
This isn't true?
new Object[0][0] instanceof Object[]
$3 ==> true
This is a consequence of
- If S and T are both reference types, then S[] >1 T[] iff S >1 T.
- Object >1 Object[]
unless I'm missing some context here.
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.
Right, I missed that when reading the rules apparently. That is a bit unfortunate. I guess I need to peel of layers until one or the other reaches a non-array value.
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.
Addressed (hopefully :P). Thanks :)
Thanks! |
This one was a bit of a doozy.
Array subtyping needs to be special cased, as Spoon is not able to build a
CtType
for source-level arrays. Similarly, once we are given a shadowCtType
that refers to an array type, we need to unpack to find the real type to build our hierarchy for. We can not just fall back to the javaClass#isAssignableFrom
, as the super type reference might not be shadowable.Closes #5462.