From 7ad068cfd45f6c00258a607090cf086cb2080a84 Mon Sep 17 00:00:00 2001 From: ekkoruse Date: Mon, 4 Aug 2025 16:30:35 +0800 Subject: [PATCH] add CTE for overload async add CTE and some reserved logic Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICR01Q Signed-off-by: ekkoruse --- ets2panda/checker/ETSAnalyzer.cpp | 16 + .../lowering/ets/asyncMethodLowering.cpp | 36 +- .../ets/FixedArray/MultipleParserErrors.ets | 253 +-- .../ast/parser/ets/MultipleParserErrors.ets | 247 +-- .../parser/ets/async_consistence.ets} | 21 +- .../methodOverrideAsyncMethod-expected.txt | 1506 ----------------- .../ets/methodOverrideAsyncMethod.ets | 32 - ets2panda/util/diagnostic/semantic.yaml | 4 + 8 files changed, 304 insertions(+), 1811 deletions(-) rename ets2panda/test/{runtime/ets/async_overload.ets => ast/parser/ets/async_consistence.ets} (66%) delete mode 100644 ets2panda/test/compiler/ets/methodOverrideAsyncMethod-expected.txt delete mode 100644 ets2panda/test/compiler/ets/methodOverrideAsyncMethod.ets diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index e611b5aef7..ae548e6fe8 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -216,6 +216,17 @@ static bool IsInitializerBlockTransfer(std::string_view str) return str.size() >= prefix.size() && str.compare(0, prefix.size(), prefix) == 0; } +static bool CheckOverloadAsyncConsistence(ir::MethodDefinition *node) +{ + bool isAsync = util::Helpers::IsAsyncMethod(node); + for (auto method : node->Overloads()) { + if (isAsync != util::Helpers::IsAsyncMethod(method)) { + return false; + } + } + return true; +} + checker::Type *ETSAnalyzer::Check(ir::MethodDefinition *node) const { ETSChecker *checker = GetETSChecker(); @@ -253,6 +264,11 @@ checker::Type *ETSAnalyzer::Check(ir::MethodDefinition *node) const return returnErrorType(); } + if (!CheckOverloadAsyncConsistence(node)) { + checker->LogError(diagnostic::NOT_CONSISTENT_ASYNC_OVERLOAD, {node->Id()->Name()}, scriptFunc->Start()); + return returnErrorType(); + } + if (node->TsType() == nullptr) { node->SetTsType(checker->BuildMethodSignature(node)); } diff --git a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp index 7283b469f5..03f7135ef0 100644 --- a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp +++ b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp @@ -162,6 +162,19 @@ ir::MethodDefinition *CreateAsyncProxy(checker::ETSChecker *checker, ir::MethodD return implMethod; } +static ir::MethodDefinition *FindFirstAsyncMethod(ir::MethodDefinition *localNode) +{ + if (localNode->AsyncPairMethod() != nullptr) { + return localNode->AsyncPairMethod(); + } + for (auto method : localNode->Overloads()) { + if (method->AsyncPairMethod() != nullptr) { + return method->AsyncPairMethod(); + } + } + return nullptr; +}; + void ComposeAsyncImplMethod(checker::ETSChecker *checker, ir::MethodDefinition *node) { ES2PANDA_ASSERT(checker->FindAncestorGivenByType(node, ir::AstNodeType::CLASS_DEFINITION)); @@ -173,19 +186,20 @@ void ComposeAsyncImplMethod(checker::ETSChecker *checker, ir::MethodDefinition * node->Function()->SetAsyncPairMethod(implMethod->Function()); ES2PANDA_ASSERT(node->Function() != nullptr); - if (node->Function()->IsOverload() && node->BaseOverloadMethod()->AsyncPairMethod() != nullptr) { - auto *baseOverloadImplMethod = node->BaseOverloadMethod()->AsyncPairMethod(); - ES2PANDA_ASSERT(implMethod->Function() != nullptr && baseOverloadImplMethod->Function() != nullptr); - implMethod->Function()->Id()->SetVariable(baseOverloadImplMethod->Function()->Id()->Variable()); - baseOverloadImplMethod->AddOverload(implMethod); - implMethod->SetParent(baseOverloadImplMethod); - } else if (node->Function()->IsOverload() && node->BaseOverloadMethod()->AsyncPairMethod() == nullptr) { - // If it's base overload function doesnot marked as async, - // then current AsyncImpl should be treated as AsyncPairMethod in base overload. - node->BaseOverloadMethod()->SetAsyncPairMethod(implMethod); - classDef->EmplaceBody(implMethod); + if (node->Function()->IsOverload()) { + // reserved for async and non-async method overload. + auto firstAsyncMethod = FindFirstAsyncMethod(node->BaseOverloadMethod()); + if (firstAsyncMethod != nullptr && firstAsyncMethod != implMethod) { + implMethod->Function()->Id()->SetVariable(firstAsyncMethod->Function()->Id()->Variable()); + firstAsyncMethod->AddOverload(implMethod); + implMethod->SetParent(firstAsyncMethod); + } else { + classDef->EmplaceBody(implMethod); + implMethod->SetParent(classDef); + } } else { classDef->EmplaceBody(implMethod); + implMethod->SetParent(classDef); } } diff --git a/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets b/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets index b39957d8dc..053d3d07dd 100644 --- a/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets +++ b/ets2panda/test/ast/parser/ets/FixedArray/MultipleParserErrors.ets @@ -166,129 +166,130 @@ function main(): void { f(); } -/* @@? 18:14 Error SyntaxError: Optional variable is not allowed in for of statements. */ -/* @@? 28:29 Error TypeError: Native, Abstract and Declare methods cannot have body. */ -/* @@? 34:14 Error SyntaxError: The modifier for a constructor should be limited to access modifiers (private, internal, protected, public), and 'native' modifiers. */ -/* @@? 37:33 Error SyntaxError: Unexpected token 'rethrows'. */ -/* @@? 37:33 Error TypeError: Unresolved reference rethrows */ -/* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 39:24 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 39:27 Error SyntaxError: Unexpected token ')'. */ -/* @@? 39:29 Error SyntaxError: Unexpected token '{'. */ -/* @@? 39:31 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 39:38 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 41:1 Error TypeError: Unresolved reference type */ -/* @@? 41:6 Error SyntaxError: Unexpected token '123'. */ -/* @@? 41:6 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 41:10 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 41:12 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 43:6 Error SyntaxError: Unexpected token 'null'. */ -/* @@? 43:6 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 43:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 43:13 Error SyntaxError: Unexpected token 'byte'. */ -/* @@? 45:6 Error SyntaxError: Unexpected token 'this'. */ -/* @@? 45:6 Error TypeError: Cannot reference 'this' in this context. */ -/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 45:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ -/* @@? 47:8 Error TypeError: Missing initializer in const declaration */ -/* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 51:35 Error SyntaxError: Rest parameter must be the last formal parameter. */ -/* @@? 51:37 Error SyntaxError: Unexpected token '...'. */ -/* @@? 51:40 Error SyntaxError: Unexpected token 'p'. */ -/* @@? 51:43 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 51:43 Error TypeError: Unresolved reference FixedArray */ -/* @@? 51:58 Error SyntaxError: Unexpected token, expected '('. */ -/* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ -/* @@? 51:61 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 51:61 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 51:61 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 51:65 Error SyntaxError: Unexpected token '{'. */ -/* @@? 52:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 52:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 52:12 Error TypeError: Unresolved reference q */ -/* @@? 52:23 Error TypeError: Unresolved reference p */ -/* @@? 55:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 59:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 63:22 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 63:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 67:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 67:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 68:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 73:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 73:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 74:11 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 77:20 Error TypeError: Interface expected here. */ -/* @@? 77:22 Error TypeError: 'I' type does not exist. */ -/* @@? 78:22 Error TypeError: Method fee(): Int in B not overriding any method */ -/* @@? 83:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 83:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 84:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 92:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 103:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 104:21 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ -/* @@? 115:32 Error SyntaxError: Unexpected token 'U'. */ -/* @@? 115:32 Error TypeError: Unresolved reference U */ -/* @@? 115:33 Error SyntaxError: Unexpected token ')'. */ -/* @@? 115:34 Error SyntaxError: Unexpected token ':'. */ -/* @@? 115:36 Error SyntaxError: Unexpected token 'T'. */ -/* @@? 115:36 Error TypeError: Unresolved reference T */ -/* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ -/* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ -/* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ -/* @@? 119:32 Error SyntaxError: Unexpected token 'U'. */ -/* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ -/* @@? 119:34 Error SyntaxError: Unexpected token ':'. */ -/* @@? 119:36 Error SyntaxError: Unexpected token 'T'. */ -/* @@? 119:38 Error SyntaxError: Unexpected token '{'. */ -/* @@? 120:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 120:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 123:5 Error SyntaxError: Identifier expected, got ','. */ -/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ -/* @@? 123:6 Error SyntaxError: Unexpected token 'abc'. */ -/* @@? 123:6 Error TypeError: Unresolved reference abc */ -/* @@? 125:1 Error TypeError: Method declaration `foo` must all ambient or non-ambient */ -/* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ -/* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 137:16 Error SyntaxError: Unexpected token '='. */ -/* @@? 137:16 Error SyntaxError: Expected '{', got '='. */ -/* @@? 137:16 Error SyntaxError: Expected ')', got '='. */ -/* @@? 137:16 Error SyntaxError: Catch clause variable cannot have an initializer. */ -/* @@? 137:18 Error SyntaxError: Unexpected token '0'. */ -/* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ -/* @@? 137:21 Error SyntaxError: Unexpected token '{'. */ -/* @@? 141:24 Error TypeError: This expression is not callable. */ -/* @@? 145:18 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 146:28 Error TypeError: Property 'getInner' does not exist on type 'A' */ -/* @@? 148:25 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 149:24 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 151:20 Error TypeError: Cannot find type 'D0'. */ -/* @@? 151:29 Error TypeError: Cannot find type 'D0'. */ -/* @@? 157:16 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 158:26 Error TypeError: Property 'getInner' does not exist on type 'A' */ -/* @@? 161:9 Error SyntaxError: Identifier expected, got 'let'. */ -/* @@? 161:9 Error SyntaxError: Hard keyword 'let' cannot be used as identifier */ -/* @@? 162:9 Error SyntaxError: Hard keyword 'const' cannot be used as identifier */ -/* @@? 162:9 Error SyntaxError: Identifier expected, got 'const'. */ -/* @@? 163:9 Error SyntaxError: Hard keyword 'new' cannot be used as identifier */ -/* @@? 163:9 Error SyntaxError: Identifier expected, got 'new'. */ -/* @@? 164:5 Error TypeError: This expression is not callable. */ -/* @@? 165:5 Error TypeError: This expression is not callable. */ -/* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ -/* @@? 166:5 Error TypeError: No matching call signature */ -/* @@? 295:1 Error SyntaxError: Expected '}', got 'end of stream'. */ +/* @@? 16:10 Error TypeError: All overloads of method 'foo' must have the same async modifier (either all async or all synchronous). */ +/* @@? 18:14 Error SyntaxError: Optional variable is not allowed in for of statements. */ +/* @@? 28:29 Error TypeError: Native, Abstract and Declare methods cannot have body. */ +/* @@? 34:14 Error SyntaxError: The modifier for a constructor should be limited to access modifiers (private, internal, protected, public), and 'native' modifiers. */ +/* @@? 37:33 Error SyntaxError: Unexpected token 'rethrows'. */ +/* @@? 37:33 Error TypeError: Unresolved reference rethrows */ +/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 39:24 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 39:27 Error SyntaxError: Unexpected token ')'. */ +/* @@? 39:29 Error SyntaxError: Unexpected token '{'. */ +/* @@? 39:31 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 39:38 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 41:1 Error TypeError: Unresolved reference type */ +/* @@? 41:6 Error SyntaxError: Unexpected token '123'. */ +/* @@? 41:6 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 41:10 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 41:12 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 43:6 Error SyntaxError: Unexpected token 'null'. */ +/* @@? 43:6 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 43:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 43:13 Error SyntaxError: Unexpected token 'byte'. */ +/* @@? 45:6 Error SyntaxError: Unexpected token 'this'. */ +/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 45:6 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 45:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@? 47:8 Error TypeError: Missing initializer in const declaration */ +/* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 51:35 Error SyntaxError: Rest parameter must be the last formal parameter. */ +/* @@? 51:37 Error SyntaxError: Unexpected token '...'. */ +/* @@? 51:40 Error SyntaxError: Unexpected token 'p'. */ +/* @@? 51:43 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 51:43 Error TypeError: Unresolved reference FixedArray */ +/* @@? 51:58 Error SyntaxError: Unexpected token, expected '('. */ +/* @@? 51:59 Error SyntaxError: Unexpected token ':'. */ +/* @@? 51:61 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 51:61 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 51:61 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 51:65 Error SyntaxError: Unexpected token '{'. */ +/* @@? 52:5 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 52:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 52:12 Error TypeError: Unresolved reference q */ +/* @@? 52:23 Error TypeError: Unresolved reference p */ +/* @@? 55:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 59:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 63:22 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 63:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 67:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 67:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 68:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 73:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 73:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 74:11 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 77:20 Error TypeError: Interface expected here. */ +/* @@? 77:22 Error TypeError: 'I' type does not exist. */ +/* @@? 78:22 Error TypeError: Method fee(): Int in B not overriding any method */ +/* @@? 83:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 83:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 84:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 92:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 103:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 104:21 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ +/* @@? 115:32 Error SyntaxError: Unexpected token 'U'. */ +/* @@? 115:32 Error TypeError: Unresolved reference U */ +/* @@? 115:33 Error SyntaxError: Unexpected token ')'. */ +/* @@? 115:34 Error SyntaxError: Unexpected token ':'. */ +/* @@? 115:36 Error SyntaxError: Unexpected token 'T'. */ +/* @@? 115:36 Error TypeError: Unresolved reference T */ +/* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ +/* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ +/* @@? 119:32 Error SyntaxError: Unexpected token 'U'. */ +/* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ +/* @@? 119:34 Error SyntaxError: Unexpected token ':'. */ +/* @@? 119:36 Error SyntaxError: Unexpected token 'T'. */ +/* @@? 119:38 Error SyntaxError: Unexpected token '{'. */ +/* @@? 120:5 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 120:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 123:5 Error SyntaxError: Identifier expected, got ','. */ +/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@? 123:6 Error SyntaxError: Unexpected token 'abc'. */ +/* @@? 123:6 Error TypeError: Unresolved reference abc */ +/* @@? 125:1 Error TypeError: Method declaration `foo` must all ambient or non-ambient */ +/* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ +/* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 137:16 Error SyntaxError: Catch clause variable cannot have an initializer. */ +/* @@? 137:16 Error SyntaxError: Expected ')', got '='. */ +/* @@? 137:16 Error SyntaxError: Expected '{', got '='. */ +/* @@? 137:16 Error SyntaxError: Unexpected token '='. */ +/* @@? 137:18 Error SyntaxError: Unexpected token '0'. */ +/* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ +/* @@? 137:21 Error SyntaxError: Unexpected token '{'. */ +/* @@? 141:24 Error TypeError: This expression is not callable. */ +/* @@? 145:18 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 146:28 Error TypeError: Property 'getInner' does not exist on type 'A' */ +/* @@? 148:25 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 149:24 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 151:20 Error TypeError: Cannot find type 'D0'. */ +/* @@? 151:29 Error TypeError: Cannot find type 'D0'. */ +/* @@? 157:16 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 158:26 Error TypeError: Property 'getInner' does not exist on type 'A' */ +/* @@? 161:9 Error SyntaxError: Identifier expected, got 'let'. */ +/* @@? 161:9 Error SyntaxError: Hard keyword 'let' cannot be used as identifier */ +/* @@? 162:9 Error SyntaxError: Hard keyword 'const' cannot be used as identifier */ +/* @@? 162:9 Error SyntaxError: Identifier expected, got 'const'. */ +/* @@? 163:9 Error SyntaxError: Hard keyword 'new' cannot be used as identifier */ +/* @@? 163:9 Error SyntaxError: Identifier expected, got 'new'. */ +/* @@? 164:5 Error TypeError: This expression is not callable. */ +/* @@? 165:5 Error TypeError: This expression is not callable. */ +/* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ +/* @@? 166:5 Error TypeError: No matching call signature */ +/* @@? 296:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets b/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets index f4c6092e3d..879488da00 100644 --- a/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets +++ b/ets2panda/test/ast/parser/ets/MultipleParserErrors.ets @@ -166,126 +166,127 @@ function main(): void { f(); } -/* @@? 18:14 Error SyntaxError: Optional variable is not allowed in for of statements. */ -/* @@? 28:29 Error TypeError: Native, Abstract and Declare methods cannot have body. */ -/* @@? 34:14 Error SyntaxError: The modifier for a constructor should be limited to access modifiers (private, internal, protected, public), and 'native' modifiers. */ -/* @@? 37:33 Error SyntaxError: Unexpected token 'rethrows'. */ -/* @@? 37:33 Error TypeError: Unresolved reference rethrows */ -/* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 39:24 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 39:27 Error SyntaxError: Unexpected token ')'. */ -/* @@? 39:29 Error SyntaxError: Unexpected token '{'. */ -/* @@? 39:31 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 39:38 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 41:1 Error TypeError: Unresolved reference type */ -/* @@? 41:6 Error SyntaxError: Unexpected token '123'. */ -/* @@? 41:6 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 41:10 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 41:12 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 43:6 Error SyntaxError: Unexpected token 'null'. */ -/* @@? 43:6 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 43:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 43:13 Error SyntaxError: Unexpected token 'byte'. */ -/* @@? 45:6 Error SyntaxError: Unexpected token 'this'. */ -/* @@? 45:6 Error TypeError: Cannot reference 'this' in this context. */ -/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ -/* @@? 45:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ -/* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ -/* @@? 47:8 Error TypeError: Missing initializer in const declaration */ -/* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 51:25 Error SyntaxError: Rest parameter must be the last formal parameter. */ -/* @@? 51:27 Error SyntaxError: Unexpected token '...'. */ -/* @@? 51:30 Error SyntaxError: Unexpected token 'p'. */ -/* @@? 51:33 Error SyntaxError: Label must be followed by a loop statement. */ -/* @@? 51:38 Error SyntaxError: Unexpected token ')'. */ -/* @@? 51:39 Error SyntaxError: Unexpected token ':'. */ -/* @@? 51:41 Error SyntaxError: Unexpected token 'int'. */ -/* @@? 51:45 Error SyntaxError: Unexpected token '{'. */ -/* @@? 52:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 52:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 52:12 Error TypeError: Unresolved reference q */ -/* @@? 52:23 Error TypeError: Unresolved reference p */ -/* @@? 55:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 59:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 63:22 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 63:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 67:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 67:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 68:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 73:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 73:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 74:11 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 77:20 Error TypeError: Interface expected here. */ -/* @@? 77:22 Error TypeError: 'I' type does not exist. */ -/* @@? 78:22 Error TypeError: Method fee(): Int in B not overriding any method */ -/* @@? 83:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 83:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 84:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ -/* @@? 92:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ -/* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ -/* @@? 103:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 104:21 Error SyntaxError: Rest parameter should be either array or tuple type. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ -/* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ -/* @@? 115:32 Error SyntaxError: Unexpected token 'U'. */ -/* @@? 115:32 Error TypeError: Unresolved reference U */ -/* @@? 115:33 Error SyntaxError: Unexpected token ')'. */ -/* @@? 115:34 Error SyntaxError: Unexpected token ':'. */ -/* @@? 115:36 Error SyntaxError: Unexpected token 'T'. */ -/* @@? 115:36 Error TypeError: Unresolved reference T */ -/* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ -/* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ -/* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ -/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ -/* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ -/* @@? 119:32 Error SyntaxError: Unexpected token 'U'. */ -/* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ -/* @@? 119:34 Error SyntaxError: Unexpected token ':'. */ -/* @@? 119:36 Error SyntaxError: Unexpected token 'T'. */ -/* @@? 119:38 Error SyntaxError: Unexpected token '{'. */ -/* @@? 120:5 Error SyntaxError: return keyword should be used in function body. */ -/* @@? 120:12 Error TypeError: All return statements in the function should be empty or have a value. */ -/* @@? 123:5 Error SyntaxError: Identifier expected, got ','. */ -/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ -/* @@? 123:6 Error SyntaxError: Unexpected token 'abc'. */ -/* @@? 123:6 Error TypeError: Unresolved reference abc */ -/* @@? 125:1 Error TypeError: Method declaration `foo` must all ambient or non-ambient */ -/* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ -/* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ -/* @@? 137:16 Error SyntaxError: Unexpected token '='. */ -/* @@? 137:16 Error SyntaxError: Expected '{', got '='. */ -/* @@? 137:16 Error SyntaxError: Expected ')', got '='. */ -/* @@? 137:16 Error SyntaxError: Catch clause variable cannot have an initializer. */ -/* @@? 137:18 Error SyntaxError: Unexpected token '0'. */ -/* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ -/* @@? 137:21 Error SyntaxError: Unexpected token '{'. */ -/* @@? 141:24 Error TypeError: This expression is not callable. */ -/* @@? 145:18 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 146:28 Error TypeError: Property 'getInner' does not exist on type 'A' */ -/* @@? 148:25 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 149:24 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 151:20 Error TypeError: Cannot find type 'D0'. */ -/* @@? 151:29 Error TypeError: Cannot find type 'D0'. */ -/* @@? 157:16 Error TypeError: A is abstract therefore cannot be instantiated. */ -/* @@? 158:26 Error TypeError: Property 'getInner' does not exist on type 'A' */ -/* @@? 161:9 Error SyntaxError: Identifier expected, got 'let'. */ -/* @@? 161:9 Error SyntaxError: Hard keyword 'let' cannot be used as identifier */ -/* @@? 162:9 Error SyntaxError: Hard keyword 'const' cannot be used as identifier */ -/* @@? 162:9 Error SyntaxError: Identifier expected, got 'const'. */ -/* @@? 163:9 Error SyntaxError: Hard keyword 'new' cannot be used as identifier */ -/* @@? 163:9 Error SyntaxError: Identifier expected, got 'new'. */ -/* @@? 164:5 Error TypeError: This expression is not callable. */ -/* @@? 165:5 Error TypeError: This expression is not callable. */ -/* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ -/* @@? 166:5 Error TypeError: No matching call signature */ -/* @@? 292:1 Error SyntaxError: Expected '}', got 'end of stream'. */ +/* @@? 16:10 Error TypeError: All overloads of method 'foo' must have the same async modifier (either all async or all synchronous). */ +/* @@? 18:14 Error SyntaxError: Optional variable is not allowed in for of statements. */ +/* @@? 28:29 Error TypeError: Native, Abstract and Declare methods cannot have body. */ +/* @@? 34:14 Error SyntaxError: The modifier for a constructor should be limited to access modifiers (private, internal, protected, public), and 'native' modifiers. */ +/* @@? 37:33 Error SyntaxError: Unexpected token 'rethrows'. */ +/* @@? 37:33 Error TypeError: Unresolved reference rethrows */ +/* @@? 39:14 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 39:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 39:14 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 39:24 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 39:27 Error SyntaxError: Unexpected token ')'. */ +/* @@? 39:29 Error SyntaxError: Unexpected token '{'. */ +/* @@? 39:31 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 39:38 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 41:1 Error TypeError: Unresolved reference type */ +/* @@? 41:6 Error SyntaxError: Unexpected token '123'. */ +/* @@? 41:6 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 41:10 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 41:12 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 43:6 Error SyntaxError: Unexpected token 'null'. */ +/* @@? 43:6 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 43:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 43:13 Error SyntaxError: Unexpected token 'byte'. */ +/* @@? 45:6 Error SyntaxError: Unexpected token 'this'. */ +/* @@? 45:6 Error TypeError: Invalid left-hand side of assignment expression */ +/* @@? 45:6 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 45:11 Error SyntaxError: Invalid left-hand side in assignment expression. */ +/* @@? 47:8 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@? 47:8 Error TypeError: Missing initializer in const declaration */ +/* @@? 49:13 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 51:25 Error SyntaxError: Rest parameter must be the last formal parameter. */ +/* @@? 51:27 Error SyntaxError: Unexpected token '...'. */ +/* @@? 51:30 Error SyntaxError: Unexpected token 'p'. */ +/* @@? 51:33 Error SyntaxError: Label must be followed by a loop statement. */ +/* @@? 51:38 Error SyntaxError: Unexpected token ')'. */ +/* @@? 51:39 Error SyntaxError: Unexpected token ':'. */ +/* @@? 51:41 Error SyntaxError: Unexpected token 'int'. */ +/* @@? 51:45 Error SyntaxError: Unexpected token '{'. */ +/* @@? 52:5 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 52:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 52:12 Error TypeError: Unresolved reference q */ +/* @@? 52:23 Error TypeError: Unresolved reference p */ +/* @@? 55:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 59:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 63:22 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 63:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 67:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 67:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 68:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 73:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 73:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 74:11 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 77:20 Error TypeError: Interface expected here. */ +/* @@? 77:22 Error TypeError: 'I' type does not exist. */ +/* @@? 78:22 Error TypeError: Method fee(): Int in B not overriding any method */ +/* @@? 83:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 83:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 84:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 92:7 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 92:7 Error TypeError: Variable 'A' has already been declared. */ +/* @@? 93:3 Error SyntaxError: Unexpected token. A constructor, method, accessor, or property was expected. */ +/* @@? 103:14 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 104:21 Error SyntaxError: Rest parameter should be either array or tuple type. */ +/* @@? 115:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 115:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 115:26 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 115:30 Error SyntaxError: Unexpected token ':'. */ +/* @@? 115:32 Error SyntaxError: Unexpected token 'U'. */ +/* @@? 115:32 Error TypeError: Unresolved reference U */ +/* @@? 115:33 Error SyntaxError: Unexpected token ')'. */ +/* @@? 115:34 Error SyntaxError: Unexpected token ':'. */ +/* @@? 115:36 Error SyntaxError: Unexpected token 'T'. */ +/* @@? 115:36 Error TypeError: Unresolved reference T */ +/* @@? 115:38 Error SyntaxError: Unexpected token '{'. */ +/* @@? 116:5 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 116:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 119:1 Error TypeError: Function foo with this assembly signature already declared. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 119:26 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 119:26 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 119:26 Error SyntaxError: Unexpected token 'case'. */ +/* @@? 119:30 Error SyntaxError: Unexpected token ':'. */ +/* @@? 119:32 Error SyntaxError: Unexpected token 'U'. */ +/* @@? 119:33 Error SyntaxError: Unexpected token ')'. */ +/* @@? 119:34 Error SyntaxError: Unexpected token ':'. */ +/* @@? 119:36 Error SyntaxError: Unexpected token 'T'. */ +/* @@? 119:38 Error SyntaxError: Unexpected token '{'. */ +/* @@? 120:5 Error SyntaxError: return keyword should be used in function body. */ +/* @@? 120:12 Error TypeError: All return statements in the function should be empty or have a value. */ +/* @@? 123:5 Error SyntaxError: Identifier expected, got ','. */ +/* @@? 123:6 Error SyntaxError: Variable must be initialized or it's type must be declared. */ +/* @@? 123:6 Error SyntaxError: Unexpected token 'abc'. */ +/* @@? 123:6 Error TypeError: Unresolved reference abc */ +/* @@? 125:1 Error TypeError: Method declaration `foo` must all ambient or non-ambient */ +/* @@? 127:1 Error SyntaxError: The modifier async cannot be used in an ambient context. */ +/* @@? 132:14 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 137:16 Error SyntaxError: Unexpected token '='. */ +/* @@? 137:16 Error SyntaxError: Expected '{', got '='. */ +/* @@? 137:16 Error SyntaxError: Expected ')', got '='. */ +/* @@? 137:16 Error SyntaxError: Catch clause variable cannot have an initializer. */ +/* @@? 137:18 Error SyntaxError: Unexpected token '0'. */ +/* @@? 137:19 Error SyntaxError: Unexpected token ')'. */ +/* @@? 137:21 Error SyntaxError: Unexpected token '{'. */ +/* @@? 141:24 Error TypeError: This expression is not callable. */ +/* @@? 145:18 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 146:28 Error TypeError: Property 'getInner' does not exist on type 'A' */ +/* @@? 148:25 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 149:24 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 151:20 Error TypeError: Cannot find type 'D0'. */ +/* @@? 151:29 Error TypeError: Cannot find type 'D0'. */ +/* @@? 157:16 Error TypeError: A is abstract therefore cannot be instantiated. */ +/* @@? 158:26 Error TypeError: Property 'getInner' does not exist on type 'A' */ +/* @@? 161:9 Error SyntaxError: Identifier expected, got 'let'. */ +/* @@? 161:9 Error SyntaxError: Hard keyword 'let' cannot be used as identifier */ +/* @@? 162:9 Error SyntaxError: Hard keyword 'const' cannot be used as identifier */ +/* @@? 162:9 Error SyntaxError: Identifier expected, got 'const'. */ +/* @@? 163:9 Error SyntaxError: Hard keyword 'new' cannot be used as identifier */ +/* @@? 163:9 Error SyntaxError: Identifier expected, got 'new'. */ +/* @@? 164:5 Error TypeError: This expression is not callable. */ +/* @@? 165:5 Error TypeError: This expression is not callable. */ +/* @@? 166:5 Error TypeError: Expected 1 arguments, got 0. */ +/* @@? 166:5 Error TypeError: No matching call signature */ +/* @@? 293:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/runtime/ets/async_overload.ets b/ets2panda/test/ast/parser/ets/async_consistence.ets similarity index 66% rename from ets2panda/test/runtime/ets/async_overload.ets rename to ets2panda/test/ast/parser/ets/async_consistence.ets index f50ea63200..86753bc8c8 100644 --- a/ets2panda/test/runtime/ets/async_overload.ets +++ b/ets2panda/test/ast/parser/ets/async_consistence.ets @@ -13,20 +13,15 @@ * limitations under the License. */ -function foo(a : string){ - return 1; -} -async function foo() { - return 2 -} +class Test { + regularFunc(): boolean { + return true + } -async function foo(a: int) { - return 3 + async regularFunc(param: () => boolean): Promise { + return param(); + } } -function main() { - arktest.assertEQ(foo("test"), 1); - arktest.assertEQ(await foo(), 2); - arktest.assertEQ(await foo(1), 3); -} +/* @@? 18:16 Error TypeError: All overloads of method 'regularFunc' must have the same async modifier (either all async or all synchronous). */ \ No newline at end of file diff --git a/ets2panda/test/compiler/ets/methodOverrideAsyncMethod-expected.txt b/ets2panda/test/compiler/ets/methodOverrideAsyncMethod-expected.txt deleted file mode 100644 index 7c7074103e..0000000000 --- a/ets2panda/test/compiler/ets/methodOverrideAsyncMethod-expected.txt +++ /dev/null @@ -1,1506 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 7, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 16, - "column": 8, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "regularFunc1", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "regularFunc1", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "param", - "typeAnnotation": { - "type": "ETSFunctionType", - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 17, - "column": 29, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 36, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 23, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 36, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 16, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 36, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 16, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 36, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 39, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 46, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 17, - "column": 47, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 54, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 46, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 55, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 39, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 55, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 39, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 17, - "column": 55, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 19, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "property": { - "type": "Identifier", - "name": "resolve", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 20, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 18, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "arguments": [ - { - "type": "BooleanLiteral", - "value": true, - "loc": { - "start": { - "line": 18, - "column": 37, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 41, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "optional": false, - "typeParameters": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 28, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 35, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 36, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 42, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 5, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 18, - "column": 43, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 56, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 19, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 19, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 19, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "regularFunc1", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 21, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "regularFunc1", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 21, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 21, - "column": 19, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 21, - "column": 26, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "BooleanLiteral", - "value": true, - "loc": { - "start": { - "line": 22, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 22, - "column": 16, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 5, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 22, - "column": 17, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 21, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 23, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 23, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 23, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 23, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 19, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "regularFunc2", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 9, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 21, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "regularFunc2", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 9, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 21, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "generator": false, - "async": true, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "param", - "typeAnnotation": { - "type": "ETSFunctionType", - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 25, - "column": 35, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 42, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 29, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 42, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 22, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 42, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 22, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 42, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 45, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 52, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 25, - "column": 53, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 60, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 25, - "column": 52, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 61, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 45, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 61, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 45, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 25, - "column": 61, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 19, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "property": { - "type": "Identifier", - "name": "resolve", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 20, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "arguments": [ - { - "type": "BooleanLiteral", - "value": true, - "loc": { - "start": { - "line": 26, - "column": 37, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 41, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "optional": false, - "typeParameters": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 28, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 35, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 26, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 36, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 42, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 5, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 26, - "column": 43, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 25, - "column": 62, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 27, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 21, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 27, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 21, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 27, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "regularFunc2", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 29, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "regularFunc2", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 29, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 29, - "column": 19, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 29, - "column": 26, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "BooleanLiteral", - "value": true, - "loc": { - "start": { - "line": 30, - "column": 12, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 30, - "column": 16, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 30, - "column": 5, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 30, - "column": 17, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 29, - "column": 27, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 31, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 31, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 15, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 31, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 3, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 31, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 9, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 27, - "column": 4, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "kind": "constructor", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 16, - "column": 10, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 33, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 33, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - }, - "end": { - "line": 33, - "column": 1, - "program": "methodOverrideAsyncMethod.ets" - } - } -} diff --git a/ets2panda/test/compiler/ets/methodOverrideAsyncMethod.ets b/ets2panda/test/compiler/ets/methodOverrideAsyncMethod.ets deleted file mode 100644 index 1555684735..0000000000 --- a/ets2panda/test/compiler/ets/methodOverrideAsyncMethod.ets +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -class A { - regularFunc1(param: () => boolean): Promise { - return Promise.resolve(true); - } - - regularFunc1(): boolean { - return true; - } - - async regularFunc2(param: () => boolean): Promise { - return Promise.resolve(true); - } - - regularFunc2(): boolean { - return true; - } -} diff --git a/ets2panda/util/diagnostic/semantic.yaml b/ets2panda/util/diagnostic/semantic.yaml index 509c9dbf7b..c8be31f0e1 100644 --- a/ets2panda/util/diagnostic/semantic.yaml +++ b/ets2panda/util/diagnostic/semantic.yaml @@ -904,6 +904,10 @@ semantic: id: 67 message: "'{}' is not an annotation." +- name: NOT_CONSISTENT_ASYNC_OVERLOAD + id: 488 + message: "All overloads of method '{}' must have the same async modifier (either all async or all synchronous)." + - name: NOT_CONSTANT id: 163 message: "Constant expression required" -- Gitee