diff --git a/compiler/frontend/builtins/jet/Byte.kotlin_class b/compiler/frontend/builtins/jet/Byte.kotlin_class index 939a717dd97..0c44f575e17 100644 Binary files a/compiler/frontend/builtins/jet/Byte.kotlin_class and b/compiler/frontend/builtins/jet/Byte.kotlin_class differ diff --git a/compiler/frontend/builtins/jet/Short.kotlin_class b/compiler/frontend/builtins/jet/Short.kotlin_class index eafafba07cf..cc5560966ad 100644 Binary files a/compiler/frontend/builtins/jet/Short.kotlin_class and b/compiler/frontend/builtins/jet/Short.kotlin_class differ diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 8847bcd860b..76d9e6717a1 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -73,7 +73,7 @@ public final class Byte : jet.Number, jet.Comparable { public open override /*1*/ fun equals(/*0*/ other: jet.Any?): jet.Boolean public open override /*1*/ fun hashCode(): jet.Int public final fun inc(): jet.Byte - public final fun minus(): jet.Byte + public final fun minus(): jet.Int public final fun minus(/*0*/ other: jet.Byte): jet.Int public final fun minus(/*0*/ other: jet.Char): jet.Int public final fun minus(/*0*/ other: jet.Double): jet.Double @@ -88,7 +88,7 @@ public final class Byte : jet.Number, jet.Comparable { public final fun mod(/*0*/ other: jet.Int): jet.Int public final fun mod(/*0*/ other: jet.Long): jet.Long public final fun mod(/*0*/ other: jet.Short): jet.Int - public final fun plus(): jet.Byte + public final fun plus(): jet.Int public final fun plus(/*0*/ other: jet.Byte): jet.Int public final fun plus(/*0*/ other: jet.Char): jet.Int public final fun plus(/*0*/ other: jet.Double): jet.Double @@ -1493,7 +1493,7 @@ public final class Short : jet.Number, jet.Comparable { public open override /*1*/ fun equals(/*0*/ other: jet.Any?): jet.Boolean public open override /*1*/ fun hashCode(): jet.Int public final fun inc(): jet.Short - public final fun minus(): jet.Short + public final fun minus(): jet.Int public final fun minus(/*0*/ other: jet.Byte): jet.Int public final fun minus(/*0*/ other: jet.Char): jet.Int public final fun minus(/*0*/ other: jet.Double): jet.Double @@ -1508,7 +1508,7 @@ public final class Short : jet.Number, jet.Comparable { public final fun mod(/*0*/ other: jet.Int): jet.Int public final fun mod(/*0*/ other: jet.Long): jet.Long public final fun mod(/*0*/ other: jet.Short): jet.Int - public final fun plus(): jet.Short + public final fun plus(): jet.Int public final fun plus(/*0*/ other: jet.Byte): jet.Int public final fun plus(/*0*/ other: jet.Char): jet.Int public final fun plus(/*0*/ other: jet.Double): jet.Double diff --git a/compiler/testData/codegen/box/unaryOp/call.kt b/compiler/testData/codegen/box/unaryOp/call.kt index 1431554f7b8..9b354aea3f2 100644 --- a/compiler/testData/codegen/box/unaryOp/call.kt +++ b/compiler/testData/codegen/box/unaryOp/call.kt @@ -6,8 +6,8 @@ fun box(): String { val a5: Double = 1.0.minus() val a6: Float = 1f.minus() - if (a1 != -1.toByte()) return "fail 1" - if (a2 != -1.toShort()) return "fail -1" + if (a1 != (-1).toByte()) return "fail 1" + if (a2 != (-1).toShort()) return "fail -1" if (a3 != -1) return "fail 3" if (a4 != -1L) return "fail 4" if (a5 != -1.0) return "fail 5" diff --git a/compiler/testData/codegen/box/unaryOp/callNullable.kt b/compiler/testData/codegen/box/unaryOp/callNullable.kt index 6bfeb00c4cb..95bbd208ebf 100644 --- a/compiler/testData/codegen/box/unaryOp/callNullable.kt +++ b/compiler/testData/codegen/box/unaryOp/callNullable.kt @@ -6,8 +6,8 @@ fun box(): String { val a5: Double? = 1.0.minus() val a6: Float? = 1f.minus() - if (a1!! != -1.toByte()) return "fail 1" - if (a2!! != -1.toShort()) return "fail 2" + if (a1!! != (-1).toByte()) return "fail 1" + if (a2!! != (-1).toShort()) return "fail 2" if (a3!! != -1) return "fail 3" if (a4!! != -1L) return "fail 4" if (a5!! != -1.0) return "fail 5" diff --git a/compiler/testData/codegen/box/unaryOp/callWithCommonType.kt b/compiler/testData/codegen/box/unaryOp/callWithCommonType.kt index e97ae934efe..a3fa43dc3c3 100644 --- a/compiler/testData/codegen/box/unaryOp/callWithCommonType.kt +++ b/compiler/testData/codegen/box/unaryOp/callWithCommonType.kt @@ -1,6 +1,6 @@ fun box(): String { if (!foo(1.toByte())) return "fail 1" - if (!foo(-1.toByte())) return "fail 2" + if (!foo((1.toByte()).inc())) return "fail 2" return "OK" } diff --git a/compiler/testData/codegen/box/unaryOp/intrinsic.kt b/compiler/testData/codegen/box/unaryOp/intrinsic.kt index e2766c5abe8..30bd7d9d8f0 100644 --- a/compiler/testData/codegen/box/unaryOp/intrinsic.kt +++ b/compiler/testData/codegen/box/unaryOp/intrinsic.kt @@ -6,8 +6,8 @@ fun box(): String { val a5: Double = -1.0 val a6: Float = -1f - if (a1 != -1.toByte()) return "fail 1" - if (a2 != -1.toShort()) return "fail 2" + if (a1 != (-1).toByte()) return "fail 1" + if (a2 != (-1).toShort()) return "fail 2" if (a3 != -1) return "fail 3" if (a4 != -1L) return "fail 4" if (a5 != -1.0) return "fail 5" diff --git a/compiler/testData/codegen/box/unaryOp/intrinsicNullable.kt b/compiler/testData/codegen/box/unaryOp/intrinsicNullable.kt index a7756e17247..0463bcddba9 100644 --- a/compiler/testData/codegen/box/unaryOp/intrinsicNullable.kt +++ b/compiler/testData/codegen/box/unaryOp/intrinsicNullable.kt @@ -6,8 +6,8 @@ fun box(): String { val a5: Double? = -1.0 val a6: Float? = -1f - if (a1!! != -1.toByte()) return "fail 1" - if (a2!! != -1.toShort()) return "fail 2" + if (a1!! != (-1).toByte()) return "fail 1" + if (a2!! != (-1).toShort()) return "fail 2" if (a3!! != -1) return "fail 3" if (a4!! != -1L) return "fail 4" if (a5!! != -1.0) return "fail 5" diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt b/compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt index 2e0af867684..b3cf2d96acf 100644 --- a/compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt @@ -7,11 +7,11 @@ fun box(): String { val ann = javaClass().getAnnotation(javaClass()) if (ann == null) return "fail: cannot find Ann on MyClass}" if (ann.i != -2) return "fail: annotation parameter i should be -2, but was ${ann.i}" - if (ann.s != -2.toShort()) return "fail: annotation parameter i should be -2, but was ${ann.i}" + if (ann.s != (-2).toShort()) return "fail: annotation parameter i should be -2, but was ${ann.i}" if (ann.f != -2.toFloat()) return "fail: annotation parameter i should be -2, but was ${ann.i}" if (ann.d != -2.toDouble()) return "fail: annotation parameter i should be -2, but was ${ann.i}" if (ann.l != -2.toLong()) return "fail: annotation parameter i should be -2, but was ${ann.i}" - if (ann.b != -2.toByte()) return "fail: annotation parameter i should be -2, but was ${ann.i}" + if (ann.b != (-2).toByte()) return "fail: annotation parameter i should be -2, but was ${ann.i}" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/byte.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/byte.kt index d01f082be59..ce33977b555 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/byte.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/byte.kt @@ -1,7 +1,7 @@ data class A(val a: Byte) fun box() : String { - val v1 = A(-10.toByte()).hashCode() - val v2 = (-10.toByte() as Byte?)!!.hashCode() + val v1 = A(10.toByte()).hashCode() + val v2 = (10.toByte() as Byte?)!!.hashCode() return if( v1 == v2 ) "OK" else "$v1 $v2" } diff --git a/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/short.kt b/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/short.kt index 88e26b6d05e..5e220e27cfc 100644 --- a/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/short.kt +++ b/compiler/testData/codegen/boxWithStdlib/dataClasses/hashcode/short.kt @@ -1,7 +1,7 @@ data class A(val a: Short) fun box() : String { - val v1 = A(-10.toShort()).hashCode() - val v2 = (-10.toShort() as Short?)!!.hashCode() + val v1 = A(10.toShort()).hashCode() + val v2 = (10.toShort() as Short?)!!.hashCode() return if( v1 == v2 ) "OK" else "$v1 $v2" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt index f9a083f633f..47137c3a9e7 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt @@ -14,23 +14,23 @@ fun box(): String { } val list2 = ArrayList() - val range2 = 10.toByte()..-5.toByte() + val range2 = 10.toByte()..(-5).toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } if (list2 != listOf()) { - return "Wrong elements for 10.toByte()..-5.toByte(): $list2" + return "Wrong elements for 10.toByte()..(-5).toByte(): $list2" } val list3 = ArrayList() - val range3 = 10.toShort()..-5.toShort() + val range3 = 10.toShort()..(-5).toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } if (list3 != listOf()) { - return "Wrong elements for 10.toShort()..-5.toShort(): $list3" + return "Wrong elements for 10.toShort()..(-5).toShort(): $list3" } val list4 = ArrayList() diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt index b91e44763e7..02859c16667 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt @@ -13,21 +13,21 @@ fun box(): String { } val list2 = ArrayList() - for (i in 10.toByte()..-5.toByte()) { + for (i in 10.toByte()..(-5).toByte()) { list2.add(i) if (list2.size() > 23) break } if (list2 != listOf()) { - return "Wrong elements for 10.toByte()..-5.toByte(): $list2" + return "Wrong elements for 10.toByte()..(-5).toByte(): $list2" } val list3 = ArrayList() - for (i in 10.toShort()..-5.toShort()) { + for (i in 10.toShort()..(-5).toShort()) { list3.add(i) if (list3.size() > 23) break } if (list3 != listOf()) { - return "Wrong elements for 10.toShort()..-5.toShort(): $list3" + return "Wrong elements for 10.toShort()..(-5).toShort(): $list3" } val list4 = ArrayList() diff --git a/compiler/testData/diagnostics/tests/evaluate/unaryMinusDepOnExpType.kt b/compiler/testData/diagnostics/tests/evaluate/unaryMinusDepOnExpType.kt index 2d120862fd0..2af454e35b9 100644 --- a/compiler/testData/diagnostics/tests/evaluate/unaryMinusDepOnExpType.kt +++ b/compiler/testData/diagnostics/tests/evaluate/unaryMinusDepOnExpType.kt @@ -7,14 +7,15 @@ fun test() { fooInt(-1) fooInt(-1111111111111111111) fooInt(-1.toInt()) - fooInt(-1.toByte()) + fooInt(-1.toByte()) fooInt(-1.toLong()) - fooInt(-1.toShort()) + fooInt(-1.toShort()) fooByte(-1) fooByte(-1111111111111111111) fooByte(-1.toInt()) - fooByte(-1.toByte()) + fooByte(-1.toByte()) + fooByte((-1).toByte()) fooByte(-1.toLong()) fooByte(-1.toShort()) @@ -30,5 +31,6 @@ fun test() { fooShort(-1.toInt()) fooShort(-1.toByte()) fooShort(-1.toLong()) - fooShort(-1.toShort()) + fooShort(-1.toShort()) + fooShort((-1).toShort()) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndepWoExpType.kt b/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndepWoExpType.kt index d9dc367c7a3..40a393d0021 100644 --- a/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndepWoExpType.kt +++ b/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndepWoExpType.kt @@ -1,8 +1,8 @@ val p1 = -1 val p2 = -1.toLong() -val p3 = -1.toByte() +val p3 = (-1).toByte() val p4 = -1.toInt() -val p5 = -1.toShort() +val p5 = (-1).toShort() val p6 = -1111111111111111111 fun fooInt(p: Int) = p diff --git a/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.kt b/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.kt index 6e454d6090f..03091002dcc 100644 --- a/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.kt +++ b/compiler/testData/diagnostics/tests/evaluate/unaryMinusIndependentExpType.kt @@ -13,8 +13,8 @@ val l2: Byte = -1.toLong() val l3: Int = -1.toLong() val l4: Short = -1.toLong() -val b1: Byte = -1.toByte() -val b2: Int = -1.toByte() +val b1: Byte = -1.toByte() +val b2: Int = -1.toByte() val b3: Long = -1.toByte() val b4: Short = -1.toByte() @@ -24,6 +24,6 @@ val i3: Long = -1.toInt() val i4: Short = -1.toInt() val s1: Byte = -1.toShort() -val s2: Int = -1.toShort() +val s2: Int = -1.toShort() val s3: Long = -1.toShort() -val s4: Short = -1.toShort() \ No newline at end of file +val s4: Short = -1.toShort() \ No newline at end of file diff --git a/compiler/testData/evaluate/constant/unaryMinusIndepWoExpType.kt b/compiler/testData/evaluate/constant/unaryMinusIndepWoExpType.kt index 9ba92fdde8a..5b6752b789c 100644 --- a/compiler/testData/evaluate/constant/unaryMinusIndepWoExpType.kt +++ b/compiler/testData/evaluate/constant/unaryMinusIndepWoExpType.kt @@ -7,10 +7,16 @@ val p1 = -1 val p2 = -1.toLong() // val p3: -1.toByte() -val p3 = -1.toByte() +val p3 = (-1).toByte() + +// val p3a: -1.toInt() +val p3a =-1.toByte() // val p4: -1.toInt() val p4 = -1.toInt() // val p5: -1.toShort() -val p5 = -1.toShort() +val p5 = (-1).toShort() + +// val p5a: -1.toInt() +val p5a = -1.toShort() diff --git a/compiler/testData/evaluate/constant/unaryMinusIndependentExpType.kt b/compiler/testData/evaluate/constant/unaryMinusIndependentExpType.kt index 288873a6cb6..e78abcf273b 100644 --- a/compiler/testData/evaluate/constant/unaryMinusIndependentExpType.kt +++ b/compiler/testData/evaluate/constant/unaryMinusIndependentExpType.kt @@ -25,16 +25,16 @@ val l3: Int = -1.toLong() val l4: Short = -1.toLong() -// val b1: -1.toByte() +// val b1: -1.toInt() val b1: Byte = -1.toByte() -// val b2: -1.toByte() +// val b2: -1.toInt() val b2: Int = -1.toByte() -// val b3: -1.toByte() +// val b3: -1.toInt() val b3: Long = -1.toByte() -// val b4: -1.toByte() +// val b4: -1.toInt() val b4: Short = -1.toByte() @@ -50,14 +50,14 @@ val i3: Long = -1.toInt() // val i4: -1.toInt() val i4: Short = -1.toInt() -// val s1: -1.toShort() +// val s1: -1.toInt() val s1: Byte = -1.toShort() -// val s2: -1.toShort() +// val s2: -1.toInt() val s2: Int = -1.toShort() -// val s3: -1.toShort() +// val s3: -1.toInt() val s3: Long = -1.toShort() -// val s4: -1.toShort() +// val s4: -1.toInt() val s4: Short = -1.toShort() \ No newline at end of file diff --git a/idea/builtinsSrc/jet/Numbers.kt b/idea/builtinsSrc/jet/Numbers.kt index 00f72b282bf..6cfb95265c2 100644 --- a/idea/builtinsSrc/jet/Numbers.kt +++ b/idea/builtinsSrc/jet/Numbers.kt @@ -387,8 +387,8 @@ public class Short private () : Number, Comparable { public fun inc() : Short public fun dec() : Short - public fun plus() : Short - public fun minus() : Short + public fun plus() : Int + public fun minus() : Int public override fun toDouble() : Double public override fun toFloat() : Float @@ -461,8 +461,8 @@ public class Byte private () : Number, Comparable { public fun inc() : Byte public fun dec() : Byte - public fun plus() : Byte - public fun minus() : Byte + public fun plus() : Int + public fun minus() : Int public override fun toDouble() : Double public override fun toFloat() : Float diff --git a/js/js.translator/testFiles/number/cases/doubleConversions.kt b/js/js.translator/testFiles/number/cases/doubleConversions.kt index 576a50d242b..bdad193fd78 100644 --- a/js/js.translator/testFiles/number/cases/doubleConversions.kt +++ b/js/js.translator/testFiles/number/cases/doubleConversions.kt @@ -25,13 +25,13 @@ fun box(): Boolean { if (cn.toFloat() != -3.6.toFloat()) { return false } - if (cn.toByte() != -3.toByte()) { + if (cn.toByte() != (-3).toByte()) { return false } if (cn.toInt() != -3) { return false } - if (cn.toShort() != -3.toShort()) { + if (cn.toShort() != (-3).toShort()) { return false } @@ -59,13 +59,13 @@ fun box(): Boolean { if (fn.toFloat() != -3.6.toFloat()) { return false } - if (fn.toByte() != -3.toByte()) { + if (fn.toByte() != (-3).toByte()) { return false } if (fn.toInt() != -3) { return false } - if (fn.toShort() != -3.toShort()) { + if (fn.toShort() != (-3).toShort()) { return false } return true diff --git a/js/js.translator/testFiles/number/cases/intConversions.kt b/js/js.translator/testFiles/number/cases/intConversions.kt index 29a1e5913ea..af94266e173 100644 --- a/js/js.translator/testFiles/number/cases/intConversions.kt +++ b/js/js.translator/testFiles/number/cases/intConversions.kt @@ -18,7 +18,7 @@ fun box(): Boolean { return false } val c2: Int = -5 - if (c2.toShort() != -5.toShort()) { + if (c2.toShort() != (-5).toShort()) { return false } if (c2.toFloat() != -5.toFloat()) { diff --git a/libraries/stdlib/test/language/RangeIterationTest.kt b/libraries/stdlib/test/language/RangeIterationTest.kt index 03fe755dd86..29190d6b376 100644 --- a/libraries/stdlib/test/language/RangeIterationTest.kt +++ b/libraries/stdlib/test/language/RangeIterationTest.kt @@ -45,8 +45,8 @@ public class RangeIterationTest { test fun emptyRange() { doTest(10..5, 10, 5, 1, listOf()) - doTest(10.toByte()..-5.toByte(), 10.toByte(), -5.toByte(), 1, listOf()) - doTest(10.toShort()..-5.toShort(), 10.toShort(), -5.toShort(), 1, listOf()) + doTest(10.toByte()..(-5).toByte(), 10.toByte(), (-5).toByte(), 1, listOf()) + doTest(10.toShort()..(-5).toShort(), 10.toShort(), (-5).toShort(), 1, listOf()) doTest(10.toLong()..-5.toLong(), 10.toLong(), -5.toLong(), 1.toLong(), listOf()) doTest('z'..'a', 'z', 'a', 1, listOf()) diff --git a/libraries/stdlib/test/language/RangeTest.kt b/libraries/stdlib/test/language/RangeTest.kt index 9fd58cac6d7..101c186236e 100644 --- a/libraries/stdlib/test/language/RangeTest.kt +++ b/libraries/stdlib/test/language/RangeTest.kt @@ -23,12 +23,12 @@ public class RangeTest { } test fun byteRange() { - val range = -5.toByte()..9.toByte() - assertFalse(-100.toByte() in range) - assertFalse(-6.toByte() in range) + val range = (-5).toByte()..9.toByte() + assertFalse((-100).toByte() in range) + assertFalse((-6).toByte() in range) - assertTrue(-5.toByte() in range) - assertTrue(-4.toByte() in range) + assertTrue((-5).toByte() in range) + assertTrue((-4).toByte() in range) assertTrue(0.toByte() in range) assertTrue(3.toByte() in range) assertTrue(8.toByte() in range) @@ -39,12 +39,12 @@ public class RangeTest { } test fun shortRange() { - val range = -5.toShort()..9.toShort() - assertFalse(-1000.toShort() in range) - assertFalse(-6.toShort() in range) + val range = (-5).toShort()..9.toShort() + assertFalse((-1000).toShort() in range) + assertFalse((-6).toShort() in range) - assertTrue(-5.toShort() in range) - assertTrue(-4.toShort() in range) + assertTrue((-5).toShort() in range) + assertTrue((-4).toShort() in range) assertTrue(0.toShort() in range) assertTrue(3.toShort() in range) assertTrue(8.toShort() in range)