diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 7303f27a93e7fd98bbd3105183cd30c64e14ebec..ba08add0593f330a2df76a25441d142a2fa271b2 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -547,6 +547,9 @@ void ETSChecker::CheckDynamicInheritanceAndImplement(ETSObjectType *const interf } return false; }; + if (isFromDynamicDecl(interfaceOrClassType)) { + return; + } for (ETSObjectType *interType : interfaceOrClassType->Interfaces()) { if (isFromDynamicDecl(interType)) { LogError(diagnostic::INTERFACE_OR_CLASS_CANNOT_IMPL_OR_EXTEND_DYNAMIC, @@ -1908,6 +1911,9 @@ void ETSChecker::CheckCyclicConstructorCall(Signature *signature) ETSObjectType *ETSChecker::CheckExceptionOrErrorType(checker::Type *type, const lexer::SourcePosition pos) { + if (type->IsGradualType()) { + return CheckExceptionOrErrorType(type->AsGradualType()->GetBaseType(), pos); + } ES2PANDA_ASSERT(type != nullptr); if (!type->IsETSObjectType() || (!Relation()->IsAssignableTo(type, GlobalBuiltinExceptionType()) && !Relation()->IsAssignableTo(type, GlobalBuiltinErrorType()))) { diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index 0ee26101bbea0f25ad40fc4b050fcfa830cd178b..021b8c6147d47d42d07c2c95ddb6e38fa421e3f7 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -1108,6 +1108,10 @@ Type *ETSChecker::GetReadonlyType(Type *type) return *found; } + if (type->IsGradualType()) { + return GetReadonlyType(type->AsGradualType()->GetBaseType()); + } + NamedTypeStackElement ntse(this, type); ES2PANDA_ASSERT(type != nullptr); if (type->IsETSArrayType()) { diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index 340d413e5e060b383c31b2aa069c4a41fb8daca4..b661e39c240d8a314f94501799c3fef224d70733 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -897,6 +897,11 @@ void ETSObjectType::Cast(TypeRelation *const relation, Type *const target) return; } + if (target->IsGradualType()) { + relation->Result(true); + return; + } + if (CastNumericObject(relation, target)) { return; } diff --git a/ets2panda/compiler/lowering/ets/dynamicImport.cpp b/ets2panda/compiler/lowering/ets/dynamicImport.cpp index 2bb77d4b72bb59ff72f47d04f8409a7eda28b8ba..5e848f6e1eefdc7a976e7820b1dd46a056b90a22 100644 --- a/ets2panda/compiler/lowering/ets/dynamicImport.cpp +++ b/ets2panda/compiler/lowering/ets/dynamicImport.cpp @@ -285,8 +285,11 @@ static AstNodePtr TransformIdentifier(ir::Identifier *ident, public_lib::Context } const auto parent = ident->Parent(); + auto isTransformedNode = + (parent->IsMemberExpression() && parent->AsMemberExpression()->ObjType() != nullptr && + parent->AsMemberExpression()->ObjType()->HasObjectFlag(checker::ETSObjectFlags::LAZY_IMPORT_OBJECT)); if (parent->IsImportSpecifier() || parent->IsImportNamespaceSpecifier() || parent->IsScriptFunction() || - parent->IsMethodDefinition()) { + parent->IsMethodDefinition() || isTransformedNode) { return ident; } diff --git a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp index 247092a886ea77f196182ee33a2f1933e1698b9c..4b208dc69c634d69a26835e18272a6a6947747cc 100644 --- a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp @@ -86,7 +86,8 @@ static ir::BlockExpression *ConvertSpreadToBlockExpression(public_lib::Context * static bool ShouldProcessRestParameters(checker::Signature *signature, const ArenaVector &arguments) { return signature != nullptr && signature->HasRestParameter() && !signature->RestVar()->TsType()->IsETSArrayType() && - arguments.size() >= signature->Params().size() && !signature->RestVar()->TsType()->IsETSTupleType(); + arguments.size() >= signature->Params().size() && !signature->RestVar()->TsType()->IsETSTupleType() && + !signature->Function()->IsDynamic(); } static ir::Expression *CreateRestArgsArray(public_lib::Context *context, ArenaVector &arguments, diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp index d8c68fb76d773b4e536779daa39b3b284e468c5f..e3d38668aa587db543be433878e3d557ad8c2582 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp @@ -691,9 +691,10 @@ ir::ClassDeclaration *GlobalClassHandler::CreateGlobalClass(const parser::Progra auto *ident = NodeAllocator::Alloc(allocator_, compiler::Signatures::ETS_GLOBAL, allocator_); ES2PANDA_ASSERT(ident != nullptr); ident->SetRange(rangeToStartOfFile); - auto *classDef = - NodeAllocator::Alloc(allocator_, allocator_, ident, ir::ClassDefinitionModifiers::GLOBAL, - ir::ModifierFlags::ABSTRACT, Language(Language::Id::ETS)); + auto lang = + globalProgram->IsDeclForDynamicStaticInterop() ? Language(Language::Id::JS) : Language(Language::Id::ETS); + auto *classDef = NodeAllocator::Alloc( + allocator_, allocator_, ident, ir::ClassDefinitionModifiers::GLOBAL, ir::ModifierFlags::ABSTRACT, lang); ES2PANDA_ASSERT(classDef != nullptr); classDef->SetRange(rangeToStartOfFile); auto *classDecl = NodeAllocator::Alloc(allocator_, classDef, allocator_); diff --git a/ets2panda/ir/ets/etsTypeReference.cpp b/ets2panda/ir/ets/etsTypeReference.cpp index 1a65605f89fb6f069276183806d73ae8d8ba54b1..2d3a50e9526e8f945d022410bfe4d0e10d9e4202 100644 --- a/ets2panda/ir/ets/etsTypeReference.cpp +++ b/ets2panda/ir/ets/etsTypeReference.cpp @@ -71,6 +71,15 @@ ir::Identifier *ETSTypeReference::BaseName() const while (iter->Left()->IsTSQualifiedName()) { iter = iter->Left()->AsTSQualifiedName(); } + if (iter->Left()->IsMemberExpression()) { + ES2PANDA_ASSERT(iter->Left()->AsMemberExpression()->ObjType()->HasObjectFlag( + checker::ETSObjectFlags::LAZY_IMPORT_OBJECT)); + ir::MemberExpression *memberExprIter = iter->Left()->AsMemberExpression(); + while (memberExprIter->Property()->IsMemberExpression()) { + memberExprIter = memberExprIter->Property()->AsMemberExpression(); + } + return memberExprIter->Property()->AsIdentifier(); + } return iter->Left()->AsIdentifier(); } diff --git a/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_error.ets b/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_error.ets new file mode 100644 index 0000000000000000000000000000000000000000..940a12d9810ace25736374825faa8bdc90c8adcd --- /dev/null +++ b/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_error.ets @@ -0,0 +1,29 @@ +/* + * 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. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { MyError } from "dynamic_import_tests/modules/module" + +function main() { + try { + throw new MyError() + } catch (e) { + let myError = e as MyError; + } +} + diff --git a/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_namespace.ets b/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_namespace.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ea885ad62afc35ddf3ff692e6cb51308a0efa6f --- /dev/null +++ b/ets2panda/test/ast/parser/ets/dynamic_import_tests/dynamic_namespace.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. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { ns } from "dynamic_import_tests/modules/module" + +()=>{ + let a = new ns.A() +} diff --git a/ets2panda/test/ast/parser/ets/dynamic_import_tests/readonly_dynamic_class_interface.ets b/ets2panda/test/ast/parser/ets/dynamic_import_tests/readonly_dynamic_class_interface.ets new file mode 100644 index 0000000000000000000000000000000000000000..f81878ad25902484504e643c6835ccecde2af278 --- /dev/null +++ b/ets2panda/test/ast/parser/ets/dynamic_import_tests/readonly_dynamic_class_interface.ets @@ -0,0 +1,34 @@ +/* + * 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. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { C, I2 } from "dynamic_import_tests/modules/module" + +function main() { + let c: Readonly = { s: "123" } + c.s = "234" + let i: Readonly = { + name: "abc", + age: 123 + } + i.age = 124 +} + +/* @@? 24:5 Error TypeError: The 'Readonly' property cannot be reassigned. */ +/* @@? 24:5 Error TypeError: Cannot assign to a readonly variable s */ +/* @@? 29:5 Error TypeError: The 'Readonly' property cannot be reassigned. */ diff --git a/ets2panda/test/parser/ets/dynamic_import_tests/modules/module-expected.txt b/ets2panda/test/parser/ets/dynamic_import_tests/modules/module-expected.txt index a58fd46be6c8cb7f37a76a465cad731ff2e3d9b9..67447b189f2aa0bc0f67945fd8b8b37cceeb1998 100644 --- a/ets2panda/test/parser/ets/dynamic_import_tests/modules/module-expected.txt +++ b/ets2panda/test/parser/ets/dynamic_import_tests/modules/module-expected.txt @@ -2434,8 +2434,1454 @@ "program": "module.ets" }, "end": { - "line": 43, - "column": 44, + "line": 45, + "column": 7, + "program": "module.ets" + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "C1", + "loc": { + "start": { + "line": 45, + "column": 22, + "program": "module.ets" + }, + "end": { + "line": 45, + "column": 24, + "program": "module.ets" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 45, + "column": 25, + "program": "module.ets" + }, + "end": { + "line": 45, + "column": 25, + "program": "module.ets" + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 45, + "column": 25, + "program": "module.ets" + }, + "end": { + "line": 45, + "column": 25, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 45, + "column": 25, + "program": "module.ets" + }, + "end": { + "line": 45, + "column": 25, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 45, + "column": 25, + "program": "module.ets" + }, + "end": { + "line": 45, + "column": 25, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 45, + "column": 25, + "program": "module.ets" + }, + "end": { + "line": 45, + "column": 25, + "program": "module.ets" + } + } + }, + "overloads": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + } + ], + "loc": { + "start": { + "line": 45, + "column": 24, + "program": "module.ets" + }, + "end": { + "line": 47, + "column": 7, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 45, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 47, + "column": 7, + "program": "module.ets" + } + } + }, + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [], + "loc": { + "start": { + "line": 47, + "column": 28, + "program": "module.ets" + }, + "end": { + "line": 47, + "column": 30, + "program": "module.ets" + } + } + }, + "id": { + "type": "Identifier", + "name": "I1", + "loc": { + "start": { + "line": 47, + "column": 26, + "program": "module.ets" + }, + "end": { + "line": 47, + "column": 28, + "program": "module.ets" + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 47, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 47, + "column": 30, + "program": "module.ets" + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "C2", + "loc": { + "start": { + "line": 49, + "column": 22, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 24, + "program": "module.ets" + } + } + }, + "superClass": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "C1", + "loc": { + "start": { + "line": 49, + "column": 33, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 35, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 33, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 35, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 33, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 35, + "program": "module.ets" + } + } + }, + "implements": [ + { + "type": "TSClassImplements", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "I1", + "loc": { + "start": { + "line": 49, + "column": 47, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 49, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 47, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 49, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 47, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 49, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 47, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 50, + "program": "module.ets" + } + } + } + ], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 49, + "column": 50, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 50, + "program": "module.ets" + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 49, + "column": 50, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 50, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 49, + "column": 50, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 50, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 50, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 50, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 50, + "program": "module.ets" + }, + "end": { + "line": 49, + "column": 50, + "program": "module.ets" + } + } + }, + "overloads": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + } + ], + "loc": { + "start": { + "line": 49, + "column": 49, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 7, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 7, + "program": "module.ets" + } + } + }, + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "name", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "get", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "name", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "module.ets" + }, + "end": { + "line": 1, + "column": 1, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "string", + "loc": { + "start": { + "line": 51, + "column": 10, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 10, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 10, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "overloads": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "name", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "set", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "name", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "module.ets" + }, + "end": { + "line": 1, + "column": 1, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "name", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "string", + "loc": { + "start": { + "line": 51, + "column": 10, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 10, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 10, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 9, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 9, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + "overloads": [], + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 51, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 51, + "column": 16, + "program": "module.ets" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "age", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "get", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "age", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "module.ets" + }, + "end": { + "line": 1, + "column": 1, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "loc": { + "start": { + "line": 52, + "column": 9, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 9, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 9, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "overloads": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "age", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "set", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "age", + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "module.ets" + }, + "end": { + "line": 1, + "column": 1, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "age", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "loc": { + "start": { + "line": 52, + "column": 9, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 9, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 9, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 8, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 8, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + }, + "overloads": [], + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 52, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 52, + "column": 15, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 50, + "column": 40, + "program": "module.ets" + }, + "end": { + "line": 53, + "column": 2, + "program": "module.ets" + } + } + }, + "id": { + "type": "Identifier", + "name": "I2", + "loc": { + "start": { + "line": 50, + "column": 26, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 28, + "program": "module.ets" + } + } + }, + "extends": [ + { + "type": "TSInterfaceHeritage", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "I1", + "loc": { + "start": { + "line": 50, + "column": 37, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 39, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 37, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 39, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 37, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 39, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 37, + "program": "module.ets" + }, + "end": { + "line": 50, + "column": 39, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 50, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 53, + "column": 2, + "program": "module.ets" + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "MyError", + "loc": { + "start": { + "line": 59, + "column": 22, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 29, + "program": "module.ets" + } + } + }, + "superClass": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "loc": { + "start": { + "line": 59, + "column": 38, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 43, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 59, + "column": 38, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 43, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 59, + "column": 38, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 43, + "program": "module.ets" + } + } + }, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "mycode", + "loc": { + "start": { + "line": 60, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 60, + "column": 11, + "program": "module.ets" + } + } + }, + "accessibility": "public", + "static": false, + "readonly": false, + "declare": true, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "loc": { + "start": { + "line": 60, + "column": 13, + "program": "module.ets" + }, + "end": { + "line": 60, + "column": 19, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 60, + "column": 13, + "program": "module.ets" + }, + "end": { + "line": 60, + "column": 19, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 60, + "column": 13, + "program": "module.ets" + }, + "end": { + "line": 60, + "column": 19, + "program": "module.ets" + } + } + }, + "definite": false, + "loc": { + "start": { + "line": 60, + "column": 5, + "program": "module.ets" + }, + "end": { + "line": 60, + "column": 19, + "program": "module.ets" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 59, + "column": 45, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 45, + "program": "module.ets" + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 59, + "column": 45, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 45, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 59, + "column": 45, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 45, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 59, + "column": 45, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 45, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 59, + "column": 45, + "program": "module.ets" + }, + "end": { + "line": 59, + "column": 45, + "program": "module.ets" + } + } + }, + "overloads": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + } + ], + "loc": { + "start": { + "line": 59, + "column": 44, + "program": "module.ets" + }, + "end": { + "line": 61, + "column": 2, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 59, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 61, + "column": 2, "program": "module.ets" } } @@ -2998,6 +4444,206 @@ "program": "module.ets" } } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ns", + "loc": { + "start": { + "line": 55, + "column": 26, + "program": "module.ets" + }, + "end": { + "line": 55, + "column": 28, + "program": "module.ets" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "loc": { + "start": { + "line": 56, + "column": 18, + "program": "module.ets" + }, + "end": { + "line": 56, + "column": 19, + "program": "module.ets" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 56, + "column": 20, + "program": "module.ets" + }, + "end": { + "line": 56, + "column": 20, + "program": "module.ets" + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "loc": { + "start": { + "line": 56, + "column": 20, + "program": "module.ets" + }, + "end": { + "line": 56, + "column": 20, + "program": "module.ets" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 56, + "column": 20, + "program": "module.ets" + }, + "end": { + "line": 56, + "column": 20, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 20, + "program": "module.ets" + }, + "end": { + "line": 56, + "column": 20, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 20, + "program": "module.ets" + }, + "end": { + "line": 56, + "column": 20, + "program": "module.ets" + } + } + }, + "overloads": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + } + ], + "loc": { + "start": { + "line": 56, + "column": 19, + "program": "module.ets" + }, + "end": { + "line": 57, + "column": 2, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 12, + "program": "module.ets" + }, + "end": { + "line": 57, + "column": 2, + "program": "module.ets" + } + } + } + ], + "loc": { + "start": { + "line": 55, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 57, + "column": 2, + "program": "module.ets" + } + } + }, + "loc": { + "start": { + "line": 55, + "column": 16, + "program": "module.ets" + }, + "end": { + "line": 57, + "column": 2, + "program": "module.ets" + } + } } ], "loc": { @@ -3007,8 +4653,8 @@ "program": "module.ets" }, "end": { - "line": 43, - "column": 44, + "line": 61, + "column": 2, "program": "module.ets" } } diff --git a/ets2panda/test/parser/ets/dynamic_import_tests/modules/module.ets b/ets2panda/test/parser/ets/dynamic_import_tests/modules/module.ets index 09a107ab6326d21a542db7c11c71be04561e800d..0c92660de3a186356914083384f29da7dd45747e 100644 --- a/ets2panda/test/parser/ets/dynamic_import_tests/modules/module.ets +++ b/ets2panda/test/parser/ets/dynamic_import_tests/modules/module.ets @@ -40,4 +40,22 @@ export declare class C { s:string } -export declare type requiredC = Required \ No newline at end of file +export declare type requiredC = Required + +export declare class C1{} + +export declare interface I1{} + +export declare class C2 extends C1 implements I1{} +export declare interface I2 extends I1 { + name:string; + age:number +} + +export declare namespace ns { + export class A{} +} + +export declare class MyError extends Error { + mycode: number +} \ No newline at end of file diff --git a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt index c032ed173d2e670413e96c7509647d155399fb9a..f162d5f5c5dad10374a51e47a01aa28745b37f11 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -30,6 +30,7 @@ runtime/ets/generics_1.ets runtime/ets/labeledStatement.ets runtime/ets/namespace_tests/namespace_import_type_test/namespace_export.ets runtime/ets/newArrayCreationUnionType.ets +parser/ets/dynamic_import_tests/modules/module.ets # FailKind.ES2PANDA_FAIL