diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 666921f9426e589133e7af1359b8685f52062996..447a600f588668951f6e6b8c1f526ae5c0f33688 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -3649,7 +3649,7 @@ 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; @@ -3663,7 +3663,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (allBaseTypes && allBaseTypes.length > 0) { this.checkMethodType(allBaseTypes, methodName, node); } - this.checkIncompatibleFunctionTypes(node); } private checkMethodType(allBaseTypes: ts.Type[], methodName: string, node: ts.MethodDeclaration): void { @@ -3708,6 +3707,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (declaredReturnTypeStr === actualReturnTypeStr) { return; } + if (actualReturnType.flags & ts.TypeFlags.Any || declaredReturnType.flags & ts.TypeFlags.Any) { + return; + } if (this.isSubtypeByBaseTypesList(actualReturnType, declaredReturnType)) { this.incrementCounters(returnStmt.expression, FaultID.IncompationbleFunctionType); return; diff --git a/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json b/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json index 83f24a944f1bcded0c0bcc6d2fc6ce1b311ff4de..2757f6f80c22bafa79806545a2c7b026468d11c0 100644 --- a/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json +++ b/ets2panda/linter/test/main/incompatible_function.ets.arkts2.json @@ -204,6 +204,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "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,