Fix const range bounds generation
This commit is contained in:
@@ -179,6 +179,19 @@ public abstract class StackValue {
|
||||
return type == Type.VOID_TYPE ? none() : new OnStack(type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue integerConstant(int value, @NotNull Type type) {
|
||||
if (type == Type.LONG_TYPE) {
|
||||
return constant(Long.valueOf(value), type);
|
||||
}
|
||||
else if (type == Type.BYTE_TYPE || type == Type.SHORT_TYPE || type == Type.INT_TYPE) {
|
||||
return constant(Integer.valueOf(value), type);
|
||||
}
|
||||
else {
|
||||
throw new AssertionError("Unexpected integer type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StackValue constant(@Nullable Object value, @NotNull Type type) {
|
||||
if (type == Type.BOOLEAN_TYPE) {
|
||||
|
||||
+1
-3
@@ -18,10 +18,8 @@ package org.jetbrains.kotlin.codegen.range.forLoop
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtForExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
class ForInUntilConstantRangeLoopGenerator(
|
||||
@@ -36,5 +34,5 @@ class ForInUntilConstantRangeLoopGenerator(
|
||||
codegen.generateReceiverValue(from, false)
|
||||
|
||||
override fun generateTo(): StackValue =
|
||||
StackValue.constant(untilValue, asmElementType)
|
||||
StackValue.integerConstant(untilValue, asmElementType)
|
||||
}
|
||||
Reference in New Issue
Block a user