Do not treat uninitialized value as a reason to retain boxing
See testData/simpleUnitializedMerge.kt On exit from `if` we merge value in variable with slot 1 (x): - from `if` body we get BoxedBasicValue - from outer block we get UNITIALIZED_VALUE So we just suppose `x` is unitialized after `if` and there's no need to mark BoxedValue as unsafe to remove because it's anyway can't be used after `if` #KT-6842 Fixed
This commit is contained in:
+4
@@ -210,6 +210,10 @@ public class BoxingInterpreter extends OptimizationBasicInterpreter {
|
||||
@Override
|
||||
@NotNull
|
||||
public BasicValue merge(@NotNull BasicValue v, @NotNull BasicValue w) {
|
||||
if (v == BasicValue.UNINITIALIZED_VALUE || w == BasicValue.UNINITIALIZED_VALUE) {
|
||||
return BasicValue.UNINITIALIZED_VALUE;
|
||||
}
|
||||
|
||||
if (v instanceof BoxedBasicValue && ((BoxedBasicValue) v).typeEquals(w)) {
|
||||
onMergeSuccess((BoxedBasicValue) v, (BoxedBasicValue) w);
|
||||
return v;
|
||||
|
||||
+1
@@ -114,6 +114,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
|
||||
if (CollectionsKt.any(usedValues, new Function1<BasicValue, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(BasicValue input) {
|
||||
if (input == BasicValue.UNINITIALIZED_VALUE) return false;
|
||||
return input == null ||
|
||||
!(input instanceof BoxedBasicValue) ||
|
||||
!((BoxedBasicValue) input).isSafeToRemove() ||
|
||||
|
||||
Reference in New Issue
Block a user