This commit is contained in:
Dmitry Jemerov
2011-04-07 15:11:24 +02:00
parent cd3ed17e25
commit b6a078a562
3 changed files with 9 additions and 2 deletions
@@ -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) {
@@ -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;
}
@@ -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());