diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 9f6577ebe63..08ed66ffaee 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -344,7 +344,7 @@ public class ExpressionCodegen extends JetVisitor { } } - private String getMethodDescriptor(PsiMethod method) { + private static String getMethodDescriptor(PsiMethod method) { Type returnType = psiTypeToAsm(method.getReturnType()); PsiParameter[] parameters = method.getParameterList().getParameters(); Type[] parameterTypes = new Type[parameters.length]; @@ -354,7 +354,7 @@ public class ExpressionCodegen extends JetVisitor { return Type.getMethodDescriptor(returnType, parameterTypes); } - private Type psiTypeToAsm(PsiType type) { + private static Type psiTypeToAsm(PsiType type) { if (type instanceof PsiPrimitiveType) { if (type == PsiType.VOID) { return Type.VOID_TYPE; @@ -368,6 +368,21 @@ public class ExpressionCodegen extends JetVisitor { if (type == PsiType.BOOLEAN) { return Type.BOOLEAN_TYPE; } + if (type == PsiType.BYTE) { + return Type.BYTE_TYPE; + } + if (type == PsiType.SHORT) { + return Type.SHORT_TYPE; + } + if (type == PsiType.CHAR) { + return Type.CHAR_TYPE; + } + if (type == PsiType.FLOAT) { + return Type.FLOAT_TYPE; + } + if (type == PsiType.DOUBLE) { + return Type.DOUBLE_TYPE; + } } if (type instanceof PsiClassType) { PsiClass psiClass = ((PsiClassType) type).resolve(); diff --git a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java index c9ec7b4b12f..1b1abb1c0b5 100644 --- a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -65,7 +65,7 @@ public class JetTypeMapper { if (jetType.equals(TypeUtils.makeNullable(standardLibrary.getBooleanType()))) { return Type.getObjectType("java/lang/Boolean"); } - if (jetType.equals(standardLibrary.getStringType())) { + if (jetType.equals(standardLibrary.getStringType()) || jetType.equals(standardLibrary.getNullableStringType())) { return Type.getType(String.class); } diff --git a/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 3d2a3f34b53..a0719af4887 100644 --- a/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -308,6 +308,12 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase { binOpTest("fun foo(a: Double, b: Double): Boolean = a == b", 1.0, 2.0, false); } + public void testDoubleToJava() throws Exception { + loadText("fun foo(d: Double): String? = Double.toString(d)"); + final Method main = generateFunction(); + assertEquals("1.0", main.invoke(null, 1.0)); + } + private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception { loadText(text); System.out.println(generateToText());