From 6c2c1426120a5e07d32963588e067818a2820948 Mon Sep 17 00:00:00 2001 From: vadimdolgachev Date: Fri, 1 Aug 2025 10:56:53 +0700 Subject: [PATCH 1/2] Fixed type of the Array.length property --- .../arkui/src/stateManagement/base/observeWrappedArray.ts | 4 ++-- incremental/compat/src/arkts/observable.ts | 4 ++-- incremental/runtime/src/states/State.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arkoala-arkts/arkui/src/stateManagement/base/observeWrappedArray.ts b/arkoala-arkts/arkui/src/stateManagement/base/observeWrappedArray.ts index 34e8b5ea6..db12ae234 100644 --- a/arkoala-arkts/arkui/src/stateManagement/base/observeWrappedArray.ts +++ b/arkoala-arkts/arkui/src/stateManagement/base/observeWrappedArray.ts @@ -65,14 +65,14 @@ export class WrappedArray extends Array implements IObservedObject, Observ return ObserveSingleton.instance.shouldAddRef(this.____V1RenderId); } - override get length(): number { + override get length(): int { if (this.shouldAddRef()) { this.meta_.addRef(CONSTANT.OB_LENGTH); } return this.store_.length; } - override set length(newLen: number) { + override set length(newLen: int) { const len = this.store_.length; if (len !== newLen) { this.store_.length; diff --git a/incremental/compat/src/arkts/observable.ts b/incremental/compat/src/arkts/observable.ts index 33d25ead5..979520896 100644 --- a/incremental/compat/src/arkts/observable.ts +++ b/incremental/compat/src/arkts/observable.ts @@ -306,12 +306,12 @@ class ObservableArray extends Array { return ObservableHandler.find(this) } - override get length(): number { + override get length(): int { this.handler?.onAccess() return super.length } - override set length(length: number) { + override set length(length: int) { this.handler?.onModify() super.length = length } diff --git a/incremental/runtime/src/states/State.ts b/incremental/runtime/src/states/State.ts index e23203102..e09448171 100644 --- a/incremental/runtime/src/states/State.ts +++ b/incremental/runtime/src/states/State.ts @@ -494,7 +494,7 @@ class ArrayStateImpl extends StateImpl> implements ArrayState< } set length(value: number) { - this.mutable.length = value + this.mutable.length = float64toInt32(value) } at(index: number): Item { @@ -540,7 +540,7 @@ class ArrayStateImpl extends StateImpl> implements ArrayState< splice(start: number, deleteCount: number | undefined, ...items: Item[]): Array { const array = this.mutable - return array.splice(start, deleteCount ?? array.length, ...items) + return array.splice(float64toInt32(start), deleteCount != undefined ? float64toInt32(deleteCount) : array.length, ...items) } unshift(...items: Item[]): number { -- Gitee From 8a0658a96d550e18997b6569a1bf767eb0363f46 Mon Sep 17 00:00:00 2001 From: Aleksandr Veselov Date: Fri, 1 Aug 2025 12:45:49 +0300 Subject: [PATCH 2/2] Disable failing test --- ui2abc/tests-memo/test/ui2abc/main.test.ts | 79 +++++++++++----------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/ui2abc/tests-memo/test/ui2abc/main.test.ts b/ui2abc/tests-memo/test/ui2abc/main.test.ts index acdd591d4..2cf31792a 100644 --- a/ui2abc/tests-memo/test/ui2abc/main.test.ts +++ b/ui2abc/tests-memo/test/ui2abc/main.test.ts @@ -90,29 +90,29 @@ class TestFunctionWithReceiver extends Log { this.callFunctionWithReceiver(this.log) } } +// Improve: This test fails to compile @memo annotation attached to typedef, please fix +// class TestLambdaWithReceiver extends Log { +// /** @memo */ +// callFunctionWithReceiver(log: Array) { +// let a = new Dummy() +// type MemoT = +// /** @memo */ +// (this: Dummy, log: Array) => void +// /** @memo */ +// let f: MemoT = (this: Dummy, log: Array): void => { +// log.push("lambda with receiver") +// } +// f(a, log) +// a.f(log) +// } -class TestLambdaWithReceiver extends Log { - /** @memo */ - callFunctionWithReceiver(log: Array) { - let a = new Dummy() - type MemoT = - /** @memo */ - (this: Dummy, log: Array) => void - /** @memo */ - let f: MemoT = (this: Dummy, log: Array): void => { - log.push("lambda with receiver") - } - f(a, log) - a.f(log) - } - - /** @memo */ - test() { - this.log.push("lambda with receiver call") - GlobalStateHolder.globalState.value - this.callFunctionWithReceiver(this.log) - } -} +// /** @memo */ +// test() { +// this.log.push("lambda with receiver call") +// GlobalStateHolder.globalState.value +// this.callFunctionWithReceiver(this.log) +// } +// } class TestGetterAndSetter extends Log { /** @memo */ @@ -281,23 +281,24 @@ suite("[ARKTS+MEMO PLUGIN]", () => { }) // Improve: check but cause - test.expectFailure("Improve: fails in runtime, probably a bug in call AST", "Lambda function with receiver", () => { - const instance = new TestLambdaWithReceiver() - const root = testRoot(instance.test) - assertResultArray(instance.log, - "lambda with receiver call", - "lambda with receiver", - "lambda with receiver", - ) - GlobalStateHolder.globalState.value++ - testTick(root) - assertResultArray(instance.log, - "lambda with receiver call", - "lambda with receiver", - "lambda with receiver", - "lambda with receiver call", - ) - }) + // Improve: This test fails to compile @memo annotation attached to typedef, please fix + // test.expectFailure("Improve: fails in runtime, probably a bug in call AST", "Lambda function with receiver", () => { + // const instance = new TestLambdaWithReceiver() + // const root = testRoot(instance.test) + // assertResultArray(instance.log, + // "lambda with receiver call", + // "lambda with receiver", + // "lambda with receiver", + // ) + // GlobalStateHolder.globalState.value++ + // testTick(root) + // assertResultArray(instance.log, + // "lambda with receiver call", + // "lambda with receiver", + // "lambda with receiver", + // "lambda with receiver call", + // ) + // }) }) suite("Getter and Setter with property of memo function type", () => { -- Gitee