Avoid to generate unecessary checkcast

StackValue already avoid to generate checkcast from a type or an
 array to java.lang.Object. Add a new case to avoid to generate a
 checkcast from an array to an array of java.lang.Object when arrays
 have the same dimensions.

 #KT-22714 Fixed
This commit is contained in:
Mikaël Peltier
2018-02-06 15:56:29 +01:00
committed by Mikhael Bogdanov
parent 9a9452f73a
commit 126afbb8ac
8 changed files with 67 additions and 1 deletions
@@ -395,7 +395,15 @@ public abstract class StackValue {
}
}
else if (toType.getSort() == Type.ARRAY) {
v.checkcast(toType);
if (fromType.getSort() != Type.ARRAY) {
v.checkcast(toType);
}
else if (toType.getDimensions() != fromType.getDimensions()) {
v.checkcast(toType);
}
else if (!toType.getElementType().equals(OBJECT_TYPE)) {
v.checkcast(toType);
}
}
else if (toType.getSort() == Type.OBJECT) {
if (fromType.getSort() == Type.OBJECT || fromType.getSort() == Type.ARRAY) {