From b6a078a562fccd9b6935297f4d5d9c4f3093f1e6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 7 Apr 2011 15:11:24 +0200 Subject: [PATCH] Char --- idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java | 4 ++-- idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java | 3 +++ idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 608c24e90d4..68a515a1783 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -472,7 +472,7 @@ public class ExpressionCodegen extends JetVisitor { if (cls instanceof ClassDescriptor) { final String className = cls.getName(); if (className.equals("Int") || className.equals("Long") || className.equals("Short") || - className.equals("Byte")) { + className.equals("Byte") || className.equals("Char")) { if (op.getName().equals("compareTo")) { generateCompareOp(expression, opToken); } @@ -506,7 +506,7 @@ public class ExpressionCodegen extends JetVisitor { } private static boolean isIntLikePrimitive(Type type) { - return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE; + return type == Type.INT_TYPE || type == Type.SHORT_TYPE || type == Type.BYTE_TYPE || type == Type.CHAR_TYPE; } private static int opcodeForMethod(final String name) { diff --git a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 9c926b3703a..1c30a92a603 100644 --- a/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/idea/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -29,6 +29,9 @@ public class JetTypeMapper { if (jetType.equals(standardLibrary.getByteType())) { return Type.BYTE_TYPE; } + if (jetType.equals(standardLibrary.getCharType())) { + return Type.CHAR_TYPE; + } if (jetType.equals(standardLibrary.getBooleanType())) { return Type.BOOLEAN_TYPE; } diff --git a/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index e1ca7e1ccfd..e23c3c603f8 100644 --- a/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -275,6 +275,10 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase { assertEquals(true, main.invoke(null)); } + public void testChar() throws Exception { + binOpTest("fun foo(a: Char, b: Char): Int = a + b", 'A', (char) 3, (int) 'D'); + } + private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception { loadText(text); System.out.println(generateToText());