KT-2275 fix: wrong coercion between nullable primitives
This commit is contained in:
@@ -1425,7 +1425,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
for (ValueArgument argument : expression.getValueArguments()) {
|
||||
args.add(argument.getArgumentExpression());
|
||||
}
|
||||
return intrinsic.generate(this, v, expressionType(expression), expression, args, receiver, state);
|
||||
Type callType = typeMapper.mapType(resolvedCall.getCandidateDescriptor().getReturnType(),MapTypeMode.VALUE);
|
||||
Type exprType = expressionType(expression);
|
||||
StackValue stackValue = intrinsic.generate(this, v, callType, expression, args, receiver, state);
|
||||
stackValue.put(exprType,v);
|
||||
return StackValue.onStack(exprType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ public class JetTypeMapper {
|
||||
public static final Type TYPE_FUNCTION0 = Type.getObjectType("jet/Function0");
|
||||
public static final Type TYPE_FUNCTION1 = Type.getObjectType("jet/Function1");
|
||||
|
||||
private JetStandardLibrary standardLibrary1;
|
||||
public BindingContext bindingContext;
|
||||
private ClosureAnnotator closureAnnotator;
|
||||
private boolean mapBuiltinsToJava;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import java.util.HashMap
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
(0.toLong() as Number?)?.toByte()
|
||||
(0 as Int?)?.toDouble()
|
||||
}
|
||||
@@ -443,6 +443,9 @@ public class PrimitiveTypesTest extends CodegenTestCase {
|
||||
|
||||
public void testKt2269() {
|
||||
blackBoxFile("regressions/kt2269.kt");
|
||||
System.out.println(generateToText());
|
||||
}
|
||||
|
||||
public void testKt2275() {
|
||||
blackBoxFile("regressions/kt2275.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user