Conversation
| if (baseType.equals(NullType.getInstance())) { | ||
| return NullType.getInstance(); | ||
| } else if (baseType instanceof ArrayType) { | ||
| return ((ArrayType) baseType).getElementType(); |
There was a problem hiding this comment.
I guess this if we have a multidimensional array e.g. int[ ][ ] this would return int instead of int[ ] ? we need to reduce the amount of dimensions / unwrap as it was done in Soot.
Why they check for NullType and return UnknownType instead of the actual baseType is not clear to me (maybe sanitization but in SootUp we rather would trow an error than silently trying to fix problems introduced/not handled earlier)
There was a problem hiding this comment.
((ArrayType) baseType).getElementType(); handles the int[ ][ ] case I guess
SootUp/sootup.core/src/main/java/sootup/core/types/ArrayType.java
Lines 90 to 96 in 621cabd
There was a problem hiding this comment.
base.getType() is UnknownType when TypeAssigner is not enabled.
I feel it hard to use if we throw errors inside getType. We have to do try-catch every where.
There was a problem hiding this comment.
But baseType would already be unknown, so we can return it directly / same for NullType - Im wondering if handling just ArrayType/return baseType otherwise would be enough?
There was a problem hiding this comment.
The current implementation is correct you want to have the type of a entry in an array. if the array is multidimensional you should get an array as return value.
There was a problem hiding this comment.
I get the point.
else return base.getType() is equivalent from the value perspective.
But this code would imply that the return type of jarrayref is just the array itself, this could be confusing.
There was a problem hiding this comment.
The current implementation is correct you want to have the type of a entry in an array. if the array is multidimensional you should get an array as return value.
There was a problem hiding this comment.
it makes sense.. as these two would be the only valid other base types as the ArrayRef should not point anywhere else than to an Array which is of ArrayType.
JonasKlauke
left a comment
There was a problem hiding this comment.
I see no issue in the implementation.
Thanks 👍
| if (baseType.equals(NullType.getInstance())) { | ||
| return NullType.getInstance(); | ||
| } else if (baseType instanceof ArrayType) { | ||
| return ((ArrayType) baseType).getElementType(); |
There was a problem hiding this comment.
The current implementation is correct you want to have the type of a entry in an array. if the array is multidimensional you should get an array as return value.
swissiety
left a comment
There was a problem hiding this comment.
lets reorder the ifelse so that the ArrayType is the first check as usually someone would use the TypeAssigner
swissiety
left a comment
There was a problem hiding this comment.
thanks for your contribution!
fix #1076