From d52f245cf7a4a18e81db807056e4f41242625bcb Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 12 Oct 2015 19:19:22 +0300 Subject: [PATCH] Rename unary plus/minus in builtins and stdlib --- build.xml | 6 + compiler/frontend/OperationsMapGenerated2.kt | 355 ++++++++++++++++++ .../evaluate/OperationsMapGenerated.kt | 12 - compiler/testData/builtin-classes.txt | 24 +- .../withPrimary.instructions | 2 +- .../secondaryConstructors/withPrimary.values | 2 +- .../withPrimarySuper.instructions | 2 +- .../withPrimarySuper.values | 2 +- .../withoutPrimary.instructions | 4 +- .../withoutPrimarySuper.instructions | 4 +- compiler/testData/codegen/box/unaryOp/call.kt | 12 +- .../codegen/box/unaryOp/callNullable.kt | 12 +- .../InfixCallNullability.kt | 4 +- .../pseudocodeMemoryOverhead.kt | 25 +- .../kotlin/codegen/PackageGenTest.java | 2 +- core/builtins/native/kotlin/Primitives.kt | 24 +- .../kotlin/generators/builtins/primitives.kt | 6 +- .../functionCallAfterInfixCall.kt | 2 +- .../functionCallAfterInfixCall.kt.after | 2 +- .../expressions/conventions/unaryMinus.kt | 2 +- .../conventions/unaryMinus.kt.match | 2 +- js/js.translator/testData/long.js | 4 +- libraries/stdlib/src/kotlin/math/JMath.kt | 4 +- 23 files changed, 432 insertions(+), 82 deletions(-) create mode 100644 compiler/frontend/OperationsMapGenerated2.kt diff --git a/build.xml b/build.xml index bcd3e07b179..3888820a494 100644 --- a/build.xml +++ b/build.xml @@ -159,6 +159,12 @@ + + + + diff --git a/compiler/frontend/OperationsMapGenerated2.kt b/compiler/frontend/OperationsMapGenerated2.kt new file mode 100644 index 00000000000..a12e33a12a0 --- /dev/null +++ b/compiler/frontend/OperationsMapGenerated2.kt @@ -0,0 +1,355 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.constants.evaluate + +import java.math.BigInteger +import java.util.HashMap + +/** This file is generated by org.jetbrains.kotlin.generators.evaluate:generate(). DO NOT MODIFY MANUALLY */ + +internal val emptyBinaryFun: Function2 = { a, b -> BigInteger("0") } +internal val emptyUnaryFun: Function1 = { a -> 1.toLong() } + +internal val unaryOperations: HashMap, Pair, Function1>> + = hashMapOf, Pair, Function1>>( + unaryOperation(BOOLEAN, "not", { a -> a.not() }, emptyUnaryFun), + unaryOperation(BOOLEAN, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(BYTE, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(BYTE, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(BYTE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(BYTE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(BYTE, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(BYTE, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(BYTE, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(BYTE, "unaryMinus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }), + unaryOperation(BYTE, "unaryPlus", { a -> a.unaryPlus() }, emptyUnaryFun), + unaryOperation(BYTE, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(CHAR, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(CHAR, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(CHAR, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(CHAR, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(CHAR, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(CHAR, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(CHAR, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(CHAR, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(DOUBLE, "unaryMinus", { a -> a.unaryMinus() }, emptyUnaryFun), + unaryOperation(DOUBLE, "unaryPlus", { a -> a.unaryPlus() }, emptyUnaryFun), + unaryOperation(DOUBLE, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(FLOAT, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(FLOAT, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(FLOAT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(FLOAT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(FLOAT, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(FLOAT, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(FLOAT, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(FLOAT, "unaryMinus", { a -> a.unaryMinus() }, emptyUnaryFun), + unaryOperation(FLOAT, "unaryPlus", { a -> a.unaryPlus() }, emptyUnaryFun), + unaryOperation(FLOAT, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(INT, "inv", { a -> a.inv() }, emptyUnaryFun), + unaryOperation(INT, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(INT, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(INT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(INT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(INT, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(INT, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(INT, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(INT, "unaryMinus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }), + unaryOperation(INT, "unaryPlus", { a -> a.unaryPlus() }, emptyUnaryFun), + unaryOperation(INT, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(LONG, "inv", { a -> a.inv() }, emptyUnaryFun), + unaryOperation(LONG, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(LONG, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(LONG, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(LONG, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(LONG, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(LONG, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(LONG, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(LONG, "unaryMinus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }), + unaryOperation(LONG, "unaryPlus", { a -> a.unaryPlus() }, emptyUnaryFun), + unaryOperation(LONG, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(SHORT, "toByte", { a -> a.toByte() }, emptyUnaryFun), + unaryOperation(SHORT, "toChar", { a -> a.toChar() }, emptyUnaryFun), + unaryOperation(SHORT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), + unaryOperation(SHORT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), + unaryOperation(SHORT, "toInt", { a -> a.toInt() }, emptyUnaryFun), + unaryOperation(SHORT, "toLong", { a -> a.toLong() }, emptyUnaryFun), + unaryOperation(SHORT, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(SHORT, "unaryMinus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }), + unaryOperation(SHORT, "unaryPlus", { a -> a.unaryPlus() }, emptyUnaryFun), + unaryOperation(SHORT, "toString", { a -> a.toString() }, emptyUnaryFun), + unaryOperation(STRING, "length", { a -> a.length() }, emptyUnaryFun), + unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun) +) + +internal val binaryOperations: HashMap, Pair, Function2>> + = hashMapOf, Pair, Function2>>( + binaryOperation(BOOLEAN, BOOLEAN, "and", { a, b -> a.and(b) }, emptyBinaryFun), + binaryOperation(BOOLEAN, BOOLEAN, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BOOLEAN, BOOLEAN, "or", { a, b -> a.or(b) }, emptyBinaryFun), + binaryOperation(BOOLEAN, BOOLEAN, "xor", { a, b -> a.xor(b) }, emptyBinaryFun), + binaryOperation(BOOLEAN, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(BYTE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BYTE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BYTE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BYTE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BYTE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BYTE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(BYTE, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(BYTE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(BYTE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(BYTE, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(BYTE, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(BYTE, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(BYTE, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(BYTE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(BYTE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(BYTE, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(BYTE, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(BYTE, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(BYTE, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(BYTE, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(BYTE, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(BYTE, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(BYTE, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(BYTE, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(BYTE, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(BYTE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(BYTE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(BYTE, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(BYTE, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(BYTE, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(BYTE, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(BYTE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(BYTE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(BYTE, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(BYTE, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(BYTE, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(BYTE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(CHAR, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(CHAR, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(CHAR, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(CHAR, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, LONG, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, SHORT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(DOUBLE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(FLOAT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(FLOAT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(FLOAT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(FLOAT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(FLOAT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(FLOAT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(FLOAT, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(FLOAT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(FLOAT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(FLOAT, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(FLOAT, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(FLOAT, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(FLOAT, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(FLOAT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(FLOAT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(FLOAT, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(FLOAT, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(FLOAT, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(FLOAT, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(FLOAT, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(FLOAT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(FLOAT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(FLOAT, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(FLOAT, LONG, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(FLOAT, SHORT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(FLOAT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "and", { a, b -> a.and(b) }, { a, b -> a.and(b) }), + binaryOperation(INT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(INT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(INT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(INT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(INT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(INT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(INT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(INT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(INT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(INT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(INT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(INT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(INT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(INT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(INT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(INT, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(INT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(INT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(INT, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(INT, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(INT, INT, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }), + binaryOperation(INT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(INT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(INT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(INT, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(INT, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(INT, INT, "shl", { a, b -> a.shl(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun), + binaryOperation(INT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(INT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(INT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(INT, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(INT, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(INT, INT, "ushr", { a, b -> a.ushr(b) }, emptyBinaryFun), + binaryOperation(INT, INT, "xor", { a, b -> a.xor(b) }, { a, b -> a.xor(b) }), + binaryOperation(INT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(LONG, LONG, "and", { a, b -> a.and(b) }, { a, b -> a.and(b) }), + binaryOperation(LONG, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(LONG, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(LONG, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(LONG, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(LONG, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(LONG, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(LONG, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(LONG, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(LONG, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(LONG, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(LONG, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(LONG, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(LONG, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(LONG, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(LONG, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(LONG, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(LONG, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(LONG, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(LONG, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(LONG, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(LONG, LONG, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }), + binaryOperation(LONG, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(LONG, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(LONG, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(LONG, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(LONG, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(LONG, INT, "shl", { a, b -> a.shl(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun), + binaryOperation(LONG, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(LONG, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(LONG, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(LONG, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(LONG, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(LONG, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(LONG, INT, "ushr", { a, b -> a.ushr(b) }, emptyBinaryFun), + binaryOperation(LONG, LONG, "xor", { a, b -> a.xor(b) }, { a, b -> a.xor(b) }), + binaryOperation(LONG, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(SHORT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(SHORT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(SHORT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(SHORT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(SHORT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(SHORT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(SHORT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(SHORT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(SHORT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), + binaryOperation(SHORT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(SHORT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(SHORT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), + binaryOperation(SHORT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(SHORT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(SHORT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(SHORT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(SHORT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(SHORT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), + binaryOperation(SHORT, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(SHORT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(SHORT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), + binaryOperation(SHORT, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(SHORT, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(SHORT, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), + binaryOperation(SHORT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(SHORT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(SHORT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(SHORT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(SHORT, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(SHORT, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), + binaryOperation(SHORT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(SHORT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(SHORT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), + binaryOperation(SHORT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(SHORT, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(SHORT, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), + binaryOperation(SHORT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), + binaryOperation(STRING, STRING, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), + binaryOperation(STRING, INT, "get", { a, b -> a.get(b) }, emptyBinaryFun), + binaryOperation(STRING, ANY, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(STRING, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun) +) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt index 35c7f7a0553..31bdf04c3dc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt @@ -28,8 +28,6 @@ internal val unaryOperations: HashMap, Pair, Pair, Function1>>( unaryOperation(BOOLEAN, "not", { a -> a.not() }, emptyUnaryFun), unaryOperation(BOOLEAN, "toString", { a -> a.toString() }, emptyUnaryFun), - unaryOperation(BYTE, "minus", { a -> a.minus() }, { a -> a.minus() }), - unaryOperation(BYTE, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(BYTE, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(BYTE, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(BYTE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), @@ -48,8 +46,6 @@ internal val unaryOperations: HashMap, Pair a.toLong() }, emptyUnaryFun), unaryOperation(CHAR, "toShort", { a -> a.toShort() }, emptyUnaryFun), unaryOperation(CHAR, "toString", { a -> a.toString() }, emptyUnaryFun), - unaryOperation(DOUBLE, "minus", { a -> a.minus() }, emptyUnaryFun), - unaryOperation(DOUBLE, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(DOUBLE, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(DOUBLE, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(DOUBLE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), @@ -60,8 +56,6 @@ internal val unaryOperations: HashMap, Pair a.minus() }, emptyUnaryFun), unaryOperation(DOUBLE, "unaryPlus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(DOUBLE, "toString", { a -> a.toString() }, emptyUnaryFun), - unaryOperation(FLOAT, "minus", { a -> a.minus() }, emptyUnaryFun), - unaryOperation(FLOAT, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(FLOAT, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(FLOAT, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(FLOAT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), @@ -73,8 +67,6 @@ internal val unaryOperations: HashMap, Pair a.plus() }, emptyUnaryFun), unaryOperation(FLOAT, "toString", { a -> a.toString() }, emptyUnaryFun), unaryOperation(INT, "inv", { a -> a.inv() }, emptyUnaryFun), - unaryOperation(INT, "minus", { a -> a.minus() }, { a -> a.minus() }), - unaryOperation(INT, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(INT, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(INT, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(INT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), @@ -86,8 +78,6 @@ internal val unaryOperations: HashMap, Pair a.plus() }, emptyUnaryFun), unaryOperation(INT, "toString", { a -> a.toString() }, emptyUnaryFun), unaryOperation(LONG, "inv", { a -> a.inv() }, emptyUnaryFun), - unaryOperation(LONG, "minus", { a -> a.minus() }, { a -> a.minus() }), - unaryOperation(LONG, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(LONG, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(LONG, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(LONG, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), @@ -98,8 +88,6 @@ internal val unaryOperations: HashMap, Pair a.minus() }, { a -> a.minus() }), unaryOperation(LONG, "unaryPlus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(LONG, "toString", { a -> a.toString() }, emptyUnaryFun), - unaryOperation(SHORT, "minus", { a -> a.minus() }, { a -> a.minus() }), - unaryOperation(SHORT, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(SHORT, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(SHORT, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(SHORT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index f239393f8e7..1a6a81ca57d 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -62,7 +62,6 @@ public final class Byte : kotlin.Number, kotlin.Comparable { 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 { 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 { 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 { /*primary*/ private constructor Companion() @@ -331,7 +331,6 @@ public final class Double : kotlin.Number, kotlin.Comparable { 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 { 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 { 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 { /*primary*/ private constructor Companion() @@ -481,7 +481,6 @@ public final class Float : kotlin.Number, kotlin.Comparable { 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 { 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 { 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 { /*primary*/ private constructor Companion() @@ -635,7 +635,6 @@ public final class Int : kotlin.Number, kotlin.Comparable { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { /*primary*/ private constructor Companion() diff --git a/compiler/testData/cfg/secondaryConstructors/withPrimary.instructions b/compiler/testData/cfg/secondaryConstructors/withPrimary.instructions index 33cd991f6e0..396e7644aaa 100644 --- a/compiler/testData/cfg/secondaryConstructors/withPrimary.instructions +++ b/compiler/testData/cfg/secondaryConstructors/withPrimary.instructions @@ -36,7 +36,7 @@ L0: v(val v = -1) r(1) -> mark(-1) - call(-1, minus|) -> + call(-1, unaryMinus|) -> w(v|) 2 mark({ x = w z = 8 }) magic[IMPLICIT_RECEIVER](x) -> diff --git a/compiler/testData/cfg/secondaryConstructors/withPrimary.values b/compiler/testData/cfg/secondaryConstructors/withPrimary.values index 0fe11b3c296..e0cb8195057 100644 --- a/compiler/testData/cfg/secondaryConstructors/withPrimary.values +++ b/compiler/testData/cfg/secondaryConstructors/withPrimary.values @@ -31,7 +31,7 @@ class A(val w: Char) { : A NEW: magic[IMPLICIT_RECEIVER](z) -> : A NEW: magic[IMPLICIT_RECEIVER](y) -> 1 : Int NEW: r(1) -> --1 : Int NEW: call(-1, minus|) -> +-1 : Int NEW: call(-1, unaryMinus|) -> w : Int NEW: r(w|) -> 8 : Int NEW: r(8) -> z = 8 !: * diff --git a/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.instructions b/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.instructions index d19eb0427e2..d28de2deb2e 100644 --- a/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.instructions +++ b/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.instructions @@ -67,7 +67,7 @@ L2 [after default value for parameter u]: v(val v = -1) r(1) -> mark(-1) - call(-1, minus|) -> + call(-1, unaryMinus|) -> w(v|) 2 mark({ x = w z = 8 }) magic[IMPLICIT_RECEIVER](x) -> diff --git a/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.values b/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.values index 77961873b77..9e0eaedbbbc 100644 --- a/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.values +++ b/compiler/testData/cfg/secondaryConstructors/withPrimarySuper.values @@ -45,7 +45,7 @@ u : Int NEW: r(u) -> w.toInt() + u : Int NEW: call(w.toInt() + u, plus|, ) -> B(w.toInt() + u) : * NEW: call(B(w.toInt() + u), |) -> 1 : Int NEW: r(1) -> --1 : Int NEW: call(-1, minus|) -> +-1 : Int NEW: call(-1, unaryMinus|) -> w : Int NEW: r(w|) -> 8 : Int NEW: r(8) -> z = 8 !: * diff --git a/compiler/testData/cfg/secondaryConstructors/withoutPrimary.instructions b/compiler/testData/cfg/secondaryConstructors/withoutPrimary.instructions index 34952b735e5..c98fc56bda0 100644 --- a/compiler/testData/cfg/secondaryConstructors/withoutPrimary.instructions +++ b/compiler/testData/cfg/secondaryConstructors/withoutPrimary.instructions @@ -57,7 +57,7 @@ L0: v(val v = -1) r(1) -> mark(-1) - call(-1, minus|) -> + call(-1, unaryMinus|) -> w(v|) 2 mark({ z = 8 }) magic[IMPLICIT_RECEIVER](z) -> @@ -107,7 +107,7 @@ L2 [after default value for parameter b]: v(val v = -1) r(1) -> mark(-1) - call(-1, minus|) -> + call(-1, unaryMinus|) -> w(v|) 2 mark({ z = 8 }) magic[IMPLICIT_RECEIVER](z) -> diff --git a/compiler/testData/cfg/secondaryConstructors/withoutPrimarySuper.instructions b/compiler/testData/cfg/secondaryConstructors/withoutPrimarySuper.instructions index 33d6296949c..66327c42330 100644 --- a/compiler/testData/cfg/secondaryConstructors/withoutPrimarySuper.instructions +++ b/compiler/testData/cfg/secondaryConstructors/withoutPrimarySuper.instructions @@ -73,7 +73,7 @@ L0: v(val v = -1) r(1) -> mark(-1) - call(-1, minus|) -> + call(-1, unaryMinus|) -> w(v|) 2 mark({ z = 8 }) magic[IMPLICIT_RECEIVER](z) -> @@ -124,7 +124,7 @@ L2 [after default value for parameter b]: v(val v = -1) r(1) -> mark(-1) - call(-1, minus|) -> + call(-1, unaryMinus|) -> w(v|) 2 mark({ z = 8 }) magic[IMPLICIT_RECEIVER](z) -> diff --git a/compiler/testData/codegen/box/unaryOp/call.kt b/compiler/testData/codegen/box/unaryOp/call.kt index 9b354aea3f2..fe138509d88 100644 --- a/compiler/testData/codegen/box/unaryOp/call.kt +++ b/compiler/testData/codegen/box/unaryOp/call.kt @@ -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" diff --git a/compiler/testData/codegen/box/unaryOp/callNullable.kt b/compiler/testData/codegen/box/unaryOp/callNullable.kt index 95bbd208ebf..f3ff7db949a 100644 --- a/compiler/testData/codegen/box/unaryOp/callNullable.kt +++ b/compiler/testData/codegen/box/unaryOp/callNullable.kt @@ -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" diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt index fec32c10412..5f537ad1c2c 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/InfixCallNullability.kt @@ -12,8 +12,8 @@ fun test(x : Int?, a : A?) { x?.plus(1) x + 1 -x - x.minus() - x?.minus() + x.unaryMinus() + x?.unaryMinus() a.plus(1) a?.plus(1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt index f6cf29b6555..45f0b25965e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt @@ -40,10 +40,11 @@ private val unaryOperations: HashMap, Pair, Pair, Function1>>( 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, Pair 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), diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/PackageGenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/PackageGenTest.java index 2841602975e..1a593e1ac72 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/PackageGenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/PackageGenTest.java @@ -432,7 +432,7 @@ public class PackageGenTest extends CodegenTestCase { } public void testExplicitCallOfUnaryMinusIntrinsic() throws Exception { - loadText("fun foo(a: Int) = a.minus()"); + loadText("fun foo(a: Int) = a.unaryMinus()"); Method main = generateFunction(); assertEquals(-1, ((Integer) main.invoke(null, 1)).intValue()); } diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index ececdf90ec8..f66db75e670 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -132,9 +132,9 @@ public class Byte private () : Number, Comparable { /** Decrements this value. */ public operator fun dec(): Byte /** Returns this value. */ - public operator fun plus(): Int + public operator fun unaryPlus(): Int /** Returns the negative of this value. */ - public operator fun minus(): Int + public operator fun unaryMinus(): Int /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): ByteRange @@ -272,9 +272,9 @@ public class Short private () : Number, Comparable { /** Decrements this value. */ public operator fun dec(): Short /** Returns this value. */ - public operator fun plus(): Int + public operator fun unaryPlus(): Int /** Returns the negative of this value. */ - public operator fun minus(): Int + public operator fun unaryMinus(): Int /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): ShortRange @@ -412,9 +412,9 @@ public class Int private () : Number, Comparable { /** Decrements this value. */ public operator fun dec(): Int /** Returns this value. */ - public operator fun plus(): Int + public operator fun unaryPlus(): Int /** Returns the negative of this value. */ - public operator fun minus(): Int + public operator fun unaryMinus(): Int /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): IntRange @@ -567,9 +567,9 @@ public class Long private () : Number, Comparable { /** Decrements this value. */ public operator fun dec(): Long /** Returns this value. */ - public operator fun plus(): Long + public operator fun unaryPlus(): Long /** Returns the negative of this value. */ - public operator fun minus(): Long + public operator fun unaryMinus(): Long /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): LongRange @@ -722,9 +722,9 @@ public class Float private () : Number, Comparable { /** Decrements this value. */ public operator fun dec(): Float /** Returns this value. */ - public operator fun plus(): Float + public operator fun unaryPlus(): Float /** Returns the negative of this value. */ - public operator fun minus(): Float + public operator fun unaryMinus(): Float /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): FloatRange @@ -862,9 +862,9 @@ public class Double private () : Number, Comparable { /** Decrements this value. */ public operator fun dec(): Double /** Returns this value. */ - public operator fun plus(): Double + public operator fun unaryPlus(): Double /** Returns the negative of this value. */ - public operator fun minus(): Double + public operator fun unaryMinus(): Double /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): DoubleRange diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt index 7e86902a42c..80eb6851cf1 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt @@ -31,8 +31,8 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { private val unaryOperators: Map = mapOf( "inc" to "Increments this value.", "dec" to "Decrements this value.", - "plus" to "Returns this value.", - "minus" to "Returns the negative of this value.") + "unaryPlus" to "Returns this value.", + "unaryMinus" to "Returns the negative of this value.") private val shiftOperators: Map = mapOf( "shl" to "Shifts this value left by [bits].", "shr" to "Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit.", @@ -131,7 +131,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { private fun generateUnaryOperators(kind: PrimitiveType) { for ((name, doc) in unaryOperators) { val returnType = if (kind in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) && - name in listOf("plus", "minus")) "Int" else kind.capitalized + name in listOf("unaryPlus", "unaryMinus")) "Int" else kind.capitalized out.println(" /** $doc */") out.println(" public operator fun $name(): $returnType") } diff --git a/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt b/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt index 3bc06bf0f64..0e6e00bc3b1 100644 --- a/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt +++ b/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt @@ -1,3 +1,3 @@ fun foo(x: Int) { - (x shl 1).minus() + (x shl 1).unaryMinus() } diff --git a/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt.after b/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt.after index 9ae9abf5207..509eb411e64 100644 --- a/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt.after +++ b/idea/testData/intentions/infixCallToOrdinary/functionCallAfterInfixCall.kt.after @@ -1,3 +1,3 @@ fun foo(x: Int) { - (x.shl(1)).minus() + (x.shl(1)).unaryMinus() } diff --git a/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt b/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt index aaa59248e06..9f03cb55900 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt +++ b/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt @@ -1,4 +1,4 @@ fun foo() { -1 - 1.minus() + 1.unaryMinus() } \ No newline at end of file diff --git a/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt.match b/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt.match index 1182c71c87f..c9b9d76f802 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt.match +++ b/idea/testData/unifier/equivalence/expressions/conventions/unaryMinus.kt.match @@ -1,3 +1,3 @@ -1 -1.minus() \ No newline at end of file +1.unaryMinus() \ No newline at end of file diff --git a/js/js.translator/testData/long.js b/js/js.translator/testData/long.js index b95cdf75aa3..391e5e797a9 100644 --- a/js/js.translator/testData/long.js +++ b/js/js.translator/testData/long.js @@ -827,11 +827,11 @@ return this.toNumber(); }; - Kotlin.Long.prototype.plus = function() { + Kotlin.Long.prototype.unaryPlus = function() { return this; }; - Kotlin.Long.prototype.minus = Kotlin.Long.prototype.negate; + Kotlin.Long.prototype.unaryMinus = Kotlin.Long.prototype.negate; Kotlin.Long.prototype.inv = Kotlin.Long.prototype.not; Kotlin.Long.prototype.rangeTo = function (other) { diff --git a/libraries/stdlib/src/kotlin/math/JMath.kt b/libraries/stdlib/src/kotlin/math/JMath.kt index 3a58c011587..2991a67cafe 100644 --- a/libraries/stdlib/src/kotlin/math/JMath.kt +++ b/libraries/stdlib/src/kotlin/math/JMath.kt @@ -29,7 +29,7 @@ public operator fun BigInteger.div(other: BigInteger) : BigInteger = this.divide /** * Enables the use of the unary `-` operator for [BigInteger] instances. */ -public operator fun BigInteger.minus() : BigInteger = this.negate() +public operator fun BigInteger.unaryMinus() : BigInteger = this.negate() /** @@ -60,4 +60,4 @@ public operator fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remain /** * Enables the use of the unary `-` operator for [BigDecimal] instances. */ -public operator fun BigDecimal.minus() : BigDecimal = this.negate() +public operator fun BigDecimal.unaryMinus() : BigDecimal = this.negate()