Coercion fix

This commit is contained in:
Michael Bogdanov
2014-11-13 17:25:28 +03:00
parent c5d8f1faf5
commit 37bb4ae984
2 changed files with 4 additions and 7 deletions
@@ -390,8 +390,8 @@ public abstract class StackValue {
return new FieldForSharedVar(field.type, field.owner, field.name, newSharedVarReceiver); return new FieldForSharedVar(field.type, field.owner, field.name, newSharedVarReceiver);
} }
public static StackValue coercion(@NotNull StackValue receiver, @NotNull Type type) { public static StackValue coercion(@NotNull StackValue value, @NotNull Type castType) {
return CodegenPackage.coercion(receiver, type); return new CoercionValue(value, castType);
} }
public static StackValue thisOrOuter(@NotNull ExpressionCodegen codegen, @NotNull ClassDescriptor descriptor, boolean isSuper, boolean isExplicit) { public static StackValue thisOrOuter(@NotNull ExpressionCodegen codegen, @NotNull ClassDescriptor descriptor, boolean isSuper, boolean isExplicit) {
@@ -21,17 +21,14 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.Label import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.jet.codegen.StackValue.StackValueWithSimpleReceiver import org.jetbrains.jet.codegen.StackValue.StackValueWithSimpleReceiver
public fun coercion(value: StackValue, castType: Type): StackValue {
return CoercionValue(value, castType)
}
class CoercionValue( class CoercionValue(
val value: StackValue, val value: StackValue,
val castType: Type val castType: Type
) : StackValue(castType) { ) : StackValue(castType) {
override fun putSelector(type: Type, v: InstructionAdapter) { override fun putSelector(type: Type, v: InstructionAdapter) {
value.putSelector(type, v) value.putSelector(castType, v)
StackValue.coerce(castType, type, v)
} }
override fun storeSelector(topOfStackType: Type, v: InstructionAdapter) { override fun storeSelector(topOfStackType: Type, v: InstructionAdapter) {