From c0339d41d70edbe147e2dc81e0826a790bbd232b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=9F=E6=9F=A0?= Date: Thu, 31 Jul 2025 16:05:31 +0800 Subject: [PATCH] fix issue for missingSuperCall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICPZ7O Test scenarios:fix issue for missingSuperCall Signed-off-by: 钟柠 --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 6 ++++++ ...object_literals_properties.ets.arkts2.json | 10 --------- ...bject_literals_properties.ets.autofix.json | 10 --------- ...bject_literals_properties.ets.migrate.json | 20 ------------------ .../linter/test/main/subclass_super_call.ets | 21 +++++++++++++++++++ 5 files changed, 27 insertions(+), 40 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index abf6f3c74c..ce701928ad 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -10387,6 +10387,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } + // If there are only non parametric constructions, do not check. + const value = extendedClassInfo.values().next().value; + if (extendedClassInfo.size === 1 && value && value.length === 0) { + return; + } + this.handleExtendCustomClass(node.parent, extendedClassInfo); } } diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json b/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json index a63a7a849d..918f5f7157 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json @@ -1054,16 +1054,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 216, - "column": 1, - "endLine": 218, - "endColumn": 2, - "problem": "MissingSuperCall", - "suggest": "", - "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", - "severity": "ERROR" - }, { "line": 219, "column": 18, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json index 432b311d06..7ddc642182 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json @@ -1843,16 +1843,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 216, - "column": 1, - "endLine": 218, - "endColumn": 2, - "problem": "MissingSuperCall", - "suggest": "", - "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", - "severity": "ERROR" - }, { "line": 219, "column": 18, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json index 35c8ec6cd0..3272b27a71 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json @@ -284,16 +284,6 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, - { - "line": 272, - "column": 1, - "endLine": 274, - "endColumn": 2, - "problem": "MissingSuperCall", - "suggest": "", - "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", - "severity": "ERROR" - }, { "line": 284, "column": 1, @@ -324,16 +314,6 @@ "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", "severity": "ERROR" }, - { - "line": 301, - "column": 1, - "endLine": 303, - "endColumn": 2, - "problem": "MissingSuperCall", - "suggest": "", - "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", - "severity": "ERROR" - }, { "line": 342, "column": 16, diff --git a/ets2panda/linter/test/main/subclass_super_call.ets b/ets2panda/linter/test/main/subclass_super_call.ets index 2ed960ed90..20947157c1 100644 --- a/ets2panda/linter/test/main/subclass_super_call.ets +++ b/ets2panda/linter/test/main/subclass_super_call.ets @@ -101,3 +101,24 @@ class B extends A { super(EEE.E1) } } + +class A2 { + constructor() { + console.log("Parent constructor") + } +} + +class C2 extends A2 { + // ok 不用报 +} + +class A3 {} + +class C3 extends A3 { + constructor() { + super() + } +} + +class C4 extends A3 { +} \ No newline at end of file -- Gitee