From 271f5a3870dc1a355d858b03a0988fcfe103f870 Mon Sep 17 00:00:00 2001 From: muratcimen_9be2 Date: Wed, 6 Aug 2025 09:34:54 +0300 Subject: [PATCH 1/6] distinct-unsigned-right-shift-negative-number Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQDPB Signed-off-by: muratcimen_9be2 --- ets2panda/linter/rule-config.json | 1 + ets2panda/linter/src/lib/CookBookMsg.ts | 2 + ets2panda/linter/src/lib/FaultAttrs.ts | 1 + ets2panda/linter/src/lib/FaultDesc.ts | 1 + ets2panda/linter/src/lib/Problems.ts | 1 + ets2panda/linter/src/lib/TypeScriptLinter.ts | 36 ++++++++++++ ets2panda/linter/src/lib/utils/TsUtils.ts | 8 +++ .../main/arkts-unsigned-shift-on-negative.ets | 26 +++++++++ ...s-unsigned-shift-on-negative.ets.args.json | 19 ++++++ ...unsigned-shift-on-negative.ets.arkts2.json | 58 +++++++++++++++++++ .../arkts-unsigned-shift-on-negative.ets.json | 18 ++++++ 11 files changed, 171 insertions(+) create mode 100644 ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets create mode 100644 ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.args.json create mode 100644 ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.json diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 2b93ff4869..dc1ab4b18f 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -65,6 +65,7 @@ "arkts-no-sparse-array", "arkts-no-enum-prop-as-type", "arkts-no-ts-like-smart-type", + "arkts-distinct-unsigned-right-shift-negative-number", "arkts-array-type-immutable", "arkts-primitive-type-normalization", "arkts-no-ts-like-catch-type", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 5a1f71ca6e..34bfc2b83c 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -302,6 +302,8 @@ cookBookTag[271] = 'After a variable is declared, a value must be assigned before using it (arkts-var-assignment-before-use)'; cookBookTag[272] = 'This API of process is obsolete in ArkTS 1.1. It\'s no longer supported in ArkTS 1.2 (arkts-concurrent-deprecated-apis)'; +cookBookTag[273] = + 'Unsigned right shift on negative number yields different results in ArkTS versions. (arkts-distinct-unsigned-right-shift-negative-number)'; cookBookTag[274] = 'The subclass constructor must call the parent class\'s parametered constructor (arkts-subclass-must-call-super-constructor-with-args)'; cookBookTag[275] = diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index f5e7fd5c14..d52e47f475 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -206,6 +206,7 @@ faultsAttrs[FaultID.InteropJsObjectExpandStaticInstance] = new FaultAttributes(2 faultsAttrs[FaultID.InteropJSFunctionInvoke] = new FaultAttributes(270); faultsAttrs[FaultID.VariableMissingInitializer] = new FaultAttributes(271); faultsAttrs[FaultID.DeprecatedProcessApi] = new FaultAttributes(272); +faultsAttrs[FaultID.NumericUnsignedShiftBehaviorChange] = new FaultAttributes(273); faultsAttrs[FaultID.MissingSuperCall] = new FaultAttributes(274); faultsAttrs[FaultID.CustomLayoutNeedAddDecorator] = new FaultAttributes(275); faultsAttrs[FaultID.InterfaceFieldNotImplemented] = new FaultAttributes(276); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 2de5c97f1f..5115315600 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -266,6 +266,7 @@ faultDesc[FaultID.UnsupportOperator] = 'Unsupport operator'; faultDesc[FaultID.CustomLayoutNeedAddDecorator] = 'Custom layout need add decorator'; faultDesc[FaultID.InterfaceFieldNotImplemented] = 'All fields must be implemented'; faultDesc[FaultID.NoLocalClass] = 'No local classes'; +faultDesc[FaultID.NumericUnsignedShiftBehaviorChange] = 'No right shift on negative numbers'; faultDesc[FaultID.PropDecoratorNotSupported] = '"@Prop" decorator is not supported'; faultDesc[FaultID.StoragePropDecoratorNotSupported] = '"@StorageProp" decorator is not supported'; faultDesc[FaultID.LocalStoragePropDecoratorNotSupported] = '"@LocalStorageProp" decorator is not supported'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index f5767b4cb2..d607d731b1 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -264,6 +264,7 @@ export enum FaultID { CustomLayoutNeedAddDecorator, InterfaceFieldNotImplemented, NoLocalClass, + NumericUnsignedShiftBehaviorChange, PropDecoratorNotSupported, StoragePropDecoratorNotSupported, LocalStoragePropDecoratorNotSupported, diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 96b6d40538..1fb56b5119 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -2448,6 +2448,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } break; default: + this.handleUnsignedShiftOnNegative(tsBinaryExpr); } this.checkInterOpImportJsDataCompare(tsBinaryExpr); this.checkInteropEqualityJudgment(tsBinaryExpr); @@ -14301,4 +14302,39 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return res; } + + private handleUnsignedShiftOnNegative(node: ts.BinaryExpression): void { + if (!this.options.arkts2) { + return; + } + + if (!TypeScriptLinter.isUnsignedShiftByZero(node)) { + return; + } + + if (TsUtils.isNegativeNumericLiteral(node.left)) { + this.incrementCounters(node, FaultID.NumericUnsignedShiftBehaviorChange); + } + + if (ts.isIdentifier(node.left)) { + const symbol = this.tsTypeChecker.getSymbolAtLocation(node.left); + const decl = symbol?.valueDeclaration; + if (!decl || !ts.isVariableDeclaration(decl)) { + return; + } + + const init = decl.initializer; + if (init && TsUtils.isNegativeNumericLiteral(init)) { + this.incrementCounters(node, FaultID.NumericUnsignedShiftBehaviorChange); + } + } + } + + private static isUnsignedShiftByZero(node: ts.BinaryExpression): boolean { + return ( + node.operatorToken.kind === ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken && + ts.isNumericLiteral(node.right) && + node.right.text === '0' + ); + } } diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 6eafedeaf4..cee4d36aee 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -3879,6 +3879,14 @@ export class TsUtils { } } + static isNegativeNumericLiteral(expr: ts.Expression): boolean { + return ( + ts.isPrefixUnaryExpression(expr) && + expr.operator === ts.SyntaxKind.MinusToken && + ts.isNumericLiteral(expr.operand) + ); + } + isNumberArrayType(type: ts.Type): boolean { if (!type.symbol || !this.isGenericArrayType(type)) { return false; diff --git a/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets new file mode 100644 index 0000000000..2841e80f91 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let a = -123; +let b = 456; +let c = -789; + +let r1 = -123 >>> 0; // error +let r2 = a >>> 0; // error +let r3 = b >>> 0; // valid +let r4 = c >>> 0; // error + +let d = -1; +let r5 = d >>> 0; // error diff --git a/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.args.json b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.args.json new file mode 100644 index 0000000000..d8d3390ad9 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 2025 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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.arkts2.json b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.arkts2.json new file mode 100644 index 0000000000..3862e0bc09 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.arkts2.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 2025 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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 20, + "problem": "NumericUnsignedShiftBehaviorChange", + "suggest": "", + "rule": "Unsigned right shift on negative number yields different results in ArkTS versions. (arkts-distinct-unsigned-right-shift-negative-number)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 10, + "endLine": 21, + "endColumn": 17, + "problem": "NumericUnsignedShiftBehaviorChange", + "suggest": "", + "rule": "Unsigned right shift on negative number yields different results in ArkTS versions. (arkts-distinct-unsigned-right-shift-negative-number)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 17, + "problem": "NumericUnsignedShiftBehaviorChange", + "suggest": "", + "rule": "Unsigned right shift on negative number yields different results in ArkTS versions. (arkts-distinct-unsigned-right-shift-negative-number)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 10, + "endLine": 26, + "endColumn": 17, + "problem": "NumericUnsignedShiftBehaviorChange", + "suggest": "", + "rule": "Unsigned right shift on negative number yields different results in ArkTS versions. (arkts-distinct-unsigned-right-shift-negative-number)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.json b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.json new file mode 100644 index 0000000000..895325b061 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-unsigned-shift-on-negative.ets.json @@ -0,0 +1,18 @@ +{ + "copyright": [ + "Copyright (c) 2025 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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + ] +} \ No newline at end of file -- Gitee From 50897f9de2cd099bddeb62ad52309d8d90a4b48a Mon Sep 17 00:00:00 2001 From: Utku Enes GURSEL Date: Tue, 5 Aug 2025 15:52:44 +0300 Subject: [PATCH 2/6] not-support-tuple-generic-validation Issue: ICNZEN Description: Add arkts-not-support-tuple-generic-validation rule. Signed-off-by: Utku Enes GURSEL --- ets2panda/linter/package.json | 5 ++- ets2panda/linter/src/lib/CookBookMsg.ts | 3 +- ets2panda/linter/src/lib/FaultDesc.ts | 3 +- ets2panda/linter/src/lib/TypeScriptLinter.ts | 39 ++++++++++++++++++- ...t-tuple-generic-validation.ets.arkts2.json | 8 ++-- .../linter/test/taskpool/taskpool_execute.ets | 24 ++++++++++++ .../taskpool/taskpool_execute.ets.args.json | 19 +++++++++ .../taskpool/taskpool_execute.ets.arkts2.json | 28 +++++++++++++ .../test/taskpool/taskpool_execute.ets.json | 17 ++++++++ 9 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 ets2panda/linter/test/taskpool/taskpool_execute.ets create mode 100644 ets2panda/linter/test/taskpool/taskpool_execute.ets.args.json create mode 100644 ets2panda/linter/test/taskpool/taskpool_execute.ets.arkts2.json create mode 100644 ets2panda/linter/test/taskpool/taskpool_execute.ets.json diff --git a/ets2panda/linter/package.json b/ets2panda/linter/package.json index c31c058543..8005b79486 100644 --- a/ets2panda/linter/package.json +++ b/ets2panda/linter/package.json @@ -20,12 +20,13 @@ "pack:linter": "rimraf bundle && mkdir bundle && npm pack && mv panda-tslinter-*.tgz bundle", "pretest": " npm run fix", "test": "npm run test_all && npm run test_ts_import_ets", - "test_all": "npm run testrunner -- -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin,test/deprecatedapi,test/sdkcommonapi", + "test_all": "npm run testrunner -- -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin,test/deprecatedapi, test/taskpool,test/sdkcommonapi", "test_main": "npm run testrunner -- -d test/main", "test_ohmurl": "npm run testrunner -- -d test/ohmurl", "test_interop": "npm run testrunner -- -d test/interop", "test_sdk": "npm run testrunner -- -d test/sdkwhite", "test_deprecatedapi": "npm run testrunner -- -d test/deprecatedapi", + "test_taskpool": "npm run testrunner -- -d test/taskpool", "test_sdkcommonapi": "npm run testrunner -- -d test/sdkcommonapi", "test_concurrent": "npm run testrunner -- -d test/concurrent", "test_rules": "npm run testrunner -- -d test/rules", @@ -38,7 +39,7 @@ "test_ts_import_ets": "npm run testrunner -- -d test/ts_import_ets/ts --sdk --interop-mode", "test_migration": "npm run testrunner -- -d test/migration", "testrunner": "npm run compile && node build/testRunner/TestRunner.js", - "update-tests": "node scripts/update-test-results.mjs test/main test/rules test/regression test/extended_features test/ts_import_ets/ts test/migration test/ohmurl test/interop test/sdkwhite test/concurrent test/builtin test/deprecatedapi test/sdkcommonapi", + "update-tests": "node scripts/update-test-results.mjs test/main test/rules test/regression test/extended_features test/ts_import_ets/ts test/migration test/ohmurl test/interop test/sdkwhite test/concurrent test/builtin test/deprecatedapi test/sdkcommonapi test/taskpool", "eslint-check": "npx eslint .", "eslint-fix": "npm run eslint-check -- --fix", "prettier-fix": "npx prettier --write .", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 34bfc2b83c..4d5245cdc2 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -318,8 +318,7 @@ cookBookTag[284] = '"prop" function is not supported (arkui-no-prop-function)'; cookBookTag[285] = '"setAndProp" function is not supported (arkui-no-setandprop-function)'; cookBookTag[286] = 'Parameters decorated with "@Prop" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)'; -cookBookTag[290] = - 'Tuple type cannot be used in generic type parameters of Promise static methods (arkts-not-support-tuple-generic-validation)'; +cookBookTag[290] = 'Tuple type cannot be used in generic type parameters (arkts-not-support-tuple-generic-validation)'; cookBookTag[300] = 'The function type should be explicit (arkts-no-ts-like-function-call)'; cookBookTag[301] = 'Importing from "oh module" requires specifying full path (arkts-require-fullpath-name)'; cookBookTag[302] = diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 5115315600..d2753c7fb5 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -174,8 +174,7 @@ faultDesc[FaultID.InteropJsObjectConditionJudgment] = 'Interop JS Object usage i faultDesc[FaultID.InteropJsObjectExpandStaticInstance] = 'Interop JS function usage'; faultDesc[FaultID.InteropJSFunctionInvoke] = 'Interop JS function invoke'; faultDesc[FaultID.VariableMissingInitializer] = 'Value must be assigned to variable'; -faultDesc[FaultID.NotSupportTupleGenericValidation] = - 'Tuple type cannot be used in generic type parameters of Promise static methods'; +faultDesc[FaultID.NotSupportTupleGenericValidation] = 'No Tuple type in Generic'; faultDesc[FaultID.DeprecatedProcessApi] = 'This process Api no longer supported in ArkTS 1.2'; faultDesc[FaultID.ExplicitFunctionType] = 'Not explicit function type'; faultDesc[FaultID.ClassstaticInitialization] = 'The static properties of a class need to have initial values'; diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 1fb56b5119..13e635fccb 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -19,7 +19,13 @@ import { FaultID } from './Problems'; import { TypeScriptLinterConfig } from './TypeScriptLinterConfig'; import type { Autofix } from './autofixes/Autofixer'; import { Autofixer } from './autofixes/Autofixer'; -import { PROMISE_METHODS, PROMISE_METHODS_WITH_NO_TUPLE_SUPPORT, SYMBOL, SYMBOL_CONSTRUCTOR, TsUtils } from './utils/TsUtils'; +import { + PROMISE_METHODS, + PROMISE_METHODS_WITH_NO_TUPLE_SUPPORT, + SYMBOL, + SYMBOL_CONSTRUCTOR, + TsUtils +} from './utils/TsUtils'; import { FUNCTION_HAS_NO_RETURN_ERROR_CODE } from './utils/consts/FunctionHasNoReturnErrorCode'; import { LIMITED_STANDARD_UTILITY_TYPES, @@ -5429,6 +5435,37 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleNoDeprecatedApi(tsCallExpr); this.handleFunctionReturnThisCall(tsCallExpr); this.handlePromiseTupleGeneric(tsCallExpr); + this.handleTupleGeneric(tsCallExpr); + } + + private handleTupleGeneric(callExpr: ts.CallExpression): void { + if (!this.options.arkts2) { + return; + } + if (!ts.isPropertyAccessExpression(callExpr.expression)) { + return; + } + const accessedProperty = callExpr.expression; + + if (!ts.isIdentifier(accessedProperty.expression)) { + return; + } + + if (accessedProperty.expression.text !== TASKPOOL) { + return; + } + + if (!callExpr.typeArguments) { + return; + } + + if (callExpr.parent) { + callExpr.typeArguments.forEach((node) => { + if (ts.isTupleTypeNode(node)) { + this.incrementCounters(node, FaultID.NotSupportTupleGenericValidation); + } + }); + } } private handleCallExpressionForUI(node: ts.CallExpression): void { diff --git a/ets2panda/linter/test/main/arkts-not-support-tuple-generic-validation.ets.arkts2.json b/ets2panda/linter/test/main/arkts-not-support-tuple-generic-validation.ets.arkts2.json index 52c316a716..e61aa4ff7a 100644 --- a/ets2panda/linter/test/main/arkts-not-support-tuple-generic-validation.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-not-support-tuple-generic-validation.ets.arkts2.json @@ -41,7 +41,7 @@ "endColumn": 47, "problem": "NotSupportTupleGenericValidation", "suggest": "", - "rule": "Tuple type cannot be used in generic type parameters of Promise static methods (arkts-not-support-tuple-generic-validation)", + "rule": "Tuple type cannot be used in generic type parameters (arkts-not-support-tuple-generic-validation)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 47, "problem": "NotSupportTupleGenericValidation", "suggest": "", - "rule": "Tuple type cannot be used in generic type parameters of Promise static methods (arkts-not-support-tuple-generic-validation)", + "rule": "Tuple type cannot be used in generic type parameters (arkts-not-support-tuple-generic-validation)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 48, "problem": "NotSupportTupleGenericValidation", "suggest": "", - "rule": "Tuple type cannot be used in generic type parameters of Promise static methods (arkts-not-support-tuple-generic-validation)", + "rule": "Tuple type cannot be used in generic type parameters (arkts-not-support-tuple-generic-validation)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 54, "problem": "NotSupportTupleGenericValidation", "suggest": "", - "rule": "Tuple type cannot be used in generic type parameters of Promise static methods (arkts-not-support-tuple-generic-validation)", + "rule": "Tuple type cannot be used in generic type parameters (arkts-not-support-tuple-generic-validation)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/taskpool/taskpool_execute.ets b/ets2panda/linter/test/taskpool/taskpool_execute.ets new file mode 100644 index 0000000000..f50a174b03 --- /dev/null +++ b/ets2panda/linter/test/taskpool/taskpool_execute.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function printArgs(args: number): number { + console.info(""printArgs: "" + args); + return args; +} + +taskpool.execute<[number], number>(printArgs, 100).then((value: number) => { + console.info(""taskpool result: "" + value); +}); + diff --git a/ets2panda/linter/test/taskpool/taskpool_execute.ets.args.json b/ets2panda/linter/test/taskpool/taskpool_execute.ets.args.json new file mode 100644 index 0000000000..bc4d2071da --- /dev/null +++ b/ets2panda/linter/test/taskpool/taskpool_execute.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 2025 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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "" + } +} diff --git a/ets2panda/linter/test/taskpool/taskpool_execute.ets.arkts2.json b/ets2panda/linter/test/taskpool/taskpool_execute.ets.arkts2.json new file mode 100644 index 0000000000..2b96bc02fd --- /dev/null +++ b/ets2panda/linter/test/taskpool/taskpool_execute.ets.arkts2.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 2025 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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 21, + "column": 18, + "endLine": 21, + "endColumn": 26, + "problem": "NotSupportTupleGenericValidation", + "suggest": "", + "rule": "Tuple type cannot be used in generic type parameters (arkts-not-support-tuple-generic-validation)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/taskpool/taskpool_execute.ets.json b/ets2panda/linter/test/taskpool/taskpool_execute.ets.json new file mode 100644 index 0000000000..9f305c86d7 --- /dev/null +++ b/ets2panda/linter/test/taskpool/taskpool_execute.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} -- Gitee From 06e7301e6d6b07aa8c7b30cb9996856b72a4e579 Mon Sep 17 00:00:00 2001 From: cihatfurkaneken Date: Wed, 6 Aug 2025 15:00:57 +0300 Subject: [PATCH 3/6] fix no-inferred-generic-params rule autofix Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICRL8A Signed-off-by: cihatfurkaneken --- .../linter/src/lib/autofixes/Autofixer.ts | 3 ++- .../test/main/func_inferred_type_args_2.ets | 4 ++++ .../func_inferred_type_args_2.ets.arkts2.json | 10 +++++++++ ...func_inferred_type_args_2.ets.autofix.json | 21 +++++++++++++++++++ .../func_inferred_type_args_2.ets.migrate.ets | 4 ++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 3789d7c2b9..3ef2aba012 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -4971,6 +4971,7 @@ export class Autofixer { } return `<${typeArg. map((arg) => { + ts.setEmitFlags(arg, ts.EmitFlags.SingleLine); return this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, arg, sourceFile); }). join(', ')}>`; @@ -4978,7 +4979,7 @@ export class Autofixer { if (!typeArg || !this.isTypeArgumentAccessible(sourceFile, typeArg as ts.TypeNode)) { return undefined; } - + ts.setEmitFlags(typeArg as ts.TypeNode, ts.EmitFlags.SingleLine); return `<${this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, typeArg as ts.TypeNode, sourceFile)}>`; } diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets b/ets2panda/linter/test/main/func_inferred_type_args_2.ets index 80246fcd42..43830e5da0 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets @@ -118,3 +118,7 @@ class SubWeakMap extends WeakMap{} let subWeakMap = new SubWeakMap(); class SubWeakSet extends WeakSet{} let subWeakSet = new SubWeakSet(); + +class C {} +class D {} +let a: D<[C]> = new D(); \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json index 582bf2a455..788aaf8aaa 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.arkts2.json @@ -524,6 +524,16 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 124, + "column": 17, + "endLine": 124, + "endColumn": 24, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, { "line": 84, "column": 2, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json index 4b652fc080..6d8c8403ac 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json @@ -766,6 +766,27 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 124, + "column": 17, + "endLine": 124, + "endColumn": 24, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 3313, + "end": 3313, + "replacementText": "<[C]>", + "line": 124, + "column": 17, + "endLine": 124, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, { "line": 84, "column": 2, diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets index 541aea7351..3cfe89eaab 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.migrate.ets @@ -125,3 +125,7 @@ class SubWeakMap extends WeakMap{} let subWeakMap = new SubWeakMap(); class SubWeakSet extends WeakSet{} let subWeakSet = new SubWeakSet(); + +class C {} +class D {} +let a: D<[C]> = new D<[C]>(); \ No newline at end of file -- Gitee From c89a7f88df9a2905ac07c0511aa9451c3a6ec829 Mon Sep 17 00:00:00 2001 From: ZhongNing Date: Tue, 5 Aug 2025 19:42:50 +0800 Subject: [PATCH 4/6] fix arkts-method-inherit-rule_ICQYZZ Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQYZZ Test scenarios: fix bug Signed-off-by: ZhongNing --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 58 +++++++++++++- ...exable_type_element_access.ets.arkts2.json | 20 +++++ ...type_string_element_access.ets.arkts2.json | 13 ++- .../linter/test/main/method_inheritance3.ets | 80 +++++++++++++++++++ .../main/method_inheritance3.ets.arkts2.json | 10 +++ .../test/main/stdlib_array.ets.arkts2.json | 40 ++++++++++ 6 files changed, 218 insertions(+), 3 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 13e635fccb..a0895253f5 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -4269,7 +4269,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.isTypeSameOrWider(baseParamType, derivedParamType)) { this.incrementCounters(derivedParams[i], FaultID.MethodInheritRule); - } + } } } @@ -4379,7 +4379,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return true; } - if (derivedType.flags & ts.TypeFlags.Any) { + if (derivedType.flags & ts.TypeFlags.Any || baseType.flags & ts.TypeFlags.Never) { return true; } @@ -4398,6 +4398,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return true; } + if (this.checkTypeInheritance(derivedType, baseType, false)) { + return true; + } + const baseTypeSet = new Set(this.flattenUnionTypes(baseType)); const derivedTypeSet = new Set(this.flattenUnionTypes(derivedType)); @@ -4431,6 +4435,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + if(this.checkTypeInheritance(fromType, toType)) { + return true; + } + const fromTypes = this.flattenUnionTypes(fromType); const toTypes = new Set(this.flattenUnionTypes(toType)); @@ -4442,6 +4450,52 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }); } + private checkTypeInheritance( + sourceType: ts.Type, + targetType: ts.Type, + isSouceTotaqrget: boolean = true + ): boolean { + // Early return if either type lacks symbol information + if (!sourceType.symbol || !targetType.symbol) { + return false; + } + + // Determine which type's inheritance chain to examine based on check direction + const typeToGetChain = isSouceTotaqrget ? sourceType : targetType; + const typeToCheck = isSouceTotaqrget ? targetType : sourceType; + + // Get inheritance chain and check for relationship + const inheritanceChain = this.getTypeInheritanceChain(typeToGetChain); + return inheritanceChain.some(t => { + return t.symbol === typeToCheck.symbol; + }); + } + + private getTypeInheritanceChain(type: ts.Type): ts.Type[] { + const chain: ts.Type[] = [type]; + const declarations = type.symbol?.getDeclarations() || []; + + for (const declaration of declarations) { + if ((!ts.isClassDeclaration(declaration) && !ts.isInterfaceDeclaration(declaration)) || + !declaration.heritageClauses) { + continue; + } + + const heritageClauses = declaration.heritageClauses.filter(clause => { + return clause.token === ts.SyntaxKind.ExtendsKeyword || clause.token === ts.SyntaxKind.ImplementsKeyword; + }); + + for (const clause of heritageClauses) { + for (const typeExpr of clause.types) { + const baseType = this.tsTypeChecker.getTypeAtLocation(typeExpr.expression); + chain.push(baseType, ...this.getTypeInheritanceChain(baseType)); + } + } + } + + return chain; + } + // Check if a type string has an equivalent primitive/wrapper type in a set private static areWrapperAndPrimitiveTypesEqual(typeStr: string, typeSet: Set): boolean { const typePairs = [ diff --git a/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json b/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json index 7345e0b15f..32eb4db5dd 100644 --- a/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json +++ b/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 18, + "column": 12, + "endLine": 18, + "endColumn": 16, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 23, "column": 1, @@ -33,6 +43,16 @@ "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" + }, + { + "line": 34, + "column": 12, + "endLine": 34, + "endColumn": 16, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json b/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json index 3ee4a5b916..8e46ce7166 100644 --- a/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json +++ b/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 17, + "column": 45, + "endLine": 17, + "endColumn": 49, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets b/ets2panda/linter/test/main/method_inheritance3.ets index d31da9911b..d4b5b6b18e 100755 --- a/ets2panda/linter/test/main/method_inheritance3.ets +++ b/ets2panda/linter/test/main/method_inheritance3.ets @@ -60,4 +60,84 @@ class EntryAbility extends UIAbility { } catch (e) { } } +} + +class TestA { + a: number = 0 +} + +class TestD extends TestA{ + a: number = 0; + b: number = 1; +} + +class TestE implements TestI{ + +} + +class TestF extends TestE{ + +} +interface TestI{ + +} + +interface TestI2 extends TestI{ + +} +class TestBase { + foo3(obj: TestD): void { + console.log("Derived:" + obj.b) + } + + foo4(obj: TestD): TestA { + console.log("base" ); + return new TestA() + } + + foo5():TestI{ + return {} + } + + foo12(obj:never){ + + } +} + +class TestDerived extends TestBase { + override foo3(obj: TestA): void { // no error + console.log("base" ); + } + + override foo4(obj: TestA): TestD { // no error + return new TestD(); + } + + override foo5(): TestI2 { // no error + return {} + } + + override foo12(obj:TestA){ // no error + + } +} + +class CC1 {} +class CC2 extends CC1 { + public static toString(result: number): string { // no error + return ''; + } +} + +class AA{ + getData(a:T):T{ + + return a; + } +} + +class BB extends AA{ + getData(a: number): number { // no error + return 123; + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json index c163f337bf..6fd8017e32 100755 --- a/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance3.ets.arkts2.json @@ -34,6 +34,16 @@ "rule": "\"void\" operator is not supported (arkts-no-void-operator)", "severity": "ERROR" }, + { + "line": 127, + "column": 3, + "endLine": 129, + "endColumn": 4, + "problem": "NoSignatureDistinctWithObjectPublicApi", + "suggest": "", + "rule": "The signature of a method in a class/interface cannot be different from the public interface in an object. (arkts-class-no-signature-distinct-with-object-public-api)", + "severity": "ERROR" + }, { "line": 44, "column": 18, diff --git a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json index c519ba8f63..cd5487e484 100644 --- a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 18, + "column": 48, + "endLine": 18, + "endColumn": 52, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 21, "column": 18, @@ -34,6 +44,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 22, + "column": 56, + "endLine": 22, + "endColumn": 60, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 25, "column": 18, @@ -44,6 +64,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 26, + "column": 54, + "endLine": 26, + "endColumn": 58, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 29, "column": 18, @@ -54,6 +84,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 30, + "column": 52, + "endLine": 30, + "endColumn": 56, + "problem": "IncompationbleFunctionType", + "suggest": "", + "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", + "severity": "ERROR" + }, { "line": 36, "column": 18, -- Gitee From b432288dcb093fa19cf3462a081433b902477b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=9F=E6=9F=A0?= Date: Sat, 2 Aug 2025 09:18:43 +0800 Subject: [PATCH 5/6] fix issue for arkts-incompatible-function-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQ73S Test scenarios:fix issue for arkts-incompatible-function-types Signed-off-by: 钟柠 --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 5 ++++- ets2panda/linter/src/lib/utils/TsUtils.ts | 18 +++++++++++++++ .../test/main/incompatible_function.ets | 22 +++++++++++++++++++ .../incompatible_function.ets.arkts2.json | 20 ++++++++--------- 4 files changed, 54 insertions(+), 11 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index a0895253f5..6aec29591a 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -3998,7 +3998,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isClassDeclaration(classDecl)) { return; } - this.checkIncompatibleFunctionTypes(node); const isStatic = node.modifiers?.some((mod) => { return mod.kind === ts.SyntaxKind.StaticKeyword; @@ -4013,6 +4012,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (allBaseTypes && allBaseTypes.length > 0) { this.checkMethodType(allBaseTypes, methodName, node, isStatic); } + this.checkIncompatibleFunctionTypes(node); } private checkMethodType( @@ -4077,6 +4077,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (declaredReturnTypeStr === actualReturnTypeStr) { return; } + if (this.tsUtils.skipCheckForArrayBufferLike(declaredReturnTypeStr, actualReturnTypeStr)) { + return; + } if (actualReturnType.flags & ts.TypeFlags.Any || declaredReturnType.flags & ts.TypeFlags.Any) { return; } diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index cee4d36aee..fbc408c87e 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -804,6 +804,9 @@ export class TsUtils { if (this.skipStructuralTypingCheckForFunctionals(lhsType, rhsType)) { return false; } + if (this.skipCheckForArrayBufferLike(lhsType, rhsType)) { + return false; + } if (rhsType.isUnion() || lhsType.isUnion()) { return this.needToDeduceStructuralIdentityHandleUnions(lhsType, rhsType, rhsExpr, isStrict); } @@ -900,6 +903,16 @@ export class TsUtils { return isStrictLhs && this.typeContainsNonSendableClassOrInterface(rhsType); } + skipCheckForArrayBufferLike(lhsType: string | ts.Type, rhsType: string | ts.Type): boolean { + const lhsIsArrayBufferLike = TsUtils.isArrayBufferType( + typeof lhsType === 'string' ? lhsType : this.tsTypeChecker.typeToString(lhsType) + ); + const rhsIsArrayBufferLike = TsUtils.isArrayBufferType( + typeof rhsType === 'string' ? rhsType : this.tsTypeChecker.typeToString(rhsType) + ); + return !!this.options.arkts2 && lhsIsArrayBufferLike && rhsIsArrayBufferLike; + } + private processExtendedParentTypes(typeA: ts.Type, typeB: ts.Type): boolean { /* @@ -2114,6 +2127,11 @@ export class TsUtils { return callSigns && callSigns.length > 0; } + static isArrayBufferType(typeStr: string): boolean { + const arrayBufferLikeArr = ['ArrayBuffer', 'ArrayBufferLike']; + return arrayBufferLikeArr.includes(typeStr); + } + static getFunctionalTypeSignature(type: ts.Type): ts.Signature | undefined { const callSigns = type.getCallSignatures(); if (callSigns.length > 0) { diff --git a/ets2panda/linter/test/main/incompatible_function.ets b/ets2panda/linter/test/main/incompatible_function.ets index db3f4250b7..4330949c71 100644 --- a/ets2panda/linter/test/main/incompatible_function.ets +++ b/ets2panda/linter/test/main/incompatible_function.ets @@ -112,4 +112,26 @@ for (let i = 0; i < totalPromises; i++) { }, delay) ) ); +} + +class D { + fun(a: ArrayBufferLike): ArrayBuffer { + return a; + } +} + +class X { + n: number = 0 + s: string = '' +} + +class Y { + n: number = 0 + s: string = '' +} + +class E { + Dfun(a: X|Y): X { + return a; + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json b/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json index 1a8bca46e8..31c19f7df3 100644 --- a/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json +++ b/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json @@ -84,16 +84,6 @@ "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", "severity": "ERROR" }, - { - "line": 92, - "column": 12, - "endLine": 92, - "endColumn": 20, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - }, { "line": 92, "column": 12, @@ -123,6 +113,16 @@ "suggest": "", "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", "severity": "ERROR" + }, + { + "line": 135, + "column": 12, + "endLine": 135, + "endColumn": 13, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)", + "severity": "ERROR" } ] } \ No newline at end of file -- Gitee From 538cf4ff7ab8b90c0d5e1cb0022403d87041c6a3 Mon Sep 17 00:00:00 2001 From: ZhongNing Date: Fri, 1 Aug 2025 17:56:32 +0800 Subject: [PATCH 6/6] Fix for MethodInheritRule Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICQFBY Test scenarios: Fix Bug Signed-off-by: ZhongNing --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 2 +- ...exable_type_element_access.ets.arkts2.json | 20 -- ...type_string_element_access.ets.arkts2.json | 41 +-- .../linter/test/main/method_inheritance2.ets | 243 +++++++++++++- .../main/method_inheritance2.ets.arkts2.json | 304 +++++++++++++++++- .../test/main/stdlib_array.ets.arkts2.json | 40 --- 6 files changed, 541 insertions(+), 109 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 6aec29591a..2658cb6a0d 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -4054,7 +4054,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private isSameDeclarationType(decl: ts.Node, type: ts.Type, isStatic: boolean): boolean { - if (isStatic && ts.isClassDeclaration(decl)) { + if (isStatic && ts.isClassDeclaration(decl) || ts.isInterfaceDeclaration(decl)) { const staticType = this.tsTypeChecker.getTypeAtLocation(decl); return this.isSameType(staticType, type); } diff --git a/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json b/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json index 32eb4db5dd..7345e0b15f 100644 --- a/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json +++ b/ets2panda/linter/test/main/indexable_type_element_access.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 18, - "column": 12, - "endLine": 18, - "endColumn": 16, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - }, { "line": 23, "column": 1, @@ -43,16 +33,6 @@ "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" - }, - { - "line": 34, - "column": 12, - "endLine": 34, - "endColumn": 16, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json b/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json index 8e46ce7166..ff51cef36a 100644 --- a/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json +++ b/ets2panda/linter/test/main/indexable_type_string_element_access.ets.arkts2.json @@ -1,28 +1,17 @@ { - "copyright": [ - "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", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 45, - "endLine": 17, - "endColumn": 49, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - } - ] + "copyright": [ + "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", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance2.ets b/ets2panda/linter/test/main/method_inheritance2.ets index e4f9112258..1f8bd03783 100755 --- a/ets2panda/linter/test/main/method_inheritance2.ets +++ b/ets2panda/linter/test/main/method_inheritance2.ets @@ -63,14 +63,14 @@ interface BaseI2 { // T implements class DerivedI2 implements BaseI2 { - foo(obj: A): void { - console.log("Drived"); // (arkts-method-inherit-rule) error + foo(obj: A): void { // (arkts-method-inherit-rule) error + console.log("Derived"); } - foo2(): void { - console.log("Drived"); // (arkts-method-inherit-rule) error + foo2(): void { // (arkts-method-inherit-rule) error + console.log("Derived"); } - foo3(obj: A | B): void { - console.log("Drived"); // (arkts-method-inherit-rule) error + foo3(obj: A | B): void { // (arkts-method-inherit-rule) error + console.log("Derived"); } } @@ -121,6 +121,233 @@ interface I{ } class J implements I{ - pp(key: string,value?:string):void { // 漏报arkts-method-inherit-rule + pp(key: string,value?:string):void { // arkts-method-inherit-rule } -} \ No newline at end of file +} + +interface BaseI { + foo(): A|B ; + foo2(): void; + foo3(): A; +} + +class Derived2 implements BaseI { + foo(): A|B|C{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo2(): A{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo3(): A|B { // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } +} + +let b2:BaseI = new Derived2(); +b2.foo(); +b2.foo2() +b2.foo3() + + +class Base32 { + foo(): A|B { + console.log("base") + return new A(); + } + foo2():void{ + console.log("base") + // return new A(); + } + foo3(): A { + console.log("base") + return new A(); + } + foo4(){ + console.log("base") + // return new A(); + } +} + +class Derived32 extends Base32 { + foo(): A|B|C{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo2(): A{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo3(): A|B { // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo4(): A{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } +} + +interface BaseI4 { + foo(): A|B ; + foo2(): void; + foo3(): A; +} + +class Derived4 implements BaseI4 { + foo(): A|B|C{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo2(): A{ // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } + + foo3(): A|B { // (arkts-method-inherit-rule) + console.log("Derived:") + return new A(); + } +} + +class Animal {} +class Dog extends Animal {} +class Base55 { + public foo(obj: Animal): void { + console.log("base") + } +} + +class Derived55 extends Base55 { + public foo(obj: Dog): void { // (arkts-method-inherit-rule) + console.log("Derived:") + } +} + +class Base6 { + public foo(): Dog { + console.log("base") + return new Dog(); + } +} + +class Derived6 extends Base6 { + public foo(): Animal { // (arkts-method-inherit-rule) + console.log("Derived:") + return new Animal() + } +} + +abstract class Base66{ + abstract foo(); + abstract foo1(); +} + +abstract class Derived66 extends Base66{ + async foo(){ // (arkts-method-inherit-rule) + + } + foo1(): number { // (arkts-method-inherit-rule)? + return 1 + } +} +class Base7{ + foo(){ + + } +} +class Derived7 extends Base7{ + foo(): number { // (arkts-method-inherit-rule) + return 12; + } +} +class Base44 { + public foo(obj: A | B): void { + console.log("base") + } + protected foo2(obj: A | B): void { + console.log("base") + } + async foo3(obj: A | B | C): Promise { + console.log("base") + } +} + +class Derived44 extends Base44 { + public foo(obj: A): void { // (arkts-method-inherit-rule) + console.log("Derived:" + obj.a) + } + protected foo2(): void { // (arkts-method-inherit-rule) + console.log("Derived:") + } + async foo3(obj: A | B): Promise { // (arkts-method-inherit-rule) + console.log("Derived:") + } +} +class Base { + foo(obj: A | B): void { + console.log("base") + } + foo2(obj: A | B): void { + console.log("base") + } + foo3(obj: A | B | C): void { + console.log("base") + } + foo4(obj: A): void { + console.log("base" ); + } +} +class Derived extends Base { + foo(obj: A): void { // (arkts-method-inherit-rule) + console.log("Derived:" + obj.a) + } + foo2(): void { // (arkts-method-inherit-rule) + console.log("Derived:") + } + foo3(obj: A | B): void { // (arkts-method-inherit-rule) + console.log("Derived:") + } + foo4(obj: D): void { // (arkts-method-inherit-rule) + console.log("Derived:" + obj.b) + } +} +class Derived_Derived extends Derived { + foo(): void { // (arkts-method-inherit-rule) + } + + foo3(obj: A): void { // (arkts-method-inherit-rule) + console.log("Derived:") + } +} + +let b:Base = new Derived(); +b.foo(new B()); +b.foo2(new B()) + +interface BaseI22 { + foo(obj: A | B):void; + foo2(obj: A ): void; + foo3(obj: A | B | C): void; +} + +class Derived22 implements BaseI22 { + foo(obj: A): void { // (arkts-method-inherit-rule) + console.log("Derived"); + } + foo2(): void { // (arkts-method-inherit-rule) + console.log("Derived"); + } + foo3(obj: A | B): void { // (arkts-method-inherit-rule) + console.log("Derived"); + } +} +let b22 :BaseI = new Derived2(); \ No newline at end of file diff --git a/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json index 54e9fda0ff..4e6f89111a 100755 --- a/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance2.ets.arkts2.json @@ -1,18 +1,4 @@ { - "copyright": [ - "Copyright (c) 2025 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", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], "result": [ { "line": 46, @@ -44,6 +30,36 @@ "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, + { + "line": 66, + "column": 10, + "endLine": 66, + "endColumn": 16, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 3, + "endLine": 69, + "endColumn": 7, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 11, + "endLine": 72, + "endColumn": 21, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, { "line": 98, "column": 17, @@ -93,6 +109,266 @@ "suggest": "", "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" + }, + { + "line": 135, + "column": 10, + "endLine": 135, + "endColumn": 15, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 11, + "endLine": 140, + "endColumn": 12, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 145, + "column": 11, + "endLine": 145, + "endColumn": 14, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 177, + "column": 13, + "endLine": 177, + "endColumn": 18, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 182, + "column": 14, + "endLine": 182, + "endColumn": 15, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 187, + "column": 14, + "endLine": 187, + "endColumn": 17, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 192, + "column": 14, + "endLine": 192, + "endColumn": 15, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 205, + "column": 13, + "endLine": 205, + "endColumn": 18, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 210, + "column": 14, + "endLine": 210, + "endColumn": 15, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 215, + "column": 14, + "endLine": 215, + "endColumn": 17, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 230, + "column": 14, + "endLine": 230, + "endColumn": 22, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 243, + "column": 17, + "endLine": 243, + "endColumn": 23, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 255, + "column": 9, + "endLine": 255, + "endColumn": 12, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 268, + "column": 10, + "endLine": 268, + "endColumn": 16, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 285, + "column": 14, + "endLine": 285, + "endColumn": 20, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 288, + "column": 13, + "endLine": 288, + "endColumn": 17, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 291, + "column": 14, + "endLine": 291, + "endColumn": 24, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 310, + "column": 7, + "endLine": 310, + "endColumn": 13, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 313, + "column": 3, + "endLine": 313, + "endColumn": 7, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 316, + "column": 8, + "endLine": 316, + "endColumn": 18, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 319, + "column": 8, + "endLine": 319, + "endColumn": 14, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 324, + "column": 3, + "endLine": 324, + "endColumn": 6, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 327, + "column": 8, + "endLine": 327, + "endColumn": 14, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 343, + "column": 7, + "endLine": 343, + "endColumn": 13, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 346, + "column": 3, + "endLine": 346, + "endColumn": 7, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 349, + "column": 8, + "endLine": 349, + "endColumn": 18, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json index cd5487e484..c519ba8f63 100644 --- a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json @@ -24,16 +24,6 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, - { - "line": 18, - "column": 48, - "endLine": 18, - "endColumn": 52, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - }, { "line": 21, "column": 18, @@ -44,16 +34,6 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, - { - "line": 22, - "column": 56, - "endLine": 22, - "endColumn": 60, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - }, { "line": 25, "column": 18, @@ -64,16 +44,6 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, - { - "line": 26, - "column": 54, - "endLine": 26, - "endColumn": 58, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - }, { "line": 29, "column": 18, @@ -84,16 +54,6 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, - { - "line": 30, - "column": 52, - "endLine": 30, - "endColumn": 56, - "problem": "IncompationbleFunctionType", - "suggest": "", - "rule": "Stricter assignments into variables of function type (arkts-incompatible-function-types)", - "severity": "ERROR" - }, { "line": 36, "column": 18, -- Gitee