diff --git a/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt b/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt index cbcd6a7ff82..d2e711545e4 100644 --- a/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt +++ b/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt @@ -484,7 +484,7 @@ public final class Double : R|kotlin/Number|, R|kotlin/Comparable public final operator fun times(other: R|kotlin/Short|): R|kotlin/Double| - @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toByte())) ) public open fun toByte(): R|kotlin/Byte| + @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toByte())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.3), errorSince = String(1.5)) public open fun toByte(): R|kotlin/Byte| public open fun toChar(): R|kotlin/Char| @@ -496,7 +496,7 @@ public final class Double : R|kotlin/Number|, R|kotlin/Comparable public open fun toLong(): R|kotlin/Long| - @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toShort())) ) public open fun toShort(): R|kotlin/Short| + @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toShort())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.3), errorSince = String(1.5)) public open fun toShort(): R|kotlin/Short| public final operator fun unaryMinus(): R|kotlin/Double| @@ -663,7 +663,7 @@ public final class Float : R|kotlin/Number|, R|kotlin/Comparable|, public final operator fun times(other: R|kotlin/Short|): R|kotlin/Float| - @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toByte())) ) public open fun toByte(): R|kotlin/Byte| + @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toByte())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.3), errorSince = String(1.5)) public open fun toByte(): R|kotlin/Byte| public open fun toChar(): R|kotlin/Char| @@ -675,7 +675,7 @@ public final class Float : R|kotlin/Number|, R|kotlin/Comparable|, public open fun toLong(): R|kotlin/Long| - @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toShort())) ) public open fun toShort(): R|kotlin/Short| + @R|kotlin/Deprecated|(message = String(Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(toInt().toShort())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.3), errorSince = String(1.5)) public open fun toShort(): R|kotlin/Short| public final operator fun unaryMinus(): R|kotlin/Float| diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/builtins/IrBuiltInsMapGenerated.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/builtins/IrBuiltInsMapGenerated.kt index f38c18ee239..d76c697fb05 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/builtins/IrBuiltInsMapGenerated.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/builtins/IrBuiltInsMapGenerated.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.ir.interpreter.state.* /** This file is generated by org.jetbrains.kotlin.backend.common.interpreter.builtins.GenerateBuiltInsMap.generateMap(). DO NOT MODIFY MANUALLY */ -@Suppress("DEPRECATION") +@Suppress("DEPRECATION_ERROR") val unaryFunctions = mapOf>( unaryOperation("hashCode", "Boolean") { a -> a.hashCode() }, unaryOperation("not", "Boolean") { a -> a.not() }, diff --git a/compiler/testData/builtin-classes/default/kotlin.txt b/compiler/testData/builtin-classes/default/kotlin.txt index b5656c1e7f5..b0856a41990 100644 --- a/compiler/testData/builtin-classes/default/kotlin.txt +++ b/compiler/testData/builtin-classes/default/kotlin.txt @@ -275,13 +275,13 @@ public final class Double : kotlin.Number, kotlin.Comparable { public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Double - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Double public final operator fun unaryPlus(): kotlin.Double @@ -376,13 +376,13 @@ public final class Float : kotlin.Number, kotlin.Comparable { public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Float - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Float public final operator fun unaryPlus(): kotlin.Float diff --git a/compiler/testData/builtin-classes/java6/kotlin.txt b/compiler/testData/builtin-classes/java6/kotlin.txt index 6e3c155d8c9..83757d3e052 100644 --- a/compiler/testData/builtin-classes/java6/kotlin.txt +++ b/compiler/testData/builtin-classes/java6/kotlin.txt @@ -285,13 +285,13 @@ public final class Double : kotlin.Number, kotlin.Comparable, jav public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Double - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Double public final operator fun unaryPlus(): kotlin.Double @@ -389,13 +389,13 @@ public final class Float : kotlin.Number, kotlin.Comparable, java. public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Float - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Float public final operator fun unaryPlus(): kotlin.Float diff --git a/compiler/testData/builtin-classes/java8/kotlin.txt b/compiler/testData/builtin-classes/java8/kotlin.txt index a39f9579457..20cec0281ad 100644 --- a/compiler/testData/builtin-classes/java8/kotlin.txt +++ b/compiler/testData/builtin-classes/java8/kotlin.txt @@ -287,13 +287,13 @@ public final class Double : kotlin.Number, kotlin.Comparable, jav public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Double - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Double public final operator fun unaryPlus(): kotlin.Double @@ -391,13 +391,13 @@ public final class Float : kotlin.Number, kotlin.Comparable, java. public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Float - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Float public final operator fun unaryPlus(): kotlin.Float diff --git a/compiler/testData/builtin-classes/newMethods/kotlin.txt b/compiler/testData/builtin-classes/newMethods/kotlin.txt index d8ff2fbb48f..1b632d7501b 100644 --- a/compiler/testData/builtin-classes/newMethods/kotlin.txt +++ b/compiler/testData/builtin-classes/newMethods/kotlin.txt @@ -285,13 +285,13 @@ public final class Double : kotlin.Number, kotlin.Comparable, jav public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Double - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Double public final operator fun unaryPlus(): kotlin.Double @@ -389,13 +389,13 @@ public final class Float : kotlin.Number, kotlin.Comparable, java. public final operator fun times(/*0*/ other: kotlin.Int): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Float - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) public open override /*1*/ fun toByte(): kotlin.Byte + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toByte(): kotlin.Byte public open override /*1*/ fun toChar(): kotlin.Char public open override /*1*/ fun toDouble(): kotlin.Double public open override /*1*/ fun toFloat(): kotlin.Float public open override /*1*/ fun toInt(): kotlin.Int public open override /*1*/ fun toLong(): kotlin.Long - @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) public open override /*1*/ fun toShort(): kotlin.Short + @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override /*1*/ fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Float public final operator fun unaryPlus(): kotlin.Float diff --git a/compiler/testData/codegen/box/boxingOptimization/casts.kt b/compiler/testData/codegen/box/boxingOptimization/casts.kt index 47ce676892b..94792825a14 100644 --- a/compiler/testData/codegen/box/boxingOptimization/casts.kt +++ b/compiler/testData/codegen/box/boxingOptimization/casts.kt @@ -12,7 +12,7 @@ fun box() : String { assertEquals(1.toByte(), foo(1L) { x -> x!!.toByte() }) assertEquals(1.toShort(), foo(1L) { x -> x!!.toShort() }) assertEquals('a'.toDouble(), foo('a') { x -> x!!.toDouble() }) - assertEquals(1.0.toByte(), foo(1.0) { x -> x!!.toByte() }) + assertEquals(1.0.toInt(), foo(1.0) { x -> x!!.toInt() }) return "OK" } diff --git a/compiler/testData/codegen/box/primitiveTypes/conversions.kt b/compiler/testData/codegen/box/primitiveTypes/conversions.kt index a8521d51a0a..99bbf1b78e8 100644 --- a/compiler/testData/codegen/box/primitiveTypes/conversions.kt +++ b/compiler/testData/codegen/box/primitiveTypes/conversions.kt @@ -42,13 +42,9 @@ fun box(): String { 65534.0, 65535.0, 65536.0, 2147483647.0, 2147483648.0, 2147483649.0, Double.MAX_VALUE, Double.POSITIVE_INFINITY)) { - assertEquals(d.toInt().toByte(), d.toByte()) - assertEquals(d.toInt().toShort(), d.toShort()) assertEquals(d.toInt().toChar(), d.toChar()) val f = d.toFloat() - assertEquals(f.toInt().toByte(), f.toByte()) - assertEquals(f.toInt().toShort(), f.toShort()) assertEquals(f.toInt().toChar(), f.toChar()) } diff --git a/compiler/testData/codegen/bytecodeText/boxingOptimization/casts.kt b/compiler/testData/codegen/bytecodeText/boxingOptimization/casts.kt index ca0d25fa198..35ebf26ebf3 100644 --- a/compiler/testData/codegen/bytecodeText/boxingOptimization/casts.kt +++ b/compiler/testData/codegen/bytecodeText/boxingOptimization/casts.kt @@ -9,7 +9,7 @@ fun bar() { foo(1L) { x -> x!!.toByte() } foo(1L) { x -> x!!.toShort() } foo('a') { x -> x!!.toDouble() } - foo(1.0) { x -> x!!.toByte() } + foo(1.0) { x -> x!!.toInt() } } // 0 valueOf @@ -17,6 +17,6 @@ fun bar() { // 1 I2L // 2 L2I // 2 I2S -// 2 I2B +// 1 I2B // 1 I2D // 1 D2I diff --git a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt index 4dc282d2968..a50f401fa3a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt @@ -63,8 +63,8 @@ private val unaryOperations: HashMap, Pair 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(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.unaryMinus() }, emptyUnaryFun), unaryOperation(FLOAT, "toChar", { a -> a.toChar() }, emptyUnaryFun), @@ -72,8 +72,8 @@ private val unaryOperations: HashMap, Pair 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(FLOAT, "toShort", { a -> a.toShort() }, emptyUnaryFun), + unaryOperation(FLOAT, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(INT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun), unaryOperation(INT, "toShort", { a -> a.toShort() }, emptyUnaryFun), unaryOperation(INT, "toByte", { a -> a.toByte() }, emptyUnaryFun), diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index f02e102e67f..0c3b456604a 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -1218,6 +1218,7 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Byte` value is equal to `this.toInt().toByte()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", ReplaceWith("toInt().toByte()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toByte(): Byte /** * Converts this [Float] value to [Char]. @@ -1231,6 +1232,7 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Short` value is equal to `this.toInt().toShort()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", ReplaceWith("toInt().toShort()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toShort(): Short /** * Converts this [Float] value to [Int]. @@ -1455,6 +1457,7 @@ public class Double private constructor() : Number(), Comparable { * The resulting `Byte` value is equal to `this.toInt().toByte()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", ReplaceWith("toInt().toByte()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toByte(): Byte /** * Converts this [Double] value to [Char]. @@ -1468,6 +1471,7 @@ public class Double private constructor() : Number(), Comparable { * The resulting `Short` value is equal to `this.toInt().toShort()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", ReplaceWith("toInt().toShort()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toShort(): Short /** * Converts this [Double] value to [Int]. diff --git a/generators/builtins/primitives.kt b/generators/builtins/primitives.kt index b7cb54be412..2fc5a0fa4b8 100644 --- a/generators/builtins/primitives.kt +++ b/generators/builtins/primitives.kt @@ -424,6 +424,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { if (isConversionDeprecated(otherKind)) { out.println(" @Deprecated(\"Unclear conversion. To achieve the same result convert to Int explicitly and then to $otherName.\", ReplaceWith(\"toInt().to$otherName()\"))") + out.println(" @DeprecatedSinceKotlin(warningSince = \"1.3\", errorSince = \"1.5\")") } out.println(" public override fun to$otherName(): $otherName") diff --git a/generators/interpreter/GenerateInterpreterMap.kt b/generators/interpreter/GenerateInterpreterMap.kt index 97c4598c54f..87bdd6474f6 100644 --- a/generators/interpreter/GenerateInterpreterMap.kt +++ b/generators/interpreter/GenerateInterpreterMap.kt @@ -52,7 +52,7 @@ fun generateMap(): String { val binaryIrOperationsMap = getBinaryIrOperationMap(irBuiltIns) - p.println("@Suppress(\"DEPRECATION\")") + p.println("@Suppress(\"DEPRECATION_ERROR\")") p.println("val unaryFunctions = mapOf>(") p.println(generateUnaryBody(unaryOperationsMap, irBuiltIns)) p.println(")") diff --git a/j2k/testData/fileOrElement/methodCallExpression/specialBuiltinMembers.kt b/j2k/testData/fileOrElement/methodCallExpression/specialBuiltinMembers.kt index bf613ab46c1..0e6dd509b45 100644 --- a/j2k/testData/fileOrElement/methodCallExpression/specialBuiltinMembers.kt +++ b/j2k/testData/fileOrElement/methodCallExpression/specialBuiltinMembers.kt @@ -22,7 +22,7 @@ internal class A { val i = 10.1.toInt() val f = 10.1.toFloat() val l = 10.1.toLong() - val s = 10.1.toShort() + val s = 10.1.toInt().toShort() try { val removed = list.removeAt(10) diff --git a/js/js.translator/testData/box/expression/equals/explicitEqualsMethodForPrimitives.kt b/js/js.translator/testData/box/expression/equals/explicitEqualsMethodForPrimitives.kt index e4c89a2d138..98e49e53c91 100644 --- a/js/js.translator/testData/box/expression/equals/explicitEqualsMethodForPrimitives.kt +++ b/js/js.translator/testData/box/expression/equals/explicitEqualsMethodForPrimitives.kt @@ -10,8 +10,8 @@ fun box(): String { if (!("a".equals(c))) return "fail4" if (!((null as Any?)?.equals(null) ?: true)) return "fail5" val d = 5.6 - if (!(d.toShort().equals(5.toShort()))) return "fail6" - if (!(d.toByte().equals(5.toByte()))) return "fail7" + if (!(d.toInt().toShort().equals(5.toShort()))) return "fail6" + if (!(d.toInt().toByte().equals(5.toByte()))) return "fail7" if (!(d.toFloat().equals(5.6.toFloat()))) return "fail8" if (!(d.toInt().equals(5))) return "fail9" if (true.equals(false)) return "fail10" diff --git a/js/js.translator/testData/box/number/conversionsWithTruncation.kt b/js/js.translator/testData/box/number/conversionsWithTruncation.kt index 0f0e4b75f3b..362d567bbb7 100644 --- a/js/js.translator/testData/box/number/conversionsWithTruncation.kt +++ b/js/js.translator/testData/box/number/conversionsWithTruncation.kt @@ -3,12 +3,6 @@ package foo fun box(): String { - assertEquals(65, 321.0.toByte()) - assertEquals(-56, 200.0.toByte()) - - assertEquals(65, 321.0f.toByte()) - assertEquals(-56, 200.0f.toByte()) - assertEquals(65, 321L.toByte()) assertEquals(-56, 200L.toByte()) @@ -18,15 +12,11 @@ fun box(): String { assertEquals(65, (321.toShort()).toByte()) assertEquals(-56, (200.toShort()).toByte()) - assertEquals(-1, 65535.0.toShort()) - assertEquals(-1, 65535.0f.toShort()) assertEquals(-1, 65535L.toShort()) assertEquals(-1, 65535.toShort()) assertEquals(65535, 65535.2.toInt()) assertEquals(23, 23.6f.toInt()) - assertEquals(-12, -12.4.toShort()) - assertEquals(-12, -12.4.toByte()) assertEquals('\u0419', (-654311).toChar()) assertEquals('\u0419', (-654311.0).toChar()) diff --git a/js/js.translator/testData/box/number/conversionsWithoutTruncation.kt b/js/js.translator/testData/box/number/conversionsWithoutTruncation.kt index 8e20fed55b2..115f42729dd 100644 --- a/js/js.translator/testData/box/number/conversionsWithoutTruncation.kt +++ b/js/js.translator/testData/box/number/conversionsWithoutTruncation.kt @@ -25,8 +25,6 @@ fun box(): String { assertEquals(true, 65.0f == doubleX.toFloat()) assertEquals(true, 65L == doubleX.toLong()) assertEquals(true, 65 == doubleX.toInt()) - assertEquals(true, 65.toShort() == doubleX.toShort()) - assertEquals(true, 65.toByte() == doubleX.toByte()) assertEquals(true, 'A' == doubleX.toChar()) var floatX: Float = 65.0f @@ -34,8 +32,6 @@ fun box(): String { assertEquals(true, 65.0f == floatX.toFloat()) assertEquals(true, 65L == floatX.toLong()) assertEquals(true, 65 == floatX.toInt()) - assertEquals(true, 65.toShort() == floatX.toShort()) - assertEquals(true, 65.toByte() == floatX.toByte()) assertEquals(true, 'A' == floatX.toChar()) val longX: Long = 65L diff --git a/js/js.translator/testData/box/number/doubleConversions.kt b/js/js.translator/testData/box/number/doubleConversions.kt index 849171497e5..cd3d2463a9e 100644 --- a/js/js.translator/testData/box/number/doubleConversions.kt +++ b/js/js.translator/testData/box/number/doubleConversions.kt @@ -9,15 +9,9 @@ fun box(): String { if (c.toFloat() != 3.6.toFloat()) { return "fail2" } - if (c.toByte() != 3.toByte()) { - return "fail3" - } if (c.toInt() != 3) { return "fail4" } - if (c.toShort() != 3.toShort()) { - return "fail5" - } val cn: Double = -3.6 if (cn.toDouble() != -3.6) { @@ -26,15 +20,9 @@ fun box(): String { if (cn.toFloat() != -3.6.toFloat()) { return "fail7" } - if (cn.toByte() != (-3).toByte()) { - return "fail8" - } if (cn.toInt() != -3) { return "fail9" } - if (cn.toShort() != (-3).toShort()) { - return "fail10" - } val f: Float = 3.6.toFloat() if (f.toDouble() != 3.6) { @@ -43,15 +31,9 @@ fun box(): String { if (f.toFloat() != 3.6.toFloat()) { return "fail12" } - if (f.toByte() != 3.toByte()) { - return "fail13" - } if (f.toInt() != 3) { return "fail14" } - if (f.toShort() != 3.toShort()) { - return "fail15" - } val fn: Float = -3.6.toFloat() if (fn.toDouble() != -3.6) { @@ -60,15 +42,9 @@ fun box(): String { if (fn.toFloat() != -3.6.toFloat()) { return "fail17" } - if (fn.toByte() != (-3).toByte()) { - return "fail18" - } if (fn.toInt() != -3) { return "fail19" } - if (fn.toShort() != (-3).toShort()) { - return "fail20" - } return "OK" } \ No newline at end of file diff --git a/libraries/stdlib/api/js-v1/kotlin.kt b/libraries/stdlib/api/js-v1/kotlin.kt index 3585715d46b..b72fda66558 100644 --- a/libraries/stdlib/api/js-v1/kotlin.kt +++ b/libraries/stdlib/api/js-v1/kotlin.kt @@ -1312,6 +1312,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { public final operator fun times(other: kotlin.Short): kotlin.Double @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toByte(): kotlin.Byte public open override fun toChar(): kotlin.Char @@ -1325,6 +1326,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { public open override fun toLong(): kotlin.Long @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Double @@ -1547,6 +1549,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { public final operator fun times(other: kotlin.Short): kotlin.Float @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toByte(): kotlin.Byte public open override fun toChar(): kotlin.Char @@ -1560,6 +1563,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { public open override fun toLong(): kotlin.Long @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toShort(): kotlin.Short public final operator fun unaryMinus(): kotlin.Float diff --git a/libraries/stdlib/api/js/kotlin.kt b/libraries/stdlib/api/js/kotlin.kt index 97e2fbe1b8d..cdff15dd001 100644 --- a/libraries/stdlib/api/js/kotlin.kt +++ b/libraries/stdlib/api/js/kotlin.kt @@ -1287,6 +1287,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { public final operator fun times(other: kotlin.Short): kotlin.Double @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toByte(): kotlin.Byte public open override fun toChar(): kotlin.Char @@ -1300,6 +1301,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { public open override fun toLong(): kotlin.Long @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toShort(): kotlin.Short /*∆*/ public open override fun toString(): kotlin.String @@ -1526,6 +1528,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { public final operator fun times(other: kotlin.Short): kotlin.Float @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toByte()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toByte(): kotlin.Byte public open override fun toChar(): kotlin.Char @@ -1539,6 +1542,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { public open override fun toLong(): kotlin.Long @kotlin.Deprecated(message = "Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", replaceWith = kotlin.ReplaceWith(expression = "toInt().toShort()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") public open override fun toShort(): kotlin.Short /*∆*/ public open override fun toString(): kotlin.String diff --git a/libraries/stdlib/js-ir/builtins/Primitives.kt b/libraries/stdlib/js-ir/builtins/Primitives.kt index 8a193c07c8a..d8225b60eda 100644 --- a/libraries/stdlib/js-ir/builtins/Primitives.kt +++ b/libraries/stdlib/js-ir/builtins/Primitives.kt @@ -959,6 +959,7 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Byte` value is equal to `this.toInt().toByte()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", ReplaceWith("toInt().toByte()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toByte(): Byte /** * Converts this [Float] value to [Char]. @@ -972,6 +973,7 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Short` value is equal to `this.toInt().toShort()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", ReplaceWith("toInt().toShort()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toShort(): Short /** * Converts this [Float] value to [Int]. @@ -1201,6 +1203,7 @@ public class Double private constructor() : Number(), Comparable { * The resulting `Byte` value is equal to `this.toInt().toByte()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte.", ReplaceWith("toInt().toByte()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toByte(): Byte /** * Converts this [Double] value to [Char]. @@ -1214,6 +1217,7 @@ public class Double private constructor() : Number(), Comparable { * The resulting `Short` value is equal to `this.toInt().toShort()`. */ @Deprecated("Unclear conversion. To achieve the same result convert to Int explicitly and then to Short.", ReplaceWith("toInt().toShort()")) + @DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5") public override fun toShort(): Short /** * Converts this [Double] value to [Int]. diff --git a/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/BoxedTypeOperationsConversion.kt b/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/BoxedTypeOperationsConversion.kt index c006b2c9851..1900e769c0d 100644 --- a/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/BoxedTypeOperationsConversion.kt +++ b/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/BoxedTypeOperationsConversion.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.nj2k.conversions import org.jetbrains.kotlin.nj2k.NewJ2kConverterContext import org.jetbrains.kotlin.nj2k.tree.* import org.jetbrains.kotlin.nj2k.types.primitiveTypes +import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType import java.util.* class BoxedTypeOperationsConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) { @@ -38,9 +39,15 @@ class BoxedTypeOperationsConversion(context: NewJ2kConverterContext) : Recursive } ?: return null val primitiveTypeName = boxedTypeToPrimitiveType[boxedJavaType] ?: return null if (operationType !in primitiveTypeNames) return null + + val shouldConvertToIntFirst = + primitiveTypeName in floatingPointPrimitiveTypeNames && operationType in typeNameOfIntegersLesserThanInt + + val conversionType = if (shouldConvertToIntFirst) "Int" else operationType.capitalize(Locale.US) + return JKCallExpressionImpl( symbolProvider.provideMethodSymbol( - "kotlin.${primitiveTypeName.capitalize(Locale.US)}.to${operationType.capitalize(Locale.US)}" + "kotlin.${primitiveTypeName.capitalize(Locale.US)}.to$conversionType" ), JKArgumentList() ).withFormattingFrom(methodCallExpression) @@ -58,5 +65,11 @@ class BoxedTypeOperationsConversion(context: NewJ2kConverterContext) : Recursive private val primitiveTypeUnwrapRegexp = """([\w.]+)\.(\w+)Value""".toRegex() + + private val floatingPointPrimitiveTypeNames = + listOf(JvmPrimitiveType.DOUBLE.javaKeywordName, JvmPrimitiveType.FLOAT.javaKeywordName) + + private val typeNameOfIntegersLesserThanInt = + listOf(JvmPrimitiveType.SHORT.javaKeywordName, JvmPrimitiveType.BYTE.javaKeywordName) } } diff --git a/nj2k/testData/newJ2k/methodCallExpression/specialBuiltinMembers.kt b/nj2k/testData/newJ2k/methodCallExpression/specialBuiltinMembers.kt index 1492dfff164..9340946b306 100644 --- a/nj2k/testData/newJ2k/methodCallExpression/specialBuiltinMembers.kt +++ b/nj2k/testData/newJ2k/methodCallExpression/specialBuiltinMembers.kt @@ -23,7 +23,7 @@ internal class A { val i = 10.1.toInt() val f = 10.1.toFloat() val l = 10.1.toLong() - val s = 10.1.toShort() + val s = 10.1.toInt().toShort() try { val removed = list.removeAt(10) val isRemoved = list.remove("a")