From a64d8e8a3147751165d6690ac16946eaf813ef9b Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 21 Feb 2023 12:53:58 +0200 Subject: [PATCH] [Stdlib] Deprecate and make open Number.toChar() ^KT-46465 Fixed --- .../testData/builtIns/kotlin.txt | 14 ++++--- .../constant/FirToConstantValueTransformer.kt | 2 +- ...LightTreeBlackBoxCodegenTestGenerated.java | 18 ++++++++ .../FirPsiBlackBoxCodegenTestGenerated.java | 18 ++++++++ .../kotlin/fir/lightTree/PathWalker.kt | 16 ++++--- .../builtin-classes/default/kotlin.txt | 14 ++++--- .../testData/builtin-classes/java6/kotlin.txt | 14 ++++--- .../testData/builtin-classes/java8/kotlin.txt | 14 ++++--- .../builtin-classes/newMethods/kotlin.txt | 14 ++++--- .../primitiveTypes/customNumberInheritor.kt | 38 +++++++++++++++++ .../customNumberInheritor_callToSuper.kt | 42 +++++++++++++++++++ ...tomNumberInheritor_interfaceInheritance.kt | 41 ++++++++++++++++++ .../constFromBuiltins.__kotlin.Int.ir.txt | 2 +- .../IrBlackBoxCodegenTestGenerated.java | 18 ++++++++ core/builtins/native/kotlin/Number.kt | 7 +++- core/builtins/native/kotlin/Primitives.kt | 11 ++--- generators/builtins/primitives.kt | 14 +++---- .../fir/FirJsCodegenBoxTestGenerated.java | 18 ++++++++ .../test/ir/IrJsCodegenBoxTestGenerated.java | 18 ++++++++ .../ir/IrJsES6CodegenBoxTestGenerated.java | 18 ++++++++ .../runtime/src/main/kotlin/kotlin/Number.kt | 6 ++- .../src/main/kotlin/kotlin/Primitives.kt | 11 ++--- libraries/stdlib/api/js-v1/kotlin.kt | 16 ++++--- libraries/stdlib/api/js/kotlin.kt | 15 ++++--- libraries/stdlib/js-ir/builtins/Primitives.kt | 8 ++-- libraries/stdlib/js-ir/runtime/long.kt | 2 +- .../stdlib/wasm/builtins/kotlin/Primitives.kt | 11 +++++ .../FirNativeCodegenBoxTestGenerated.java | 18 ++++++++ .../K1NativeCodegenBoxTestGenerated.java | 18 ++++++++ .../test/IrCodegenBoxWasmTestGenerated.java | 15 +++++++ 30 files changed, 399 insertions(+), 72 deletions(-) create mode 100644 compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt create mode 100644 compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt create mode 100644 compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt diff --git a/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt b/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt index 2fb2aa342c9..febf00e8b31 100644 --- a/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt +++ b/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt @@ -214,7 +214,7 @@ public final class Byte : R|kotlin/Number|, R|kotlin/Comparable|, R @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toByte(): R|kotlin/Byte| - @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| + @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5), errorSince = String(2.3)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toDouble(): R|kotlin/Double| @@ -521,7 +521,7 @@ public final class Double : R|kotlin/Number|, R|kotlin/Comparable @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)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toByte(): R|kotlin/Byte| - @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| + @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5), errorSince = String(2.3)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toDouble(): R|kotlin/Double| @@ -714,7 +714,7 @@ public final class Float : R|kotlin/Number|, R|kotlin/Comparable|, @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)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toByte(): R|kotlin/Byte| - @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| + @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5), errorSince = String(2.3)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toDouble(): R|kotlin/Double| @@ -1049,7 +1049,7 @@ public final class Long : R|kotlin/Number|, R|kotlin/Comparable|, R @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toByte(): R|kotlin/Byte| - @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| + @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5), errorSince = String(2.3)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toDouble(): R|kotlin/Double| @@ -1101,7 +1101,9 @@ public final class Nothing { public abstract class Number : R|kotlin/Any|, R|java/io/Serializable| { public abstract fun toByte(): R|kotlin/Byte| - public abstract fun toChar(): R|kotlin/Char| + @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. +If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. +See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.9), errorSince = String(2.3)) public open fun toChar(): R|kotlin/Char| public abstract fun toDouble(): R|kotlin/Double| @@ -1290,7 +1292,7 @@ public final class Short : R|kotlin/Number|, R|kotlin/Comparable|, @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toByte(): R|kotlin/Byte| - @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| + @R|kotlin/Deprecated|(message = String(Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.toInt().toChar())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5), errorSince = String(2.3)) @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toChar(): R|kotlin/Char| @R|kotlin/internal/IntrinsicConstEvaluation|() public open fun toDouble(): R|kotlin/Double| diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/constant/FirToConstantValueTransformer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/constant/FirToConstantValueTransformer.kt index 9e77304b0e6..97030fbd4a8 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/constant/FirToConstantValueTransformer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/constant/FirToConstantValueTransformer.kt @@ -128,7 +128,7 @@ internal object FirToConstantValueTransformer : FirDefaultVisitor ShortValue((dispatchReceiverValue!!.value as Number).toShort()) "toFloat" -> FloatValue((dispatchReceiverValue!!.value as Number).toFloat()) "toDouble" -> DoubleValue((dispatchReceiverValue!!.value as Number).toDouble()) - "toChar" -> CharValue((dispatchReceiverValue!!.value as Number).toChar()) + "toChar" -> CharValue((dispatchReceiverValue!!.value as Number).toInt().toChar()) "unaryMinus" -> { when (val receiverValue = dispatchReceiverValue) { is ByteValue -> ByteValue((-receiverValue.value).toByte()) diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 5f7c8308567..2dae9249ff3 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -35293,6 +35293,24 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/primitiveTypes/conversions.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 24394444e61..40edbb649f1 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -35293,6 +35293,24 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/primitiveTypes/conversions.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/compiler/fir/raw-fir/light-tree2fir/tests/org/jetbrains/kotlin/fir/lightTree/PathWalker.kt b/compiler/fir/raw-fir/light-tree2fir/tests/org/jetbrains/kotlin/fir/lightTree/PathWalker.kt index 8e7c26d3732..5fb13f3b57e 100644 --- a/compiler/fir/raw-fir/light-tree2fir/tests/org/jetbrains/kotlin/fir/lightTree/PathWalker.kt +++ b/compiler/fir/raw-fir/light-tree2fir/tests/org/jetbrains/kotlin/fir/lightTree/PathWalker.kt @@ -11,10 +11,16 @@ fun String.walkTopDown(f: (File) -> Unit) { val root = File(this) for (file in root.walkTopDown()) { if (file.isDirectory) continue - if (file.path.contains("kotlin-native") || - file.path.contains("testData") || - file.path.contains("testdata") || - file.path.contains("resources")) continue + val path = file.path + if ( + path.contains("kotlin-native") || + path.contains("testData") || + path.contains("testdata") || + path.contains("resources") + ) continue + + if (path.replace(File.separator, "/").contains("stdlib/api")) continue + if (file.extension != "kt") continue f(file) @@ -29,4 +35,4 @@ fun String.walkTopDownWithTestData(f: (File) -> Unit) { f(file) } -} \ No newline at end of file +} diff --git a/compiler/testData/builtin-classes/default/kotlin.txt b/compiler/testData/builtin-classes/default/kotlin.txt index 75a37acc8d4..dc0d1542e09 100644 --- a/compiler/testData/builtin-classes/default/kotlin.txt +++ b/compiler/testData/builtin-classes/default/kotlin.txt @@ -104,7 +104,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -287,7 +287,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -396,7 +396,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -579,7 +579,7 @@ public final class Long : kotlin.Number, kotlin.Comparable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -620,7 +620,9 @@ public final class Nothing { public abstract class Number { /*primary*/ public constructor Number() public abstract fun toByte(): kotlin.Byte - public abstract fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. +If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. +See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9") public open fun toChar(): kotlin.Char public abstract fun toDouble(): kotlin.Double public abstract fun toFloat(): kotlin.Float public abstract fun toInt(): kotlin.Int @@ -727,7 +729,7 @@ public final class Short : kotlin.Number, kotlin.Comparable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int diff --git a/compiler/testData/builtin-classes/java6/kotlin.txt b/compiler/testData/builtin-classes/java6/kotlin.txt index deeabb0849e..d94c7fe5a27 100644 --- a/compiler/testData/builtin-classes/java6/kotlin.txt +++ b/compiler/testData/builtin-classes/java6/kotlin.txt @@ -106,7 +106,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable, java.io @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -299,7 +299,7 @@ public final class Double : kotlin.Number, kotlin.Comparable, jav @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -411,7 +411,7 @@ public final class Float : kotlin.Number, kotlin.Comparable, java. @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -596,7 +596,7 @@ public final class Long : kotlin.Number, kotlin.Comparable, java.io @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -638,7 +638,9 @@ public final class Nothing { public abstract class Number : kotlin.Any, java.io.Serializable { /*primary*/ public constructor Number() public abstract fun toByte(): kotlin.Byte - public abstract fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. +If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. +See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9") public open fun toChar(): kotlin.Char public abstract fun toDouble(): kotlin.Double public abstract fun toFloat(): kotlin.Float public abstract fun toInt(): kotlin.Int @@ -749,7 +751,7 @@ public final class Short : kotlin.Number, kotlin.Comparable, java. @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int diff --git a/compiler/testData/builtin-classes/java8/kotlin.txt b/compiler/testData/builtin-classes/java8/kotlin.txt index 4f75c888b5d..3dcf52c8720 100644 --- a/compiler/testData/builtin-classes/java8/kotlin.txt +++ b/compiler/testData/builtin-classes/java8/kotlin.txt @@ -106,7 +106,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable, java.io @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -301,7 +301,7 @@ public final class Double : kotlin.Number, kotlin.Comparable, jav @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -413,7 +413,7 @@ public final class Float : kotlin.Number, kotlin.Comparable, java. @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -598,7 +598,7 @@ public final class Long : kotlin.Number, kotlin.Comparable, java.io @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -640,7 +640,9 @@ public final class Nothing { public abstract class Number : kotlin.Any, java.io.Serializable { /*primary*/ public constructor Number() public abstract fun toByte(): kotlin.Byte - public abstract fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. +If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. +See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9") public open fun toChar(): kotlin.Char public abstract fun toDouble(): kotlin.Double public abstract fun toFloat(): kotlin.Float public abstract fun toInt(): kotlin.Int @@ -751,7 +753,7 @@ public final class Short : kotlin.Number, kotlin.Comparable, java. @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int diff --git a/compiler/testData/builtin-classes/newMethods/kotlin.txt b/compiler/testData/builtin-classes/newMethods/kotlin.txt index 7afea2912d8..4fc2944bac2 100644 --- a/compiler/testData/builtin-classes/newMethods/kotlin.txt +++ b/compiler/testData/builtin-classes/newMethods/kotlin.txt @@ -106,7 +106,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable, java.io @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -299,7 +299,7 @@ public final class Double : kotlin.Number, kotlin.Comparable, jav @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -411,7 +411,7 @@ public final class Float : kotlin.Number, kotlin.Comparable, java. @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation 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 = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.3") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -596,7 +596,7 @@ public final class Long : kotlin.Number, kotlin.Comparable, java.io @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int @@ -638,7 +638,9 @@ public final class Nothing { public abstract class Number : kotlin.Any, java.io.Serializable { /*primary*/ public constructor Number() public abstract fun toByte(): kotlin.Byte - public abstract fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. +If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. +See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9") public open fun toChar(): kotlin.Char public abstract fun toDouble(): kotlin.Double public abstract fun toFloat(): kotlin.Float public abstract fun toInt(): kotlin.Int @@ -749,7 +751,7 @@ public final class Short : kotlin.Number, kotlin.Comparable, java. @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Long): kotlin.Long @kotlin.internal.IntrinsicConstEvaluation public final operator fun times(/*0*/ other: kotlin.Short): kotlin.Int @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toByte(): kotlin.Byte - @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toChar(): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toDouble(): kotlin.Double @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toFloat(): kotlin.Float @kotlin.internal.IntrinsicConstEvaluation public open override /*1*/ fun toInt(): kotlin.Int diff --git a/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt b/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt new file mode 100644 index 00000000000..e969a6692f2 --- /dev/null +++ b/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt @@ -0,0 +1,38 @@ +// DONT_TARGET_EXACT_BACKEND: JVM +// DONT_TARGET_EXACT_BACKEND: JS +// IGNORE_BACKEND: JVM_IR, JS_IR +// KT-46465 +// WITH_STDLIB + +class MyNumber(val b: Boolean) : Number() { + override fun toByte(): Byte { + return toInt().toByte() + } + + override fun toDouble(): Double { + return toInt().toDouble() + } + + override fun toFloat(): Float { + return toInt().toFloat() + } + + override fun toInt(): Int { + return if (b) { 'O'.code } else { 'K'.code } + } + + override fun toLong(): Long { + return toInt().toLong() + } + + override fun toShort(): Short { + return toInt().toShort() + } +} + +@Suppress("DEPRECATION") +fun box(): String { + val o = MyNumber(true) + val k = MyNumber(false) + return "${o.toChar()}${k.toChar()}" +} diff --git a/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt b/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt new file mode 100644 index 00000000000..1363f887f44 --- /dev/null +++ b/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt @@ -0,0 +1,42 @@ +// DONT_TARGET_EXACT_BACKEND: JVM +// DONT_TARGET_EXACT_BACKEND: JS +// IGNORE_BACKEND: JS_IR +// KT-46465 +// WITH_STDLIB + +class MyNumber(val b: Boolean) : Number() { + override fun toByte(): Byte { + return toInt().toByte() + } + + override fun toDouble(): Double { + return toInt().toDouble() + } + + override fun toFloat(): Float { + return toInt().toFloat() + } + + override fun toChar(): Char { + return super.toChar() + } + + override fun toInt(): Int { + return if (b) { 'O'.code } else { 'K'.code } + } + + override fun toLong(): Long { + return toInt().toLong() + } + + override fun toShort(): Short { + return toInt().toShort() + } +} + +@Suppress("DEPRECATION") +fun box(): String { + val o = MyNumber(true) + val k = MyNumber(false) + return "${o.toChar()}${k.toChar()}" +} diff --git a/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt b/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt new file mode 100644 index 00000000000..d1187484f13 --- /dev/null +++ b/compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt @@ -0,0 +1,41 @@ +// DONT_TARGET_EXACT_BACKEND: JVM +// DONT_TARGET_EXACT_BACKEND: JS +// KT-46465 +// WITH_STDLIB + +interface Some { + fun toChar(): Char +} + +class MyNumber(val b: Boolean) : Number() { + override fun toByte(): Byte { + return toInt().toByte() + } + + override fun toDouble(): Double { + return toInt().toDouble() + } + + override fun toFloat(): Float { + return toInt().toFloat() + } + + override fun toInt(): Int { + return if (b) { 'O'.code } else { 'K'.code } + } + + override fun toLong(): Long { + return toInt().toLong() + } + + override fun toShort(): Short { + return toInt().toShort() + } +} + +@Suppress("DEPRECATION") +fun box(): String { + val o = MyNumber(true) + val k = MyNumber(false) + return "${o.toChar()}${k.toChar()}" +} diff --git a/compiler/testData/ir/irText/stubs/constFromBuiltins.__kotlin.Int.ir.txt b/compiler/testData/ir/irText/stubs/constFromBuiltins.__kotlin.Int.ir.txt index 5e7771fd15d..897abb2d1b2 100644 --- a/compiler/testData/ir/irText/stubs/constFromBuiltins.__kotlin.Int.ir.txt +++ b/compiler/testData/ir/irText/stubs/constFromBuiltins.__kotlin.Int.ir.txt @@ -275,7 +275,7 @@ CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Int modality:FINAL visibility:publ annotations: IntrinsicConstEvaluation overridden: - public abstract fun toChar (): kotlin.Char declared in kotlin.Number + public open fun toChar (): kotlin.Char declared in kotlin.Number $this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name: type:kotlin.Int FUN IR_EXTERNAL_DECLARATION_STUB name:toDouble visibility:public modality:OPEN <> ($this:kotlin.Int) returnType:kotlin.Double annotations: diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index d466e2249c0..2377490b3c8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -35293,6 +35293,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/primitiveTypes/conversions.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/core/builtins/native/kotlin/Number.kt b/core/builtins/native/kotlin/Number.kt index cc57b35b91b..99c0d1a35b2 100644 --- a/core/builtins/native/kotlin/Number.kt +++ b/core/builtins/native/kotlin/Number.kt @@ -43,8 +43,11 @@ public abstract class Number { /** * Returns the [Char] with the numeric value equal to this number, truncated to 16 bits if appropriate. */ -// @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - public abstract fun toChar(): Char + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\nIf you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it.\nSee https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.9", errorSince = "2.3") + public open fun toChar(): Char { + return toInt().toChar() + } /** * Returns the value of this number as a [Short], which may involve rounding or truncation. diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index a08a2a7e32f..7df63ef3146 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -287,7 +287,7 @@ public class Byte private constructor() : Number(), Comparable { * whereas the most significant 8 bits are filled with the sign bit of this value. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @kotlin.internal.IntrinsicConstEvaluation public override fun toChar(): Char /** @@ -627,7 +627,7 @@ public class Short private constructor() : Number(), Comparable { * i.e. it has the same binary representation as this `Short`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @kotlin.internal.IntrinsicConstEvaluation public override fun toChar(): Char /** Returns this value. */ @@ -1001,6 +1001,7 @@ public class Int private constructor() : Number(), Comparable { * * The resulting `Char` code is represented by the least significant 16 bits of this `Int` value. */ + @Suppress("OVERRIDE_DEPRECATION") @kotlin.internal.IntrinsicConstEvaluation public override fun toChar(): Char /** @@ -1377,7 +1378,7 @@ public class Long private constructor() : Number(), Comparable { * The resulting `Char` code is represented by the least significant 16 bits of this `Long` value. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @kotlin.internal.IntrinsicConstEvaluation public override fun toChar(): Char /** @@ -1683,7 +1684,7 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Char` value is equal to `this.toInt().toChar()`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @kotlin.internal.IntrinsicConstEvaluation public override fun toChar(): Char /** @@ -1985,7 +1986,7 @@ public class Double private constructor() : Number(), Comparable { * The resulting `Char` value is equal to `this.toInt().toChar()`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @kotlin.internal.IntrinsicConstEvaluation public override fun toChar(): Char /** diff --git a/generators/builtins/primitives.kt b/generators/builtins/primitives.kt index fa63a84bbbe..1963a3545c2 100644 --- a/generators/builtins/primitives.kt +++ b/generators/builtins/primitives.kt @@ -437,10 +437,6 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { return kind in PrimitiveType.floatingPoint && otherKind in listOf(PrimitiveType.BYTE, PrimitiveType.SHORT) } - fun isCharConversionDeprecated(otherKind: PrimitiveType): Boolean { - return kind != PrimitiveType.INT && otherKind == PrimitiveType.CHAR - } - val thisName = kind.capitalized for (otherKind in PrimitiveType.exceptBoolean) { val otherName = otherKind.capitalized @@ -469,9 +465,13 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { 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\")") } - if (isCharConversionDeprecated(otherKind)) { - out.println(" @Deprecated(\"Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\", ReplaceWith(\"this.toInt().toChar()\"))") - out.println(" @DeprecatedSinceKotlin(warningSince = \"1.5\")") + if (otherKind == PrimitiveType.CHAR) { + if (kind == PrimitiveType.INT) { + out.println(" @Suppress(\"OVERRIDE_DEPRECATION\")") + } else { + out.println(" @Deprecated(\"Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\", ReplaceWith(\"this.toInt().toChar()\"))") + out.println(" @DeprecatedSinceKotlin(warningSince = \"1.5\", errorSince = \"2.3\")") + } } out.println(" @kotlin.internal.IntrinsicConstEvaluation") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index ddcc2b2999a..64d0ffa9194 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -24849,6 +24849,24 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/primitiveTypes/crossTypeEquals.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 1bba3a1b747..91ae661f019 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -24849,6 +24849,24 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/primitiveTypes/crossTypeEquals.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index c342456964d..eb6117e774c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -24849,6 +24849,24 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/primitiveTypes/crossTypeEquals.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Number.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Number.kt index be065f9a03a..e57e98fa092 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Number.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Number.kt @@ -32,7 +32,11 @@ public abstract class Number { /** * Returns the [Char] with the numeric value equal to this number, truncated to 16 bits if appropriate. */ - public abstract fun toChar(): Char + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\nIf you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it.\nSee https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.9", errorSince = "2.3") + public open fun toChar(): Char { + return toInt().toChar() + } /** * Returns the value of this number as a [Short], which may involve rounding or truncation. diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt index ec8f7d2403a..42979608aa2 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt @@ -289,7 +289,7 @@ public final class Byte private constructor() : Number(), Comparable { * whereas the most significant 8 bits are filled with the sign bit of this value. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @TypedIntrinsic(IntrinsicType.SIGN_EXTEND) external public override fun toChar(): Char /** @@ -634,7 +634,7 @@ public final class Short private constructor() : Number(), Comparable { * i.e. it has the same binary representation as this `Short`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @TypedIntrinsic(IntrinsicType.ZERO_EXTEND) external public override fun toChar(): Char @@ -1017,6 +1017,7 @@ public final class Int private constructor() : Number(), Comparable { * The resulting `Char` code is represented by the least significant 16 bits of this `Int` value. */ @TypedIntrinsic(IntrinsicType.INT_TRUNCATE) + @Suppress("OVERRIDE_DEPRECATION") external public override fun toChar(): Char /** * Converts this [Int] value to [Short]. @@ -1397,7 +1398,7 @@ public final class Long private constructor() : Number(), Comparable { * The resulting `Char` code is represented by the least significant 16 bits of this `Long` value. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @TypedIntrinsic(IntrinsicType.INT_TRUNCATE) external public override fun toChar(): Char /** @@ -1706,7 +1707,7 @@ public final class Float private constructor() : Number(), Comparable { * The resulting `Char` value is equal to `this.toInt().toChar()`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char = this.toInt().toChar() /** @@ -2014,7 +2015,7 @@ public final class Double private constructor() : Number(), Comparable { * The resulting `Char` value is equal to `this.toInt().toChar()`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char = this.toInt().toChar() /** diff --git a/libraries/stdlib/api/js-v1/kotlin.kt b/libraries/stdlib/api/js-v1/kotlin.kt index fe540a48ddb..eba4dc5aa25 100644 --- a/libraries/stdlib/api/js-v1/kotlin.kt +++ b/libraries/stdlib/api/js-v1/kotlin.kt @@ -1135,7 +1135,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") /*∆*/ @kotlin.internal.IntrinsicConstEvaluation public open override fun toChar(): kotlin.Char @@ -1524,7 +1524,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") /*∆*/ @kotlin.internal.IntrinsicConstEvaluation public open override fun toChar(): kotlin.Char @@ -1819,7 +1819,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") /*∆*/ @kotlin.internal.IntrinsicConstEvaluation public open override fun toChar(): kotlin.Char @@ -2348,7 +2348,7 @@ public final class Long : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") /*∆*/ @kotlin.internal.IntrinsicConstEvaluation public open override fun toChar(): kotlin.Char @@ -2443,7 +2443,11 @@ public abstract class Number { public abstract fun toByte(): kotlin.Byte - public abstract fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. + If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. + See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9") + public open fun toChar(): kotlin.Char public abstract fun toDouble(): kotlin.Double @@ -2766,7 +2770,7 @@ public final class Short : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) -/*∆*/ @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") /*∆*/ @kotlin.internal.IntrinsicConstEvaluation public open override fun toChar(): kotlin.Char diff --git a/libraries/stdlib/api/js/kotlin.kt b/libraries/stdlib/api/js/kotlin.kt index 45a0969dfbb..bea10a6a29d 100644 --- a/libraries/stdlib/api/js/kotlin.kt +++ b/libraries/stdlib/api/js/kotlin.kt @@ -1051,7 +1051,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") public open override fun toChar(): kotlin.Char public open override fun toDouble(): kotlin.Double @@ -1381,7 +1381,7 @@ public final class Double : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") public open override fun toChar(): kotlin.Char public open override fun toDouble(): kotlin.Double @@ -1612,7 +1612,7 @@ public final class Float : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") public open override fun toChar(): kotlin.Char public open override fun toDouble(): kotlin.Double @@ -2037,7 +2037,7 @@ public final class Long : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) - @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") public open override fun toChar(): kotlin.Char public open override fun toDouble(): kotlin.Double @@ -2121,7 +2121,11 @@ public abstract class Number { public abstract fun toByte(): kotlin.Byte - public abstract fun toChar(): kotlin.Char + @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead. + If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it. + See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9") + public open fun toChar(): kotlin.Char public abstract fun toDouble(): kotlin.Double @@ -2382,6 +2386,7 @@ public final class Short : kotlin.Number, kotlin.Comparable { public open override fun toByte(): kotlin.Byte @kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {})) + @kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5") public open override fun toChar(): kotlin.Char public open override fun toDouble(): kotlin.Double diff --git a/libraries/stdlib/js-ir/builtins/Primitives.kt b/libraries/stdlib/js-ir/builtins/Primitives.kt index cf8c6595ff5..23ee9a9bb69 100644 --- a/libraries/stdlib/js-ir/builtins/Primitives.kt +++ b/libraries/stdlib/js-ir/builtins/Primitives.kt @@ -249,7 +249,7 @@ public class Byte private constructor() : Number(), Comparable { * whereas the most significant 8 bits are filled with the sign bit of this value. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char /** * Converts this [Byte] value to [Short]. @@ -542,6 +542,7 @@ public class Short private constructor() : Number(), Comparable { * i.e. it has the same binary representation as this `Short`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char /** Returns this value. */ public override fun toShort(): Short @@ -861,6 +862,7 @@ public class Int private constructor() : Number(), Comparable { * * The resulting `Char` code is represented by the least significant 16 bits of this `Int` value. */ + @Suppress("OVERRIDE_DEPRECATION") public override fun toChar(): Char /** * Converts this [Int] value to [Short]. @@ -1118,7 +1120,7 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Char` value is equal to `this.toInt().toChar()`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char /** * Converts this [Float] value to [Short]. @@ -1374,7 +1376,7 @@ public class Double private constructor() : Number(), Comparable { * The resulting `Char` value is equal to `this.toInt().toChar()`. */ @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char /** * Converts this [Double] value to [Short]. diff --git a/libraries/stdlib/js-ir/runtime/long.kt b/libraries/stdlib/js-ir/runtime/long.kt index 0cff645ac67..bf951788cd9 100644 --- a/libraries/stdlib/js-ir/runtime/long.kt +++ b/libraries/stdlib/js-ir/runtime/long.kt @@ -307,7 +307,7 @@ public class Long internal constructor( public override fun toByte(): Byte = low.toByte() @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) - @DeprecatedSinceKotlin(warningSince = "1.5") + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char = low.toChar() public override fun toShort(): Short = low.toShort() public override fun toInt(): Int = low diff --git a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt index cf4c2556462..3ded24cea3b 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt @@ -313,6 +313,8 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa * The least significant 8 bits of the resulting `Char` code are the same as the bits of this `Byte` value, * whereas the most significant 8 bits are filled with the sign bit of this value. */ + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char = reinterpretAsInt().reinterpretAsChar() /** @@ -696,6 +698,8 @@ public class Short private constructor(private val value: Short) : Number(), Com * The resulting `Char` code is equal to this value reinterpreted as an unsigned number, * i.e. it has the same binary representation as this `Short`. */ + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override fun toChar(): Char = reinterpretAsInt().reinterpretAsChar() /** Returns this value. */ @@ -1125,6 +1129,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara * * The resulting `Char` code is represented by the least significant 16 bits of this `Int` value. */ + @Suppress("OVERRIDE_DEPRECATION") public override fun toChar(): Char = (this and 0xFFFF).reinterpretAsChar() @@ -1576,6 +1581,8 @@ public class Long private constructor(private val value: Long) : Number(), Compa * * The resulting `Char` code is represented by the least significant 16 bits of this `Long` value. */ + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override inline fun toChar(): Char = this.toInt().toChar() @@ -1923,6 +1930,8 @@ public class Float private constructor(private val value: Float) : Number(), Com * * The resulting `Char` value is equal to `this.toInt().toChar()`. */ + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override inline fun toChar(): Char = this.toInt().toChar() /** @@ -2264,6 +2273,8 @@ public class Double private constructor(private val value: Double) : Number(), C * * The resulting `Char` value is equal to `this.toInt().toChar()`. */ + @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) + @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") public override inline fun toChar(): Char = this.toInt().toChar() /** diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index 1349bc8643e..60376f4cfca 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -28349,6 +28349,24 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/primitiveTypes/conversions.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K1NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K1NativeCodegenBoxTestGenerated.java index 12763d770c3..e8ef50cd007 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K1NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K1NativeCodegenBoxTestGenerated.java @@ -28026,6 +28026,24 @@ public class K1NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes runTest("compiler/testData/codegen/box/primitiveTypes/conversions.kt"); } + @Test + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @Test + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @Test @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index ecdbd6fe929..37a4d4e6881 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -22147,6 +22147,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/primitiveTypes/conversions.kt"); } + @TestMetadata("customNumberInheritor.kt") + public void testCustomNumberInheritor() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor.kt"); + } + + @TestMetadata("customNumberInheritor_callToSuper.kt") + public void testCustomNumberInheritor_callToSuper() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_callToSuper.kt"); + } + + @TestMetadata("customNumberInheritor_interfaceInheritance.kt") + public void testCustomNumberInheritor_interfaceInheritance() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/customNumberInheritor_interfaceInheritance.kt"); + } + @TestMetadata("ea35963.kt") public void testEa35963() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/ea35963.kt");