This commit is contained in:
Dmitry Jemerov
2011-04-07 14:27:02 +02:00
parent 72eda24f62
commit df0a2fb62f
3 changed files with 10 additions and 2 deletions
@@ -468,7 +468,7 @@ public class ExpressionCodegen extends JetVisitor {
DeclarationDescriptor cls = op.getContainingDeclaration();
if (cls instanceof ClassDescriptor) {
final String className = cls.getName();
if (className.equals("Int") || className.equals("Long")) {
if (className.equals("Int") || className.equals("Long") || className.equals("Short")) {
if (op.getName().equals("compareTo")) {
generateCompareOp(expression, opToken);
}
@@ -23,6 +23,9 @@ public class JetTypeMapper {
if (jetType.equals(standardLibrary.getLongType())) {
return Type.LONG_TYPE;
}
if (jetType.equals(standardLibrary.getShortType())) {
return Type.SHORT_TYPE;
}
if (jetType.equals(standardLibrary.getBooleanType())) {
return Type.BOOLEAN_TYPE;
}
@@ -237,7 +237,12 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase {
assertEquals(0L, main.invoke(null, 1, 0));
}
private void binOpTest(final String text, final int arg1, final int arg2, final int expected) throws Exception {
public void testShort() throws Exception {
binOpTest("fun foo(a: Short, b: Short): Int = a + b",
Short.valueOf((short) 32767), Short.valueOf((short) 32767), 65534);
}
private void binOpTest(final String text, final Object arg1, final Object arg2, final int expected) throws Exception {
loadText(text);
System.out.println(generateToText());
final Method main = generateFunction();