diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/constantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/constantExpressionEvaluator.kt index 2c7255d62c6..64d2f7f9829 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/constantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/constantExpressionEvaluator.kt @@ -61,6 +61,11 @@ private val binaryOperations = hashMapOf, (Any?, Any?) -> bOp(STRING, FLOAT, "plus", { a, b -> a + b }), bOp(STRING, CHAR, "plus", { a, b -> a + b }), + // Boolean + bOp(BOOLEAN, BOOLEAN, "and", { a, b -> a and b }), + bOp(BOOLEAN, BOOLEAN, "or", { a, b -> a or b }), + bOp(BOOLEAN, BOOLEAN, "xor", { a, b -> a xor b }), + // Byte bOp(BYTE, DOUBLE, "plus", { a, b -> a + b }), bOp(BYTE, FLOAT, "plus", { a, b -> a + b }), @@ -171,6 +176,12 @@ private val binaryOperations = hashMapOf, (Any?, Any?) -> bOp(INT, SHORT, "mod", { a, b -> a % b }), bOp(INT, BYTE, "mod", { a, b -> a % b }), bOp(INT, CHAR, "mod", { a, b -> a % b }), + bOp(INT, INT, "shl", { a, b -> a shl b }), + bOp(INT, INT, "shr", { a, b -> a shr b }), + bOp(INT, INT, "ushr",{ a, b -> a ushr b }), + bOp(INT, INT, "and", { a, b -> a and b }), + bOp(INT, INT, "or", { a, b -> a or b }), + bOp(INT, INT, "xor", { a, b -> a xor b }), // Long bOp(LONG, DOUBLE, "plus", { a, b -> a + b }), @@ -208,6 +219,12 @@ private val binaryOperations = hashMapOf, (Any?, Any?) -> bOp(LONG, SHORT, "mod", { a, b -> a % b }), bOp(LONG, BYTE, "mod", { a, b -> a % b }), bOp(LONG, CHAR, "mod", { a, b -> a % b }), + bOp(LONG, INT, "shl", { a, b -> a shl b }), + bOp(LONG, INT, "shr", { a, b -> a shr b }), + bOp(LONG, INT, "ushr",{ a, b -> a ushr b }), + bOp(LONG, LONG, "and", { a, b -> a and b }), + bOp(LONG, LONG, "or", { a, b -> a or b }), + bOp(LONG, LONG, "xor", { a, b -> a xor b }), // Double bOp(DOUBLE, DOUBLE, "plus", { a, b -> a + b }), diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/boolean.kt b/compiler/testData/resolveAnnotations/parameters/expressions/boolean.kt new file mode 100644 index 00000000000..133b1ec6e18 --- /dev/null +++ b/compiler/testData/resolveAnnotations/parameters/expressions/boolean.kt @@ -0,0 +1,11 @@ +package test + +annotation class Ann( + val b1: Boolean, + val b2: Boolean, + val b3: Boolean +) + +Ann(true and false, false or true, true xor false) class MyClass + +// EXPECTED: Ann[b1 = false: jet.Boolean, b2 = true: jet.Boolean, b3 = true: jet.Boolean] diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt b/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt new file mode 100644 index 00000000000..5a3c0a271f1 --- /dev/null +++ b/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt @@ -0,0 +1,13 @@ +package test + +annotation class Ann(p1: Int, + p2: Short, + p3: Byte, + p4: Int, + p5: Int, + p6: Int + ) + +Ann(1 or 1, 1 and 1, 1 xor 1, 1 shl 1, 1 shr 1, 1 ushr 1) class MyClass + +// EXPECTED: Ann[p1 = 1.toInt(): jet.Int, p2 = 1.toShort(): jet.Short, p3 = 0.toByte(): jet.Byte, p4 = 2.toInt(): jet.Int, p5 = 0.toInt(): jet.Int, p6 = 0.toInt(): jet.Int] diff --git a/compiler/tests/org/jetbrains/jet/resolve/annotation/AnnotationParameterTestGenerated.java b/compiler/tests/org/jetbrains/jet/resolve/annotation/AnnotationParameterTestGenerated.java index eef5f25ff11..9a439660ab4 100644 --- a/compiler/tests/org/jetbrains/jet/resolve/annotation/AnnotationParameterTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/resolve/annotation/AnnotationParameterTestGenerated.java @@ -78,6 +78,11 @@ public class AnnotationParameterTestGenerated extends AbstractAnnotationParamete JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/resolveAnnotations/parameters/expressions"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("boolean.kt") + public void testBoolean() throws Exception { + doTest("compiler/testData/resolveAnnotations/parameters/expressions/boolean.kt"); + } + @TestMetadata("char.kt") public void testChar() throws Exception { doTest("compiler/testData/resolveAnnotations/parameters/expressions/char.kt"); @@ -128,6 +133,11 @@ public class AnnotationParameterTestGenerated extends AbstractAnnotationParamete doTest("compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt"); } + @TestMetadata("intrincics.kt") + public void testIntrincics() throws Exception { + doTest("compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt"); + } + @TestMetadata("long.kt") public void testLong() throws Exception { doTest("compiler/testData/resolveAnnotations/parameters/expressions/long.kt");