Rename unary plus/minus in builtins and stdlib

This commit is contained in:
Yan Zhulanow
2015-10-12 19:19:22 +03:00
parent f7ce0c2d20
commit d52f245cf7
23 changed files with 432 additions and 82 deletions
+12 -12
View File
@@ -62,7 +62,6 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public final operator fun div(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun div(/*0*/ other: kotlin.Short): kotlin.Int
public final operator fun inc(): kotlin.Byte
public final operator fun minus(): kotlin.Int
public final operator fun minus(/*0*/ other: kotlin.Byte): kotlin.Int
public final operator fun minus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -75,7 +74,6 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public final operator fun mod(/*0*/ other: kotlin.Int): kotlin.Int
public final operator fun mod(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun mod(/*0*/ other: kotlin.Short): kotlin.Int
public final operator fun plus(): kotlin.Int
public final operator fun plus(/*0*/ other: kotlin.Byte): kotlin.Int
public final operator fun plus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -101,6 +99,8 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public open override /*1*/ fun toInt(): kotlin.Int
public open override /*1*/ fun toLong(): kotlin.Long
public open override /*1*/ fun toShort(): kotlin.Short
public final operator fun unaryMinus(): kotlin.Int
public final operator fun unaryPlus(): kotlin.Int
public companion object Companion : kotlin.IntegerConstants<kotlin.Byte> {
/*primary*/ private constructor Companion()
@@ -331,7 +331,6 @@ public final class Double : kotlin.Number, kotlin.Comparable<kotlin.Double> {
public final operator fun div(/*0*/ other: kotlin.Long): kotlin.Double
public final operator fun div(/*0*/ other: kotlin.Short): kotlin.Double
public final operator fun inc(): kotlin.Double
public final operator fun minus(): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Byte): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Float): kotlin.Double
@@ -344,7 +343,6 @@ public final class Double : kotlin.Number, kotlin.Comparable<kotlin.Double> {
public final operator fun mod(/*0*/ other: kotlin.Int): kotlin.Double
public final operator fun mod(/*0*/ other: kotlin.Long): kotlin.Double
public final operator fun mod(/*0*/ other: kotlin.Short): kotlin.Double
public final operator fun plus(): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Byte): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Float): kotlin.Double
@@ -370,6 +368,8 @@ public final class Double : kotlin.Number, kotlin.Comparable<kotlin.Double> {
public open override /*1*/ fun toInt(): kotlin.Int
public open override /*1*/ fun toLong(): kotlin.Long
public open override /*1*/ fun toShort(): kotlin.Short
public final operator fun unaryMinus(): kotlin.Double
public final operator fun unaryPlus(): kotlin.Double
public companion object Companion : kotlin.FloatingPointConstants<kotlin.Double> {
/*primary*/ private constructor Companion()
@@ -481,7 +481,6 @@ public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
public final operator fun div(/*0*/ other: kotlin.Long): kotlin.Float
public final operator fun div(/*0*/ other: kotlin.Short): kotlin.Float
public final operator fun inc(): kotlin.Float
public final operator fun minus(): kotlin.Float
public final operator fun minus(/*0*/ other: kotlin.Byte): kotlin.Float
public final operator fun minus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -494,7 +493,6 @@ public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
public final operator fun mod(/*0*/ other: kotlin.Int): kotlin.Float
public final operator fun mod(/*0*/ other: kotlin.Long): kotlin.Float
public final operator fun mod(/*0*/ other: kotlin.Short): kotlin.Float
public final operator fun plus(): kotlin.Float
public final operator fun plus(/*0*/ other: kotlin.Byte): kotlin.Float
public final operator fun plus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -520,6 +518,8 @@ public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
public open override /*1*/ fun toInt(): kotlin.Int
public open override /*1*/ fun toLong(): kotlin.Long
public open override /*1*/ fun toShort(): kotlin.Short
public final operator fun unaryMinus(): kotlin.Float
public final operator fun unaryPlus(): kotlin.Float
public companion object Companion : kotlin.FloatingPointConstants<kotlin.Float> {
/*primary*/ private constructor Companion()
@@ -635,7 +635,6 @@ public final class Int : kotlin.Number, kotlin.Comparable<kotlin.Int> {
public final operator fun div(/*0*/ other: kotlin.Short): kotlin.Int
public final operator fun inc(): kotlin.Int
public final fun inv(): kotlin.Int
public final operator fun minus(): kotlin.Int
public final operator fun minus(/*0*/ other: kotlin.Byte): kotlin.Int
public final operator fun minus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -649,7 +648,6 @@ public final class Int : kotlin.Number, kotlin.Comparable<kotlin.Int> {
public final operator fun mod(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun mod(/*0*/ other: kotlin.Short): kotlin.Int
public final infix fun or(/*0*/ other: kotlin.Int): kotlin.Int
public final operator fun plus(): kotlin.Int
public final operator fun plus(/*0*/ other: kotlin.Byte): kotlin.Int
public final operator fun plus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -677,6 +675,8 @@ public final class Int : kotlin.Number, kotlin.Comparable<kotlin.Int> {
public open override /*1*/ fun toInt(): kotlin.Int
public open override /*1*/ fun toLong(): kotlin.Long
public open override /*1*/ fun toShort(): kotlin.Short
public final operator fun unaryMinus(): kotlin.Int
public final operator fun unaryPlus(): kotlin.Int
public final infix fun ushr(/*0*/ bits: kotlin.Int): kotlin.Int
public final infix fun xor(/*0*/ other: kotlin.Int): kotlin.Int
@@ -811,7 +811,6 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public final operator fun div(/*0*/ other: kotlin.Short): kotlin.Long
public final operator fun inc(): kotlin.Long
public final fun inv(): kotlin.Long
public final operator fun minus(): kotlin.Long
public final operator fun minus(/*0*/ other: kotlin.Byte): kotlin.Long
public final operator fun minus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -825,7 +824,6 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public final operator fun mod(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun mod(/*0*/ other: kotlin.Short): kotlin.Long
public final infix fun or(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun plus(): kotlin.Long
public final operator fun plus(/*0*/ other: kotlin.Byte): kotlin.Long
public final operator fun plus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -853,6 +851,8 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public open override /*1*/ fun toInt(): kotlin.Int
public open override /*1*/ fun toLong(): kotlin.Long
public open override /*1*/ fun toShort(): kotlin.Short
public final operator fun unaryMinus(): kotlin.Long
public final operator fun unaryPlus(): kotlin.Long
public final infix fun ushr(/*0*/ bits: kotlin.Int): kotlin.Long
public final infix fun xor(/*0*/ other: kotlin.Long): kotlin.Long
@@ -1127,7 +1127,6 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public final operator fun div(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun div(/*0*/ other: kotlin.Short): kotlin.Int
public final operator fun inc(): kotlin.Short
public final operator fun minus(): kotlin.Int
public final operator fun minus(/*0*/ other: kotlin.Byte): kotlin.Int
public final operator fun minus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun minus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -1140,7 +1139,6 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public final operator fun mod(/*0*/ other: kotlin.Int): kotlin.Int
public final operator fun mod(/*0*/ other: kotlin.Long): kotlin.Long
public final operator fun mod(/*0*/ other: kotlin.Short): kotlin.Int
public final operator fun plus(): kotlin.Int
public final operator fun plus(/*0*/ other: kotlin.Byte): kotlin.Int
public final operator fun plus(/*0*/ other: kotlin.Double): kotlin.Double
public final operator fun plus(/*0*/ other: kotlin.Float): kotlin.Float
@@ -1166,6 +1164,8 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public open override /*1*/ fun toInt(): kotlin.Int
public open override /*1*/ fun toLong(): kotlin.Long
public open override /*1*/ fun toShort(): kotlin.Short
public final operator fun unaryMinus(): kotlin.Int
public final operator fun unaryPlus(): kotlin.Int
public companion object Companion : kotlin.IntegerConstants<kotlin.Short> {
/*primary*/ private constructor Companion()
@@ -36,7 +36,7 @@ L0:
v(val v = -1)
r(1) -> <v1>
mark(-1)
call(-1, minus|<v1>) -> <v2>
call(-1, unaryMinus|<v1>) -> <v2>
w(v|<v2>)
2 mark({ x = w z = 8 })
magic[IMPLICIT_RECEIVER](x) -> <v3>
@@ -31,7 +31,7 @@ class A(val w: Char) {
<v6>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v6>
<v9>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v9>
1 <v1>: Int NEW: r(1) -> <v1>
-1 <v2>: Int NEW: call(-1, minus|<v1>) -> <v2>
-1 <v2>: Int NEW: call(-1, unaryMinus|<v1>) -> <v2>
w <v5>: Int NEW: r(w|<v4>) -> <v5>
8 <v7>: Int NEW: r(8) -> <v7>
z = 8 !<v8>: *
@@ -67,7 +67,7 @@ L2 [after default value for parameter u]:
v(val v = -1)
r(1) -> <v9>
mark(-1)
call(-1, minus|<v9>) -> <v10>
call(-1, unaryMinus|<v9>) -> <v10>
w(v|<v10>)
2 mark({ x = w z = 8 })
magic[IMPLICIT_RECEIVER](x) -> <v11>
@@ -45,7 +45,7 @@ u <v6>: Int NEW: r(u) -> <v6>
w.toInt() + u <v7>: Int NEW: call(w.toInt() + u, plus|<v5>, <v6>) -> <v7>
B(w.toInt() + u) <v8>: * NEW: call(B(w.toInt() + u), <init>|<v7>) -> <v8>
1 <v9>: Int NEW: r(1) -> <v9>
-1 <v10>: Int NEW: call(-1, minus|<v9>) -> <v10>
-1 <v10>: Int NEW: call(-1, unaryMinus|<v9>) -> <v10>
w <v13>: Int NEW: r(w|<v12>) -> <v13>
8 <v15>: Int NEW: r(8) -> <v15>
z = 8 !<v16>: *
@@ -57,7 +57,7 @@ L0:
v(val v = -1)
r(1) -> <v1>
mark(-1)
call(-1, minus|<v1>) -> <v2>
call(-1, unaryMinus|<v1>) -> <v2>
w(v|<v2>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v3>
@@ -107,7 +107,7 @@ L2 [after default value for parameter b]:
v(val v = -1)
r(1) -> <v5>
mark(-1)
call(-1, minus|<v5>) -> <v6>
call(-1, unaryMinus|<v5>) -> <v6>
w(v|<v6>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v7>
@@ -73,7 +73,7 @@ L0:
v(val v = -1)
r(1) -> <v2>
mark(-1)
call(-1, minus|<v2>) -> <v3>
call(-1, unaryMinus|<v2>) -> <v3>
w(v|<v3>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v4>
@@ -124,7 +124,7 @@ L2 [after default value for parameter b]:
v(val v = -1)
r(1) -> <v6>
mark(-1)
call(-1, minus|<v6>) -> <v7>
call(-1, unaryMinus|<v6>) -> <v7>
w(v|<v7>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v8>
+6 -6
View File
@@ -1,10 +1,10 @@
fun box(): String {
val a1: Byte = 1.minus()
val a2: Short = 1.minus()
val a3: Int = 1.minus()
val a4: Long = 1.minus()
val a5: Double = 1.0.minus()
val a6: Float = 1f.minus()
val a1: Byte = 1.unaryMinus()
val a2: Short = 1.unaryMinus()
val a3: Int = 1.unaryMinus()
val a4: Long = 1.unaryMinus()
val a5: Double = 1.0.unaryMinus()
val a6: Float = 1f.unaryMinus()
if (a1 != (-1).toByte()) return "fail 1"
if (a2 != (-1).toShort()) return "fail -1"
+6 -6
View File
@@ -1,10 +1,10 @@
fun box(): String {
val a1: Byte? = 1.minus()
val a2: Short? = 1.minus()
val a3: Int? = 1.minus()
val a4: Long? = 1.minus()
val a5: Double? = 1.0.minus()
val a6: Float? = 1f.minus()
val a1: Byte? = 1.unaryMinus()
val a2: Short? = 1.unaryMinus()
val a3: Int? = 1.unaryMinus()
val a4: Long? = 1.unaryMinus()
val a5: Double? = 1.0.unaryMinus()
val a6: Float? = 1f.unaryMinus()
if (a1!! != (-1).toByte()) return "fail 1"
if (a2!! != (-1).toShort()) return "fail 2"
@@ -12,8 +12,8 @@ fun test(x : Int?, a : A?) {
x?.plus(1)
x <!UNSAFE_INFIX_CALL!>+<!> 1
<!UNSAFE_CALL!>-<!>x
x<!UNSAFE_CALL!>.<!>minus()
x?.minus()
x<!UNSAFE_CALL!>.<!>unaryMinus()
x?.unaryMinus()
a<!UNSAFE_CALL!>.<!>plus(1)
a?.plus(1)
@@ -40,10 +40,11 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
= hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(
unaryOperation(BOOLEAN, "not!", { a -> a.not() }, emptyUnaryFun),
unaryOperation(BYTE, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(BYTE, "minus", { a -> a.minus() }, { a -> a.minus() }),
unaryOperation(BYTE, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(BYTE, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(BYTE, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(BYTE, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(BYTE, "plus", { a -> a.plus() }, emptyUnaryFun),
unaryOperation(BYTE, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(BYTE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(BYTE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(BYTE, "toShort", { a -> a.toShort() }, emptyUnaryFun),
@@ -56,48 +57,48 @@ private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?,
unaryOperation(CHAR, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(CHAR, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(DOUBLE, "minus", { a -> a.minus() }, emptyUnaryFun),
unaryOperation(DOUBLE, "minus", { a -> a.unaryMinus() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(DOUBLE, "plus", { a -> a.plus() }, emptyUnaryFun),
unaryOperation(DOUBLE, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(FLOAT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(FLOAT, "minus", { a -> a.minus() }, emptyUnaryFun),
unaryOperation(FLOAT, "minus", { a -> a.unaryMinus() }, emptyUnaryFun),
unaryOperation(FLOAT, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(FLOAT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(FLOAT, "plus", { a -> a.plus() }, emptyUnaryFun),
unaryOperation(FLOAT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(FLOAT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(FLOAT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(FLOAT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(FLOAT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(INT, "plus", { a -> a.plus() }, emptyUnaryFun),
unaryOperation(INT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(INT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(INT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(INT, "inv", { a -> a.inv() }, emptyUnaryFun),
unaryOperation(INT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(INT, "minus", { a -> a.minus() }, { a -> a.minus() }),
unaryOperation(INT, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(INT, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(INT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(INT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(INT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(LONG, "plus", { a -> a.plus() }, emptyUnaryFun),
unaryOperation(LONG, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(LONG, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(LONG, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(LONG, "inv", { a -> a.inv() }, emptyUnaryFun),
unaryOperation(LONG, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(LONG, "minus", { a -> a.minus() }, { a -> a.minus() }),
unaryOperation(LONG, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(LONG, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(LONG, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(LONG, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(LONG, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(SHORT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(SHORT, "minus", { a -> a.minus() }, { a -> a.minus() }),
unaryOperation(SHORT, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(SHORT, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(SHORT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(SHORT, "plus", { a -> a.plus() }, emptyUnaryFun),
unaryOperation(SHORT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(SHORT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(SHORT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(SHORT, "toShort", { a -> a.toShort() }, emptyUnaryFun),