From 61ffb3d57a6076c5c2b1e522b9c07a6578075e48 Mon Sep 17 00:00:00 2001 From: cheezzario Date: Tue, 16 Jul 2024 12:42:23 +0300 Subject: [PATCH] [ArkTS][StdLib] Drop Object.equals Description: Drop Object.equals() Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/IACL01 Testing: All required pre-merge tests passed. Results are available in the ggwatcher Signed-off-by: cheezzario --- .../ets/generic_arrayaslist-expected.txt | 207 ++++-------------- .../test/compiler/ets/generic_arrayaslist.ets | 2 +- .../ets/generics_instantiation_3-expected.txt | 98 +++------ .../compiler/ets/generics_instantiation_3.ets | 4 +- ets2panda/test/runtime/ets/array-object.ets | 1 - .../runtime/ets/nullishTypeCodesamples.ets | 2 +- 6 files changed, 79 insertions(+), 235 deletions(-) diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt index f5d342c34e..4ca9a1c366 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt +++ b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt @@ -10870,231 +10870,108 @@ "test": { "type": "CallExpression", "callee": { - "type": "MemberExpression", - "object": { - "type": "TSAsExpression", - "expression": { + "type": "Identifier", + "name": "__runtimeEquals", + "decorators": [], + "loc": { + "start": { + "line": 132, + "column": 17 + }, + "end": { + "line": 132, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "object": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 132, - "column": 18 - }, - "end": { - "line": 132, - "column": 22 - } - } - }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 23 - }, - "end": { - "line": 132, - "column": 27 - } - } - }, - "computed": false, - "optional": false, + "type": "ThisExpression", "loc": { "start": { "line": 132, - "column": 18 + "column": 33 }, "end": { "line": 132, - "column": 27 + "column": 37 } } }, "property": { "type": "Identifier", - "name": "i", + "name": "data", "decorators": [], "loc": { "start": { "line": 132, - "column": 28 + "column": 38 }, "end": { "line": 132, - "column": 29 + "column": 42 } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { "line": 132, - "column": 18 + "column": 33 }, "end": { "line": 132, - "column": 30 + "column": 42 } } }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Object", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 34 - }, - "end": { - "line": 132, - "column": 40 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 34 - }, - "end": { - "line": 132, - "column": 41 - } - } - }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], "loc": { "start": { "line": 132, - "column": 34 + "column": 43 }, "end": { "line": 132, - "column": 41 + "column": 44 } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 132, - "column": 17 + "column": 33 }, "end": { "line": 132, - "column": 41 + "column": 45 } } }, - "property": { + { "type": "Identifier", - "name": "equals", + "name": "e", "decorators": [], "loc": { "start": { "line": 132, - "column": 42 + "column": 47 }, "end": { "line": 132, "column": 48 } } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 132, - "column": 17 - }, - "end": { - "line": 132, - "column": 48 - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 49 - }, - "end": { - "line": 132, - "column": 50 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Object", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 54 - }, - "end": { - "line": 132, - "column": 60 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 54 - }, - "end": { - "line": 132, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 54 - }, - "end": { - "line": 132, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 49 - }, - "end": { - "line": 132, - "column": 50 - } - } } ], "optional": false, @@ -11105,7 +10982,7 @@ }, "end": { "line": 132, - "column": 61 + "column": 49 } } }, @@ -11143,7 +11020,7 @@ "loc": { "start": { "line": 132, - "column": 63 + "column": 51 }, "end": { "line": 134, diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist.ets b/ets2panda/test/compiler/ets/generic_arrayaslist.ets index 4a08b5c2c4..33e480c871 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist.ets +++ b/ets2panda/test/compiler/ets/generic_arrayaslist.ets @@ -129,7 +129,7 @@ class ArrayAsListt implements Listt { assert false: "Not implemented: internal issue with calling equals"; for (let i = 0; i < this.curSize; ++i) { - if ((this.data[i] as Object).equals(e as Object)) { + if (__runtimeEquals(this.data[i], e)) { return true; } } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt b/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt index 757b511447..94e90ddeb9 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt +++ b/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt @@ -240,43 +240,14 @@ { "type": "ExpressionStatement", "expression": { - "type": "CallExpression", - "callee": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "MemberExpression", "object": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 18, - "column": 9 - }, - "end": { - "line": 18, - "column": 13 - } - } - }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 14 - }, - "end": { - "line": 18, - "column": 18 - } - } - }, - "computed": false, - "optional": false, + "type": "ThisExpression", "loc": { "start": { "line": 18, @@ -284,25 +255,26 @@ }, "end": { "line": 18, - "column": 18 + "column": 13 } } }, "property": { - "type": "NumberLiteral", - "value": 2, + "type": "Identifier", + "name": "data", + "decorators": [], "loc": { "start": { "line": 18, - "column": 19 + "column": 14 }, "end": { "line": 18, - "column": 20 + "column": 18 } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { @@ -311,26 +283,25 @@ }, "end": { "line": 18, - "column": 21 + "column": 18 } } }, "property": { - "type": "Identifier", - "name": "equals", - "decorators": [], + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 18, - "column": 22 + "column": 19 }, "end": { "line": 18, - "column": 28 + "column": 20 } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { @@ -339,28 +310,25 @@ }, "end": { "line": 18, - "column": 28 + "column": 21 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 30 - } + "right": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 26 } } - ], - "optional": false, + }, "loc": { "start": { "line": 18, @@ -368,7 +336,7 @@ }, "end": { "line": 18, - "column": 31 + "column": 26 } } }, @@ -379,7 +347,7 @@ }, "end": { "line": 18, - "column": 32 + "column": 27 } } } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_3.ets b/ets2panda/test/compiler/ets/generics_instantiation_3.ets index 53882858ed..eefe579d47 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_3.ets +++ b/ets2panda/test/compiler/ets/generics_instantiation_3.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,7 +15,7 @@ class A { public foo(e: T): void { - this.data[2].equals(e); + this.data[2] == e; } private data: T[]; diff --git a/ets2panda/test/runtime/ets/array-object.ets b/ets2panda/test/runtime/ets/array-object.ets index 916e01520f..c7caaf99e0 100644 --- a/ets2panda/test/runtime/ets/array-object.ets +++ b/ets2panda/test/runtime/ets/array-object.ets @@ -37,7 +37,6 @@ function main(): void { assert(arr1 == object_array); assert(arr1 == object); assert(arr1 != arr2); - assert(object.equals(arr1 as Object) == true); // Cannot cast type 'int[]' to 'Object[]' // let object_array2: Object[] = arr2 as Object[]; diff --git a/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets b/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets index 4d78ff9fdb..2b42d7b9ad 100644 --- a/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets +++ b/ets2panda/test/runtime/ets/nullishTypeCodesamples.ets @@ -19,7 +19,7 @@ class A { this.indices = new number[2][2]; } - public override equals(other: Object | null | undefined): boolean { + public equals(other: Object | null | undefined): boolean { for (let i = 0; i < this.indices!.length; ++i) { let num: number[] = this.indices![i]; num[0]; -- Gitee