From 71946f861b3b50ab547ddf587e16d75f1252d108 Mon Sep 17 00:00:00 2001 From: xingzeng Date: Tue, 9 Sep 2025 10:36:15 +0800 Subject: [PATCH] Remove unboxed method or use to{Type} instead Remove unboxed method for Built-In Type Classes Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICVOSZ Reason: The es2panda front-en emits toByte&co instead of unboxed in lowering. The public unboxed() method is slated for removal now that we don't have primitives at the language level. Meaning: Transfer from relying on primitive types to not relying on primitive types, with promise that in new language compiling framework it stiil can process type cast correctly. Signed-off-by: xingzeng --- .../test/ast/compiler/ets/DeclareCheckAssign.ets | 2 +- .../compiler/ets/lambdaFunctionArrayDeclaration.ets | 2 +- ets2panda/test/runtime/ets/boxingConversions.ets | 2 +- ets2panda/test/runtime/ets/boxingConversions2.ets | 2 +- ets2panda/test/runtime/ets/boxingConversions3.ets | 12 ++++++------ ets2panda/test/runtime/ets/boxingConversions4.ets | 8 ++++---- ets2panda/test/runtime/ets/boxingConversions5.ets | 6 +++--- ets2panda/test/runtime/ets/castSequence.ets | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ets2panda/test/ast/compiler/ets/DeclareCheckAssign.ets b/ets2panda/test/ast/compiler/ets/DeclareCheckAssign.ets index 7e3feec7a6..3eb37ca78f 100644 --- a/ets2panda/test/ast/compiler/ets/DeclareCheckAssign.ets +++ b/ets2panda/test/ast/compiler/ets/DeclareCheckAssign.ets @@ -16,7 +16,7 @@ export declare const byte_1: byte = -127 as byte, byte_2: byte = 126 as byte; export declare const byte_12: byte = -127 + 1, byte_22: byte = 126 - 1; export declare const byte_13: byte = Byte.MIN_VALUE, byte_23: byte = 126; -export declare const byte_14: byte = new Byte().unboxed() +export declare const byte_14: byte = new Byte().toByte() export declare const int_1 = 1 + 2 + 3 + 4 const v = 42 export declare const int_12 = v diff --git a/ets2panda/test/compiler/ets/lambdaFunctionArrayDeclaration.ets b/ets2panda/test/compiler/ets/lambdaFunctionArrayDeclaration.ets index d62b5ae67e..0adecbc70c 100644 --- a/ets2panda/test/compiler/ets/lambdaFunctionArrayDeclaration.ets +++ b/ets2panda/test/compiler/ets/lambdaFunctionArrayDeclaration.ets @@ -14,6 +14,6 @@ */ function main(): int { - let src14: ((x: Char) => char)[] = [(p: Char): char => { return p.unboxed(); }]; + let src14: ((x: Char) => char)[] = [(p: Char): char => { return p.toChar(); }]; return 0; } diff --git a/ets2panda/test/runtime/ets/boxingConversions.ets b/ets2panda/test/runtime/ets/boxingConversions.ets index ae548e88b8..bbfd408070 100644 --- a/ets2panda/test/runtime/ets/boxingConversions.ets +++ b/ets2panda/test/runtime/ets/boxingConversions.ets @@ -16,5 +16,5 @@ function main() { let s: long = 1 let d: Double = s - arktest.assertEQ(d.unboxed(), 1.0) + arktest.assertEQ(d, 1.0) } diff --git a/ets2panda/test/runtime/ets/boxingConversions2.ets b/ets2panda/test/runtime/ets/boxingConversions2.ets index 7b536bf0f1..318e22882b 100644 --- a/ets2panda/test/runtime/ets/boxingConversions2.ets +++ b/ets2panda/test/runtime/ets/boxingConversions2.ets @@ -16,6 +16,6 @@ function main() { let s1: int = 0 let d1: Float = s1 - arktest.assertEQ(d1.unboxed(), 0.0) + arktest.assertEQ(d1, 0.0) } diff --git a/ets2panda/test/runtime/ets/boxingConversions3.ets b/ets2panda/test/runtime/ets/boxingConversions3.ets index fed975dfdf..22585493c5 100644 --- a/ets2panda/test/runtime/ets/boxingConversions3.ets +++ b/ets2panda/test/runtime/ets/boxingConversions3.ets @@ -21,11 +21,11 @@ function main() { let f: Float = b let d: Double = b let c: Char = b - arktest.assertEQ(s.unboxed(), 1.0) - arktest.assertEQ(i.unboxed(), 1.0) - arktest.assertEQ(l.unboxed(), 1.0) - arktest.assertEQ(f.unboxed(), 1.0) - arktest.assertEQ(d.unboxed(), 1.0) - arktest.assertEQ(c.unboxed(), 1.0) + arktest.assertEQ(s, 1.0) + arktest.assertEQ(i, 1.0) + arktest.assertEQ(l, 1.0) + arktest.assertEQ(f, 1.0) + arktest.assertEQ(d, 1.0) + arktest.assertEQ(c, 1.0) } diff --git a/ets2panda/test/runtime/ets/boxingConversions4.ets b/ets2panda/test/runtime/ets/boxingConversions4.ets index 2c0abda389..9465602fac 100644 --- a/ets2panda/test/runtime/ets/boxingConversions4.ets +++ b/ets2panda/test/runtime/ets/boxingConversions4.ets @@ -19,9 +19,9 @@ function main() { let l: Long = c let f: Float = c let d: Double = c - arktest.assertEQ(i.unboxed(), 97) - arktest.assertEQ(l.unboxed(), 97) - arktest.assertEQ(f.unboxed(), 97.0) - arktest.assertEQ(d.unboxed(), 97.0) + arktest.assertEQ(i, 97) + arktest.assertEQ(l, 97) + arktest.assertEQ(f, 97.0) + arktest.assertEQ(d, 97.0) } diff --git a/ets2panda/test/runtime/ets/boxingConversions5.ets b/ets2panda/test/runtime/ets/boxingConversions5.ets index d391a80e4a..2c5982b970 100644 --- a/ets2panda/test/runtime/ets/boxingConversions5.ets +++ b/ets2panda/test/runtime/ets/boxingConversions5.ets @@ -19,7 +19,7 @@ function main() { let f: Float = i let d: Double = i - arktest.assertEQ(l.unboxed(), 1) - arktest.assertEQ(f.unboxed(), 1.0) - arktest.assertEQ(d.unboxed(), 1.0) + arktest.assertEQ(l, 1) + arktest.assertEQ(f, 1.0) + arktest.assertEQ(d, 1.0) } diff --git a/ets2panda/test/runtime/ets/castSequence.ets b/ets2panda/test/runtime/ets/castSequence.ets index ae948937ae..f423695c5f 100644 --- a/ets2panda/test/runtime/ets/castSequence.ets +++ b/ets2panda/test/runtime/ets/castSequence.ets @@ -17,7 +17,7 @@ function main(): void { let a_int : int = 2147; let b_Num : Number = Int.toDouble(a_int); - arktest.assertTrue(b_Num instanceof Number && b_Num.unboxed() == 2147.0) + arktest.assertTrue(b_Num instanceof Number && b_Num.toDouble() == 2147.0) let a_Short : Short = 215; let b_double : double = Short.toDouble(a_Short); @@ -28,7 +28,7 @@ function main(): void { let a_char : char = 128 as char; let b_Char = a_char as Char; - arktest.assertEQ(b_Char.unboxed(), 128 as char) + arktest.assertEQ(b_Char.toChar(), 128 as char) return; } \ No newline at end of file -- Gitee