From ff62489233a05608cf564716e008403213642a37 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sat, 12 Nov 2011 18:37:26 +0400 Subject: [PATCH] No arithmetic for Chars (except for '-') --- compiler/frontend/src/jet/Library.jet | 8 ++++---- .../org/jetbrains/jet/codegen/PrimitiveTypesTest.java | 3 ++- .../tests/org/jetbrains/jet/types/JetTypeCheckerTest.java | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index 67df91c00bd..d69436adc06 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -499,7 +499,7 @@ class Char : Number, Comparable { fun plus(other : Int) : Int fun plus(other : Short) : Int fun plus(other : Byte) : Int - fun plus(other : Char) : Int +// fun plus(other : Char) : Int fun minus(other : Double) : Double fun minus(other : Float) : Float @@ -515,7 +515,7 @@ class Char : Number, Comparable { fun times(other : Int) : Int fun times(other : Short) : Int fun times(other : Byte) : Int - fun times(other : Char) : Int +// fun times(other : Char) : Int fun div(other : Double) : Double fun div(other : Float) : Float @@ -523,7 +523,7 @@ class Char : Number, Comparable { fun div(other : Int) : Int fun div(other : Short) : Int fun div(other : Byte) : Int - fun div(other : Char) : Int +// fun div(other : Char) : Int fun mod(other : Double) : Double fun mod(other : Float) : Float @@ -531,7 +531,7 @@ class Char : Number, Comparable { fun mod(other : Int) : Int fun mod(other : Short) : Int fun mod(other : Byte) : Int - fun mod(other : Char) : Int +// fun mod(other : Char) : Int fun rangeTo(other : Double) : Range fun rangeTo(other : Float) : Range diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index d667cf4598f..d58093ab056 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -104,7 +104,8 @@ public class PrimitiveTypesTest extends CodegenTestCase { } public void testChar() throws Exception { - binOpTest("fun foo(a: Char, b: Char): Int = a + b", 'A', (char) 3, (int) 'D'); + // '+' is not available for Chars + binOpTest("fun foo(a: Char, b: Char): Int = a - b", 'D', (char) 3, (int) 'A'); } public void testFloat() throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index 0cd1450159b..39a7dbd9de7 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -395,7 +395,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { assertType("'1'.plus(1.flt)", "Float"); assertType("'1'.plus(1.lng)", "Long"); assertType("'1'.plus(1)", "Int"); - assertType("'1'.plus('1')", "Int"); + assertType("'1'.minus('1')", "Int"); // Plus is not available for char assertType("(1:Short).plus(1.dbl)", "Double"); assertType("(1:Short).plus(1.flt)", "Float");