From 5316e67ec95acc808bbf50679271bf36d01deaa9 Mon Sep 17 00:00:00 2001 From: muhammethalilsolmaz Date: Tue, 17 Jun 2025 11:14:23 +0300 Subject: [PATCH] fix: tests removed ignore-list and stdlib fix Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IC7VGJ Reason: Need type error Description: tests removed ignore-list and stdlib codes refactored. Tests: Tests removed from ignore list Signed-off-by: muhammethalilsolmaz --- .../plugins/ets/stdlib/escompat/Iterator.ets | 6 ++-- .../ets/stdlib/escompat/ReadonlyArray.ets | 2 +- .../plugins/ets/stdlib/std/core/Function.ets | 34 +++++++++---------- .../ets/templates/stdlib/Function.ets.j2 | 2 +- .../interface_variance.ets | 1 + .../interface_variance.params.yaml | 4 ++- .../interface_variance_2.ets | 2 +- .../interface_variance_2.params.yaml | 9 +++-- .../generic_in_out/generic_in_out.ets | 1 + .../generic_in_out/generic_in_out.params.yaml | 16 ++++++++- .../generic_in_out_only_compile.ets | 2 +- ...IntlDateTimeFormatSupportedLocalesTest.ets | 4 +-- .../test-lists/ets-cts/ets-cts-ignored.txt | 12 ------- 13 files changed, 52 insertions(+), 43 deletions(-) diff --git a/static_core/plugins/ets/stdlib/escompat/Iterator.ets b/static_core/plugins/ets/stdlib/escompat/Iterator.ets index 5f13bdab6e..8026f0af73 100644 --- a/static_core/plugins/ets/stdlib/escompat/Iterator.ets +++ b/static_core/plugins/ets/stdlib/escompat/Iterator.ets @@ -15,9 +15,9 @@ package escompat; -export class IteratorResult { - done: boolean - value: T | undefined +export class IteratorResult { + readonly done: boolean + readonly value: T | undefined constructor() { this.done = true diff --git a/static_core/plugins/ets/stdlib/escompat/ReadonlyArray.ets b/static_core/plugins/ets/stdlib/escompat/ReadonlyArray.ets index 3e27c448a6..974ab9ad02 100644 --- a/static_core/plugins/ets/stdlib/escompat/ReadonlyArray.ets +++ b/static_core/plugins/ets/stdlib/escompat/ReadonlyArray.ets @@ -15,7 +15,7 @@ package escompat; -export interface ReadonlyArray extends ConcatArray { +export interface ReadonlyArray extends ConcatArray { // concat(...items: (T | ConcatArray)[]): T[]; // concat(...items: (T | ConcatArray)[]): Array; concat(...items: FixedArray>): Array; diff --git a/static_core/plugins/ets/stdlib/std/core/Function.ets b/static_core/plugins/ets/stdlib/std/core/Function.ets index a710818039..18123eee1b 100644 --- a/static_core/plugins/ets/stdlib/std/core/Function.ets +++ b/static_core/plugins/ets/stdlib/std/core/Function.ets @@ -40,7 +40,7 @@ export interface __FunctionN extends FunctionN {} export abstract class LambdaN implements __FunctionN {} -export interface FunctionR0 +export interface FunctionR0 extends Function, __FunctionR1 { invokeR0(...r: FixedArray): R; @@ -238,7 +238,7 @@ export abstract class Lambda0 implements __Function0 { } } -export interface FunctionR1 +export interface FunctionR1 extends Function, __FunctionR2 { invokeR1(p1: P1, ...r: FixedArray): R; @@ -428,7 +428,7 @@ export abstract class Lambda1 implements __Function1 { } } -export interface FunctionR2 +export interface FunctionR2 extends Function, __FunctionR3 { invokeR2(p1: P1, p2: P2, ...r: FixedArray): R; @@ -608,7 +608,7 @@ export abstract class Lambda2 implements __Function2 { } } -export interface FunctionR3 +export interface FunctionR3 extends Function, __FunctionR4 { invokeR3(p1: P1, p2: P2, p3: P3, ...r: FixedArray): R; @@ -778,7 +778,7 @@ export abstract class Lambda3 implements __Function3 { } } -export interface FunctionR4 +export interface FunctionR4 extends Function, __FunctionR5 { invokeR4(p1: P1, p2: P2, p3: P3, p4: P4, ...r: FixedArray): R; @@ -938,7 +938,7 @@ export abstract class Lambda4 implements __Function4 { } } -export interface FunctionR5 +export interface FunctionR5 extends Function, __FunctionR6 { invokeR5(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, ...r: FixedArray): R; @@ -1088,7 +1088,7 @@ export abstract class Lambda5 implements __Function5 { } } -export interface FunctionR6 +export interface FunctionR6 extends Function, __FunctionR7 { invokeR6(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, ...r: FixedArray): R; @@ -1228,7 +1228,7 @@ export abstract class Lambda6 implements __Function6 { } } -export interface FunctionR7 +export interface FunctionR7 extends Function, __FunctionR8 { invokeR7(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, ...r: FixedArray): R; @@ -1358,7 +1358,7 @@ export abstract class Lambda7 implements __Function7 { } } -export interface FunctionR8 +export interface FunctionR8 extends Function, __FunctionR9 { invokeR8(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, ...r: FixedArray): R; @@ -1478,7 +1478,7 @@ export abstract class Lambda8 implements __Function8 { } } -export interface FunctionR9 +export interface FunctionR9 extends Function, __FunctionR10 { invokeR9(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, ...r: FixedArray): R; @@ -1588,7 +1588,7 @@ export abstract class Lambda9 implements __Function9 { } } -export interface FunctionR10 +export interface FunctionR10 extends Function, __FunctionR11 { invokeR10(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, ...r: FixedArray): R; @@ -1688,7 +1688,7 @@ export abstract class Lambda10 implements __Function10 { } } -export interface FunctionR11 +export interface FunctionR11 extends Function, __FunctionR12 { invokeR11(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, ...r: FixedArray): R; @@ -1778,7 +1778,7 @@ export abstract class Lambda11 implements __Function11 { } } -export interface FunctionR12 +export interface FunctionR12 extends Function, __FunctionR13 { invokeR12(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, ...r: FixedArray): R; @@ -1858,7 +1858,7 @@ export abstract class Lambda12 implements __Function12 { } } -export interface FunctionR13 +export interface FunctionR13 extends Function, __FunctionR14 { invokeR13(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, ...r: FixedArray): R; @@ -1928,7 +1928,7 @@ export abstract class Lambda13 implements __Function13 { } } -export interface FunctionR14 +export interface FunctionR14 extends Function, __FunctionR15 { invokeR14(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, ...r: FixedArray): R; @@ -1988,7 +1988,7 @@ export abstract class Lambda14 implements __Function14 { } } -export interface FunctionR15 +export interface FunctionR15 extends Function, __FunctionR16 { invokeR15(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, ...r: FixedArray): R; @@ -2038,7 +2038,7 @@ export abstract class Lambda15 implements __Function15 { } } -export interface FunctionR16 +export interface FunctionR16 extends Function { invokeR16(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, ...r: FixedArray): R; diff --git a/static_core/plugins/ets/templates/stdlib/Function.ets.j2 b/static_core/plugins/ets/templates/stdlib/Function.ets.j2 index 6daad694f9..82fa5ee783 100644 --- a/static_core/plugins/ets/templates/stdlib/Function.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/Function.ets.j2 @@ -22,7 +22,7 @@ package std.core; <{% for i in range(narg) -%} in P{{i + 1}}, {{""}} {%- endfor -%} -{%- if rest %}in PR, {% endif %}{{rvar}}out R> +{%- if rest %}PR, {% endif %}{{rvar}}out R> {%- endmacro %} {%- macro typeParamsList(narg, rest) -%} diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.ets b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.ets index 6a139e181a..3fa07b3d61 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.ets +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.ets @@ -23,6 +23,7 @@ desc: |- in T It restricts available methods so it is only allowed to access methods that do not use T or do use ones with T in in-positions only. params: interface arguments, use-site variance +tags: [compile-only, {{c.tag}}] ---*/ class X {} diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.params.yaml index a7bf9d83b9..07dd8c3e23 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance.params.yaml @@ -17,11 +17,13 @@ cases: use: |- let i: I = new A(new X()) i.methIn(new X()) + tag: negative - variance: "out " use: |- let i: I = new A(new X()) let z: X = i.methOut() - + tag: negative - use: |- let i: I = new A(new X()) let z: Object|null = i.methOut() + tag: positive diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.ets b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.ets index abf7248f44..605f6a6c18 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.ets +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.ets @@ -23,7 +23,7 @@ desc: |- in T It restricts available methods so it is only allowed to access methods that do not use T or do use ones with T in in-positions only. params: interface arguments, use-site variance -tags: +tags: [compile-only, {{c.tag}}] ---*/ class X {} diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.params.yaml index 44d45d7a1e..e60ef0ef0b 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/02.generic_instantiations/01.type_arguments/type_arguments_of_parameterized_declarations/interface_variance_2.params.yaml @@ -17,24 +17,27 @@ cases: use: |- let i: I = new A(new X()) let z: X = i.methOut() + tag: negative - variance: "in " use: |- let i: I = new A(new X()) let z: X = i.methInOut(new X()) - + tag: negative - variance: "out " use: |- let i: I = new A(new Y()) i.methIn(new Y()) + tag: negative - variance: "out " use: |- let i: I = new A(new X()) let z: X = i.methInOut(new X()) - + tag: negative - use: |- let i: I = new A(new X()) i.methIn(new X()) - + tag: positive - use: |- let i: I = new A(new X()) let z: Object|null = i.methInOut(new X()) + tag: positive diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.ets b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.ets index 42c27c3b51..80452e1fad 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.ets +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.ets @@ -17,6 +17,7 @@ /*--- desc: {{case.desc}} +tags: [compile-only, {{case.tag}}] ---*/ {{case.dec1|indent}} diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.params.yaml b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.params.yaml index 794164c044..f9e9fb8f70 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out.params.yaml @@ -21,6 +21,7 @@ generic_in_out: const a: A = { value: 42 }; const b: A = a; arktest.assertEQ(b.value, 42); + tag: negative - desc: Verify the covariance of the 'out' keyword, and act on the function. dec1: |- @@ -34,6 +35,7 @@ generic_in_out: const numberA = createA(42); const objectA: A = numberA; arktest.assertEQ(objectA.value, 42); + tag: negative - desc: To verify the covariance of an array. dec1: |- @@ -47,6 +49,7 @@ generic_in_out: const numberWrapper = createArrayWrapper([1, 2, 3]); const anyWrapper: ArrayWrapper = numberWrapper; arktest.assertEQ(JSON.stringify(anyWrapper.values), JSON.stringify([1, 2, 3])); + tag: negative - desc: Verify the application of the covariance of the 'out' keyword to the function return value. dec1: |- @@ -60,6 +63,7 @@ generic_in_out: const numberFunctionWrapper = createFunctionWrapper(() => 42); const anyFunctionWrapper: FunctionWrapper = numberFunctionWrapper; arktest.assertEQ(anyFunctionWrapper.func(), 42); + tag: negative - desc: Verify the combined use of the keywords in and out. dec1: |- @@ -73,6 +77,7 @@ generic_in_out: const numberFunctionWrapper = createFunctionWrapper((value: number) => value * 2); const anyFunctionWrapper: FunctionWrapper = numberFunctionWrapper; arktest.assertEQ(anyFunctionWrapper.func(42), 84); + tag: negative - desc: Verify the application of the covariance of the out keyword in readonlyArray. dec1: |- @@ -86,6 +91,7 @@ generic_in_out: const numberWrapper = createReadonlyArrayWrapper([1, 2, 3]); const anyWrapper: ReadonlyArrayWrapper = numberWrapper; arktest.assertEQ(JSON.stringify(anyWrapper.values), JSON.stringify([1, 2, 3])); + tag: negative - desc: Shows the covariant behavior of generics on return types. dec1: |- @@ -108,6 +114,7 @@ generic_in_out: const fruitProducer: Producer = new AppleProducer(); const fruit: Fruit = fruitProducer.produce(); arktest.assertTrue(fruit instanceof Apple); + tag: positive - desc: Show covariance of generic classes in return types. dec1: |- @@ -123,6 +130,7 @@ generic_in_out: const a: A = new C(); const c: A = a; arktest.assertEQ(c.getValue(), "Hello"); + tag: positive - desc: Verify the invariability of the'in' keyword. dec1: |- @@ -138,6 +146,7 @@ generic_in_out: const anyConsumer: Consumer = new A(); const numberConsumer: Consumer = anyConsumer; arktest.assertEQ(numberConsumer.consume(42), 42); + tag: positive - desc: Verify the application of the contravariance of the in keyword in callback functions. dec1: |- @@ -155,6 +164,7 @@ generic_in_out: const numberCallbackWrapper: CallbackWrapper = anyCallbackWrapper; numberCallbackWrapper.callback(42.0); arktest.assertEQ(a, 43); + tag: negative - desc: Shows the inverse behavior of generics on input parameters. dec1: |- @@ -178,6 +188,7 @@ generic_in_out: const result = animalConsumer.consume(new Dog()); arktest.assertEQ(result instanceof Animal, true); arktest.assertEQ(result instanceof Dog, true); + tag: negative - desc: Verify the combination of covariance and inversion. dec1: |- @@ -204,6 +215,7 @@ generic_in_out: const numberConsumer: Consumer = anyConsumer; numberConsumer.consume(anyA.value); arktest.assertEQ(a, 11); + tag: negative - desc: Verify the application of contravariance of the in keyword 'in' function parameters. dec1: |- @@ -222,6 +234,7 @@ generic_in_out: arktest.assertEQ(a, 10); numberFunctionWrapper.func(42); arktest.assertEQ(a, 11); + tag: negative - desc: Verify the covariance of the 'out' keyword. dec1: |- @@ -231,4 +244,5 @@ generic_in_out: check: |- const a: A = { value: 'hello' }; const b: A = a; - arktest.assertEQ(b.value, 'hello'); \ No newline at end of file + arktest.assertEQ(b.value, 'hello'); + tag: negative \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out_only_compile.ets b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out_only_compile.ets index 6d01563367..ee3905882a 100644 --- a/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out_only_compile.ets +++ b/static_core/plugins/ets/tests/ets-templates/05.generics/generic_declarations/generic_in_out/generic_in_out_only_compile.ets @@ -17,7 +17,7 @@ /*--- desc: {{case.desc}} -tags: [compile-only, positive] +tags: [compile-only, negative] ---*/ {{case.dec1|indent}} diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/dateformat/IntlDateTimeFormatSupportedLocalesTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/dateformat/IntlDateTimeFormatSupportedLocalesTest.ets index 88ea49d26e..ad72eebca7 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/dateformat/IntlDateTimeFormatSupportedLocalesTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/dateformat/IntlDateTimeFormatSupportedLocalesTest.ets @@ -29,7 +29,7 @@ function testResolvedOptionsRetrieval(): void { function testSupportedLocalesOfStringArray(): void { const requestedLocales = ["en-US-u-hc-h23", "zh-CN", "foo", "en-US"] - const supportedLocales = Intl.DateTimeFormat.supportedLocalesOf(requestedLocales) + const supportedLocales = Intl.DateTimeFormat.supportedLocalesOf(requestedLocales as String|Intl.Locale|ReadonlyArray) arktest.assertEQ(supportedLocales.length, 3) arktest.assertEQ(supportedLocales[0], requestedLocales[0]) @@ -47,7 +47,7 @@ function testSupportedLocalesOfString(): void { function testSupportedLocalesOfLocaleArray(): void { const requestedLocales = [new Intl.Locale("en-US-u-hc-h23"), new Intl.Locale("foo"), new Intl.Locale("zh-CN")] - const supportedLocales = Intl.DateTimeFormat.supportedLocalesOf(requestedLocales) + const supportedLocales = Intl.DateTimeFormat.supportedLocalesOf(requestedLocales as String|Intl.Locale|ReadonlyArray) arktest.assertEQ(supportedLocales.length, 2) arktest.assertEQ(supportedLocales[0], requestedLocales[0].toString()) diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt index 62e49c64c6..8d5b300f9c 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt @@ -69,21 +69,9 @@ #24448 05.generics/01.type_parameters/03.type_parameter_variance/generic_classes/wrong_type_parameter_variance_4.ets - #24444 05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/interface_type_parameter_variance.ets -#24446 -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_0.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_1.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_2.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_3.ets - -#24445 -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_4.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_5.ets -05.generics/01.type_parameters/03.type_parameter_variance/generic_interfaces/wrong_type_parameter_variance_6.ets - #20213 Generic instantiation depends on arguments order 05.generics/02.generic_instantiations/03.implicit_generic_instantiations/func_8.ets 05.generics/02.generic_instantiations/03.implicit_generic_instantiations/meth_8.ets -- Gitee