From 5fa1d1d487d49c962991fa7b6e5683feb4a38c82 Mon Sep 17 00:00:00 2001 From: Janos Pantos Date: Wed, 17 Jul 2024 09:23:40 +0200 Subject: [PATCH] [ArkTS] Assignment analyzer improvements Fixes internal issue #17844 Issue: #IADMTE Change-Id: I9dfc36212f81551e22a996d05b8535233a14251d Signed-off-by: Janos Pantos --- ets2panda/checker/ets/assignAnalyzer.cpp | 19 +- .../ets/generic_arrayaslist-expected.txt | 20 +- .../test/compiler/ets/generic_arrayaslist.sts | 2 +- .../ets/generic_function_call_5-expected.txt | 61 +- .../compiler/ets/generic_function_call_5.sts | 2 +- ...nerics_class_recursive_type_1-expected.txt | 1240 +++++++++++++---- .../ets/generics_class_recursive_type_1.sts | 13 +- .../ets/generics_instantiation_1-expected.txt | 673 +++++---- .../compiler/ets/generics_instantiation_1.sts | 3 + .../ets/generics_instantiation_3-expected.txt | 20 +- .../compiler/ets/generics_instantiation_3.sts | 2 +- .../generics_interface_bounds_1-expected.txt | 413 ++++-- .../ets/generics_interface_bounds_1.sts | 4 + .../ets/identifierReference4-expected.txt | 20 +- .../compiler/ets/identifierReference4.sts | 2 +- .../ets/invalidInheritance3-expected.txt | 145 +- .../test/compiler/ets/invalidInheritance3.sts | 2 +- .../ets/lowering-interaction-expected.txt | 63 +- .../compiler/ets/lowering-interaction.sts | 2 +- .../compiler/ets/tuple_types_19-expected.txt | 920 +++++++----- .../test/compiler/ets/tuple_types_19.sts | 1 + .../compiler/ets/union_types_5-expected.txt | 1118 ++++++++------- ets2panda/test/compiler/ets/union_types_5.sts | 6 +- .../test/parser/ets/AccessNSieve-expected.txt | 20 +- ets2panda/test/parser/ets/AccessNSieve.sts | 2 +- .../test/parser/ets/FunctionType-expected.txt | 145 +- ets2panda/test/parser/ets/FunctionType.sts | 2 +- .../test/parser/ets/Morph3d-expected.txt | 20 +- ets2panda/test/parser/ets/Morph3d.sts | 2 +- .../array_creation_expression-expected.txt | 164 ++- .../parser/ets/array_creation_expression.sts | 2 +- .../test/parser/ets/generics_1-expected.txt | 936 +++++++++++-- ets2panda/test/parser/ets/generics_1.sts | 8 +- .../re_export/folderIndex2/key-expected.txt | 40 +- .../parser/ets/re_export/folderIndex2/key.sts | 4 +- .../ets/test-type-alias-call1-expected.txt | 127 +- .../test/parser/ets/test-type-alias-call1.sts | 2 +- .../ets/test-type-alias-call2-expected.txt | 127 +- .../test/parser/ets/test-type-alias-call2.sts | 2 +- .../ets/test-type-alias-call3-expected.txt | 127 +- .../test/parser/ets/test-type-alias-call3.sts | 2 +- .../ets/test-type-alias-call4-expected.txt | 127 +- .../test/parser/ets/test-type-alias-call4.sts | 2 +- .../ets/test-type-alias-call5-expected.txt | 121 +- .../test/parser/ets/test-type-alias-call5.sts | 2 +- .../ets/test-type-alias-call6-expected.txt | 121 +- .../test/parser/ets/test-type-alias-call6.sts | 2 +- ...nion_lowering_common_property-expected.txt | 40 +- .../ets/union_lowering_common_property.sts | 4 +- ets2panda/test/runtime/ets/AccessNSieve.sts | 2 +- .../ets/InterfaceOverrideReturnTypes.sts | 4 +- ets2panda/test/runtime/ets/Morph3d.sts | 2 +- .../test/runtime/ets/accessor_functional.sts | 2 +- .../ets/common_property_union_access.sts | 4 +- .../test/runtime/ets/partialTypeRuntime_1.sts | 4 +- .../test/runtime/ets/readonlyTypeRuntime.sts | 10 +- ets2panda/test/runtime/ets/this_type.sts | 2 +- 57 files changed, 5091 insertions(+), 1841 deletions(-) diff --git a/ets2panda/checker/ets/assignAnalyzer.cpp b/ets2panda/checker/ets/assignAnalyzer.cpp index 334bc7f86c..40120b028d 100644 --- a/ets2panda/checker/ets/assignAnalyzer.cpp +++ b/ets2panda/checker/ets/assignAnalyzer.cpp @@ -66,7 +66,9 @@ namespace ark::es2panda::checker { static constexpr NodeId INVALID_ID = -1; -static constexpr bool CHECK_ALL_PROPERTIES = false; +static constexpr bool CHECK_ALL_PROPERTIES = true; +// NOTE(pantos) generic field initialization issue, skip them for now +static constexpr bool CHECK_GENERIC_NON_READONLY_PROPERTIES = false; static constexpr bool WARN_NO_INIT_ONCE_PER_VARIABLE = false; static constexpr int LOOP_PHASES = 2; @@ -1364,9 +1366,11 @@ bool AssignAnalyzer::VariableHasDefaultValue(const ir::AstNode *node) ASSERT(node != nullptr); const checker::Type *type = nullptr; + bool isNonReadonlyField = false; if (node->IsClassProperty()) { type = node->AsClassProperty()->TsType(); + isNonReadonlyField = !node->IsReadonly(); // NOTE(pantos) readonly is true, const is not set? } else if (node->IsVariableDeclarator()) { varbinder::Variable *variable = GetBoundVariable(node); if (variable != nullptr) { @@ -1376,15 +1380,17 @@ bool AssignAnalyzer::VariableHasDefaultValue(const ir::AstNode *node) UNREACHABLE(); } - return type != nullptr && (type->HasTypeFlag(checker::TypeFlag::ETS_PRIMITIVE) || - (type->PossiblyETSNullish() && !type->HasTypeFlag(checker::TypeFlag::GENERIC))); + return type != nullptr && + (type->HasTypeFlag(checker::TypeFlag::ETS_PRIMITIVE) || + (type->PossiblyETSNullish() && (!type->HasTypeFlag(checker::TypeFlag::GENERIC) || + (isNonReadonlyField && !CHECK_GENERIC_NON_READONLY_PROPERTIES)))); } void AssignAnalyzer::LetInit(const ir::AstNode *node) { const ir::AstNode *declNode = GetDeclaringNode(node); - if (declNode == nullptr) { + if (declNode == nullptr || declNode->IsDeclare()) { return; } @@ -1394,6 +1400,7 @@ void AssignAnalyzer::LetInit(const ir::AstNode *node) } if (node != declNode && declNode->IsConst()) { + // check reassignment of readonly properties util::StringView type = GetVariableType(declNode); util::StringView name = GetVariableName(declNode); const lexer::SourcePosition &pos = GetVariablePosition(node); @@ -1423,7 +1430,7 @@ void AssignAnalyzer::CheckInit(const ir::AstNode *node) { const ir::AstNode *declNode = GetDeclaringNode(node); - if (declNode == nullptr) { + if (declNode == nullptr || declNode->IsDeclare()) { return; } @@ -1438,7 +1445,7 @@ void AssignAnalyzer::CheckInit(const ir::AstNode *node) } if (declNode->IsClassProperty()) { - if (!declNode->IsConst()) { + if (!CHECK_ALL_PROPERTIES && !declNode->IsConst()) { // non readonly property return; } diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt index f5d342c34e..78774de123 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt +++ b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt @@ -21000,6 +21000,20 @@ } } }, + "value": { + "type": "ArrayExpression", + "elements": [], + "loc": { + "start": { + "line": 238, + "column": 25 + }, + "end": { + "line": 238, + "column": 27 + } + } + }, "accessibility": "private", "static": false, "readonly": false, @@ -21052,11 +21066,11 @@ "loc": { "start": { "line": 238, - "column": 22 + "column": 23 }, "end": { "line": 238, - "column": 23 + "column": 24 } } }, @@ -21069,7 +21083,7 @@ }, "end": { "line": 238, - "column": 23 + "column": 27 } } }, diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist.sts b/ets2panda/test/compiler/ets/generic_arrayaslist.sts index 4a08b5c2c4..f80aff92a7 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist.sts +++ b/ets2panda/test/compiler/ets/generic_arrayaslist.sts @@ -235,6 +235,6 @@ class ArrayAsListt implements Listt { } - private data: T[]; + private data: T[] = []; private curSize: int; } diff --git a/ets2panda/test/compiler/ets/generic_function_call_5-expected.txt b/ets2panda/test/compiler/ets/generic_function_call_5-expected.txt index df5c348a72..bc8b429c36 100644 --- a/ets2panda/test/compiler/ets/generic_function_call_5-expected.txt +++ b/ets2panda/test/compiler/ets/generic_function_call_5-expected.txt @@ -359,6 +359,61 @@ } } }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 38 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 20, + "column": 27 + }, + "end": { + "line": 20, + "column": 40 + } + } + }, "accessibility": "private", "static": false, "readonly": false, @@ -391,7 +446,7 @@ }, "end": { "line": 20, - "column": 25 + "column": 26 } } }, @@ -402,7 +457,7 @@ }, "end": { "line": 20, - "column": 25 + "column": 26 } } }, @@ -415,7 +470,7 @@ }, "end": { "line": 20, - "column": 25 + "column": 40 } } } diff --git a/ets2panda/test/compiler/ets/generic_function_call_5.sts b/ets2panda/test/compiler/ets/generic_function_call_5.sts index 4eee7b0e39..d5747778f6 100644 --- a/ets2panda/test/compiler/ets/generic_function_call_5.sts +++ b/ets2panda/test/compiler/ets/generic_function_call_5.sts @@ -17,7 +17,7 @@ class P { constructor(callback: (resolve: (value: T) => void) => void throws) { } - private ref: Object; + private ref: Object = new Object(); } function foo(): P { diff --git a/ets2panda/test/compiler/ets/generics_class_recursive_type_1-expected.txt b/ets2panda/test/compiler/ets/generics_class_recursive_type_1-expected.txt index 743d0838fa..7d8baa5b5b 100644 --- a/ets2panda/test/compiler/ets/generics_class_recursive_type_1-expected.txt +++ b/ets2panda/test/compiler/ets/generics_class_recursive_type_1-expected.txt @@ -5347,6 +5347,7 @@ } }, "kind": "constructor", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -5372,40 +5373,252 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "j", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 56, + "column": 20 + }, + "end": { + "line": 56, + "column": 21 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 56, + "column": 22 + }, + "end": { + "line": 56, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 22 + }, + "end": { + "line": 56, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 22 + }, + "end": { + "line": 56, + "column": 24 + } + } + } + ], + "loc": { + "start": { + "line": 56, + "column": 21 + }, + "end": { + "line": 56, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 20 + }, + "end": { + "line": 56, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 20 + }, + "end": { + "line": 56, + "column": 25 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 56, + "column": 17 + }, + "end": { + "line": 56, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 17 + }, + "end": { + "line": 56, + "column": 25 + } + } + } + ], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 57, + "column": 9 + }, + "end": { + "line": 57, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 57, + "column": 14 + }, + "end": { + "line": 57, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 57, + "column": 9 + }, + "end": { + "line": 57, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 57, + "column": 18 + }, + "end": { + "line": 57, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 57, + "column": 9 + }, + "end": { + "line": 57, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 57, + "column": 9 + }, + "end": { + "line": 57, + "column": 20 + } + } + } + ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 56, + "column": 26 }, "end": { - "line": 1, - "column": 1 + "line": 58, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 56, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 58, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 56, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 58, + "column": 6 } } }, @@ -5414,11 +5627,11 @@ "loc": { "start": { "line": 56, - "column": 2 + "column": 5 }, "end": { - "line": 56, - "column": 2 + "line": 58, + "column": 6 } } } @@ -5429,7 +5642,7 @@ "column": 11 }, "end": { - "line": 56, + "line": 59, "column": 2 } } @@ -5440,7 +5653,7 @@ "column": 1 }, "end": { - "line": 56, + "line": 59, "column": 2 } } @@ -5454,11 +5667,11 @@ "decorators": [], "loc": { "start": { - "line": 58, + "line": 61, "column": 7 }, "end": { - "line": 58, + "line": 61, "column": 8 } } @@ -5474,11 +5687,11 @@ "decorators": [], "loc": { "start": { - "line": 58, + "line": 61, "column": 9 }, "end": { - "line": 58, + "line": 61, "column": 10 } } @@ -5493,11 +5706,11 @@ "decorators": [], "loc": { "start": { - "line": 58, + "line": 61, "column": 19 }, "end": { - "line": 58, + "line": 61, "column": 24 } } @@ -5515,33 +5728,33 @@ "decorators": [], "loc": { "start": { - "line": 58, + "line": 61, "column": 25 }, "end": { - "line": 58, + "line": 61, "column": 31 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 25 }, "end": { - "line": 58, + "line": 61, "column": 32 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 25 }, "end": { - "line": 58, + "line": 61, "column": 32 } } @@ -5549,44 +5762,44 @@ ], "loc": { "start": { - "line": 58, + "line": 61, "column": 24 }, "end": { - "line": 58, + "line": 61, "column": 32 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 19 }, "end": { - "line": 58, + "line": 61, "column": 33 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 19 }, "end": { - "line": 58, + "line": 61, "column": 33 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 9 }, "end": { - "line": 58, + "line": 61, "column": 33 } } @@ -5599,22 +5812,22 @@ "decorators": [], "loc": { "start": { - "line": 58, + "line": 61, "column": 34 }, "end": { - "line": 58, + "line": 61, "column": 35 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 34 }, "end": { - "line": 58, + "line": 61, "column": 36 } } @@ -5622,11 +5835,11 @@ ], "loc": { "start": { - "line": 58, + "line": 61, "column": 8 }, "end": { - "line": 58, + "line": 61, "column": 36 } } @@ -5642,11 +5855,11 @@ "decorators": [], "loc": { "start": { - "line": 59, + "line": 62, "column": 5 }, "end": { - "line": 59, + "line": 62, "column": 6 } } @@ -5667,11 +5880,11 @@ "decorators": [], "loc": { "start": { - "line": 59, + "line": 62, "column": 8 }, "end": { - "line": 59, + "line": 62, "column": 13 } } @@ -5689,33 +5902,33 @@ "decorators": [], "loc": { "start": { - "line": 59, + "line": 62, "column": 14 }, "end": { - "line": 59, + "line": 62, "column": 15 } } }, "loc": { "start": { - "line": 59, + "line": 62, "column": 14 }, "end": { - "line": 59, + "line": 62, "column": 16 } } }, "loc": { "start": { - "line": 59, + "line": 62, "column": 14 }, "end": { - "line": 59, + "line": 62, "column": 16 } } @@ -5730,33 +5943,33 @@ "decorators": [], "loc": { "start": { - "line": 59, + "line": 62, "column": 17 }, "end": { - "line": 59, + "line": 62, "column": 18 } } }, "loc": { "start": { - "line": 59, + "line": 62, "column": 17 }, "end": { - "line": 59, + "line": 62, "column": 19 } } }, "loc": { "start": { - "line": 59, + "line": 62, "column": 17 }, "end": { - "line": 59, + "line": 62, "column": 19 } } @@ -5764,33 +5977,33 @@ ], "loc": { "start": { - "line": 59, + "line": 62, "column": 13 }, "end": { - "line": 59, + "line": 62, "column": 19 } } }, "loc": { "start": { - "line": 59, + "line": 62, "column": 8 }, "end": { - "line": 59, + "line": 62, "column": 20 } } }, "loc": { "start": { - "line": 59, + "line": 62, "column": 8 }, "end": { - "line": 59, + "line": 62, "column": 20 } } @@ -5799,11 +6012,11 @@ "decorators": [], "loc": { "start": { - "line": 59, + "line": 62, "column": 5 }, "end": { - "line": 59, + "line": 62, "column": 20 } } @@ -5816,11 +6029,11 @@ "decorators": [], "loc": { "start": { - "line": 60, + "line": 63, "column": 5 }, "end": { - "line": 60, + "line": 63, "column": 6 } } @@ -5841,11 +6054,11 @@ "decorators": [], "loc": { "start": { - "line": 60, + "line": 63, "column": 8 }, "end": { - "line": 60, + "line": 63, "column": 13 } } @@ -5863,33 +6076,33 @@ "decorators": [], "loc": { "start": { - "line": 60, + "line": 63, "column": 14 }, "end": { - "line": 60, + "line": 63, "column": 15 } } }, "loc": { "start": { - "line": 60, + "line": 63, "column": 14 }, "end": { - "line": 60, + "line": 63, "column": 16 } } }, "loc": { "start": { - "line": 60, + "line": 63, "column": 14 }, "end": { - "line": 60, + "line": 63, "column": 16 } } @@ -5904,33 +6117,33 @@ "decorators": [], "loc": { "start": { - "line": 60, + "line": 63, "column": 17 }, "end": { - "line": 60, + "line": 63, "column": 18 } } }, "loc": { "start": { - "line": 60, + "line": 63, "column": 17 }, "end": { - "line": 60, + "line": 63, "column": 19 } } }, "loc": { "start": { - "line": 60, + "line": 63, "column": 17 }, "end": { - "line": 60, + "line": 63, "column": 19 } } @@ -5938,33 +6151,33 @@ ], "loc": { "start": { - "line": 60, + "line": 63, "column": 13 }, "end": { - "line": 60, + "line": 63, "column": 19 } } }, "loc": { "start": { - "line": 60, + "line": 63, "column": 8 }, "end": { - "line": 60, + "line": 63, "column": 20 } } }, "loc": { "start": { - "line": 60, + "line": 63, "column": 8 }, "end": { - "line": 60, + "line": 63, "column": 20 } } @@ -5973,11 +6186,11 @@ "decorators": [], "loc": { "start": { - "line": 60, + "line": 63, "column": 5 }, "end": { - "line": 60, + "line": 63, "column": 20 } } @@ -5986,16 +6199,614 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "foo", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 61, + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "j", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Nodes", + "decorators": [], + "loc": { + "start": { + "line": 65, + "column": 12 + }, + "end": { + "line": 65, + "column": 17 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "K", + "decorators": [], + "loc": { + "start": { + "line": 65, + "column": 18 + }, + "end": { + "line": 65, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 18 + }, + "end": { + "line": 65, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 18 + }, + "end": { + "line": 65, + "column": 20 + } + } + }, + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "V", + "decorators": [], + "loc": { + "start": { + "line": 65, + "column": 21 + }, + "end": { + "line": 65, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 21 + }, + "end": { + "line": 65, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 21 + }, + "end": { + "line": 65, + "column": 23 + } + } + } + ], + "loc": { + "start": { + "line": 65, + "column": 17 + }, + "end": { + "line": 65, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 12 + }, + "end": { + "line": 65, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 12 + }, + "end": { + "line": 65, + "column": 24 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 65, + "column": 9 + }, + "end": { + "line": 65, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 65, + "column": 9 + }, + "end": { + "line": 65, + "column": 24 + } + } + }, + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "i", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Nodes", + "decorators": [], + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 66, + "column": 17 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "K", + "decorators": [], + "loc": { + "start": { + "line": 66, + "column": 18 + }, + "end": { + "line": 66, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 18 + }, + "end": { + "line": 66, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 18 + }, + "end": { + "line": 66, + "column": 20 + } + } + }, + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "V", + "decorators": [], + "loc": { + "start": { + "line": 66, + "column": 21 + }, + "end": { + "line": 66, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 21 + }, + "end": { + "line": 66, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 21 + }, + "end": { + "line": 66, + "column": 23 + } + } + } + ], + "loc": { + "start": { + "line": 66, + "column": 17 + }, + "end": { + "line": 66, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 67, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 12 + }, + "end": { + "line": 67, + "column": 10 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 66, + "column": 9 + }, + "end": { + "line": 67, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 66, + "column": 9 + }, + "end": { + "line": 67, + "column": 10 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 69, + "column": 9 + }, + "end": { + "line": 69, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 69, + "column": 14 + }, + "end": { + "line": 69, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 69, + "column": 9 + }, + "end": { + "line": 69, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 69, + "column": 18 + }, + "end": { + "line": 69, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 69, + "column": 9 + }, + "end": { + "line": 69, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 69, + "column": 9 + }, + "end": { + "line": 69, + "column": 20 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 70, + "column": 9 + }, + "end": { + "line": 70, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 70, + "column": 9 + }, + "end": { + "line": 70, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 70, + "column": 18 + }, + "end": { + "line": 70, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 70, + "column": 9 + }, + "end": { + "line": 70, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 70, + "column": 9 + }, + "end": { + "line": 70, + "column": 20 + } + } + } + ], + "loc": { + "start": { + "line": 68, + "column": 5 + }, + "end": { + "line": 71, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 64, + "column": 16 + }, + "end": { + "line": 71, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 64, + "column": 16 + }, + "end": { + "line": 71, "column": 6 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 64, + "column": 5 + }, + "end": { + "line": 71, + "column": 6 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 72, + "column": 5 }, "end": { - "line": 61, - "column": 9 + "line": 72, + "column": 8 } } }, @@ -6014,12 +6825,12 @@ "decorators": [], "loc": { "start": { - "line": 61, - "column": 6 + "line": 72, + "column": 5 }, "end": { - "line": 61, - "column": 9 + "line": 72, + "column": 8 } } }, @@ -6031,12 +6842,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 61, - "column": 13 + "line": 72, + "column": 12 }, "end": { - "line": 61, - "column": 17 + "line": 72, + "column": 16 } } }, @@ -6063,11 +6874,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 13 } } @@ -6078,11 +6889,11 @@ "decorators": [], "loc": { "start": { - "line": 62, + "line": 73, "column": 14 }, "end": { - "line": 62, + "line": 73, "column": 15 } } @@ -6091,11 +6902,11 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 15 } } @@ -6106,11 +6917,11 @@ "decorators": [], "loc": { "start": { - "line": 62, + "line": 73, "column": 16 }, "end": { - "line": 62, + "line": 73, "column": 21 } } @@ -6119,11 +6930,11 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 21 } } @@ -6134,11 +6945,11 @@ "decorators": [], "loc": { "start": { - "line": 62, + "line": 73, "column": 22 }, "end": { - "line": 62, + "line": 73, "column": 26 } } @@ -6147,11 +6958,11 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 26 } } @@ -6162,11 +6973,11 @@ "decorators": [], "loc": { "start": { - "line": 62, + "line": 73, "column": 27 }, "end": { - "line": 62, + "line": 73, "column": 32 } } @@ -6175,11 +6986,11 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 32 } } @@ -6190,11 +7001,11 @@ "decorators": [], "loc": { "start": { - "line": 62, + "line": 73, "column": 33 }, "end": { - "line": 62, + "line": 73, "column": 36 } } @@ -6203,11 +7014,11 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 36 } } @@ -6218,11 +7029,11 @@ "decorators": [], "loc": { "start": { - "line": 62, + "line": 73, "column": 37 }, "end": { - "line": 62, + "line": 73, "column": 45 } } @@ -6231,11 +7042,11 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 45 } } @@ -6244,22 +7055,22 @@ "optional": false, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 47 } } }, "loc": { "start": { - "line": 62, + "line": 73, "column": 9 }, "end": { - "line": 62, + "line": 73, "column": 48 } } @@ -6275,11 +7086,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 63, + "line": 74, "column": 9 }, "end": { - "line": 63, + "line": 74, "column": 13 } } @@ -6290,11 +7101,11 @@ "decorators": [], "loc": { "start": { - "line": 63, + "line": 74, "column": 14 }, "end": { - "line": 63, + "line": 74, "column": 15 } } @@ -6303,11 +7114,11 @@ "optional": false, "loc": { "start": { - "line": 63, + "line": 74, "column": 9 }, "end": { - "line": 63, + "line": 74, "column": 15 } } @@ -6318,11 +7129,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 63, + "line": 74, "column": 18 }, "end": { - "line": 63, + "line": 74, "column": 22 } } @@ -6333,11 +7144,11 @@ "decorators": [], "loc": { "start": { - "line": 63, + "line": 74, "column": 23 }, "end": { - "line": 63, + "line": 74, "column": 24 } } @@ -6346,33 +7157,33 @@ "optional": false, "loc": { "start": { - "line": 63, + "line": 74, "column": 18 }, "end": { - "line": 63, + "line": 74, "column": 24 } } }, "loc": { "start": { - "line": 63, + "line": 74, "column": 9 }, "end": { - "line": 63, + "line": 74, "column": 24 } } }, "loc": { "start": { - "line": 63, + "line": 74, "column": 9 }, "end": { - "line": 63, + "line": 74, "column": 25 } } @@ -6380,33 +7191,33 @@ ], "loc": { "start": { - "line": 61, - "column": 17 + "line": 72, + "column": 16 }, "end": { - "line": 64, + "line": 75, "column": 7 } } }, "loc": { "start": { - "line": 61, - "column": 9 + "line": 72, + "column": 8 }, "end": { - "line": 64, + "line": 75, "column": 7 } } }, "loc": { "start": { - "line": 61, - "column": 9 + "line": 72, + "column": 8 }, "end": { - "line": 64, + "line": 75, "column": 7 } } @@ -6415,127 +7226,34 @@ "decorators": [], "loc": { "start": { - "line": 61, - "column": 6 + "line": 72, + "column": 5 }, "end": { - "line": 64, + "line": 75, "column": 7 } } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "constructor", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 65, - "column": 2 - }, - "end": { - "line": 65, - "column": 2 - } - } } ], "loc": { "start": { - "line": 58, + "line": 61, "column": 36 }, "end": { - "line": 65, + "line": 76, "column": 2 } } }, "loc": { "start": { - "line": 58, + "line": 61, "column": 1 }, "end": { - "line": 65, + "line": 76, "column": 2 } } @@ -6685,7 +7403,7 @@ "column": 1 }, "end": { - "line": 66, + "line": 77, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/generics_class_recursive_type_1.sts b/ets2panda/test/compiler/ets/generics_class_recursive_type_1.sts index bd559123b5..828f889ba1 100644 --- a/ets2panda/test/compiler/ets/generics_class_recursive_type_1.sts +++ b/ets2panda/test/compiler/ets/generics_class_recursive_type_1.sts @@ -53,12 +53,23 @@ interface Lista { class A{ j: A; + constructor(j: A) { + this.j = j; + } } class B, V>{ j: Nodes; i: Nodes; - foo(): void{ + constructor( + j: Nodes, + i: Nodes + ) + { + this.j = j; + this.i = i; + } + foo(): void{ this.j.right.left.right.key.popFront(); this.j = this.i; } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_1-expected.txt b/ets2panda/test/compiler/ets/generics_instantiation_1-expected.txt index fa0eef0c28..f38d04972f 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_1-expected.txt +++ b/ets2panda/test/compiler/ets/generics_instantiation_1-expected.txt @@ -187,20 +187,20 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "f1", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 18, - "column": 12 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", "static": false, "optional": false, @@ -211,109 +211,167 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "f1", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 18, - "column": 12 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 } } }, "generator": false, "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", + "params": [ + { + "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "T", + "name": "a0", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 18, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 18, + "column": 23 + } + } + }, "decorators": [], "loc": { "start": { "line": 18, - "column": 18 + "column": 17 }, "end": { "line": 18, - "column": 19 + "column": 23 } } }, "loc": { "start": { "line": 18, - "column": 18 + "column": 17 }, "end": { "line": 18, - "column": 21 + "column": 23 } } - }, - "loc": { - "start": { - "line": 18, - "column": 18 - }, - "end": { - "line": 18, - "column": 21 - } } - }, + ], "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "a0", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 19, + "column": 16 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 19, - "column": 16 + "column": 9 }, "end": { "line": 19, - "column": 20 + "column": 16 } } }, - "property": { + "right": { "type": "Identifier", "name": "a0", "decorators": [], "loc": { "start": { "line": 19, - "column": 21 + "column": 19 }, "end": { "line": 19, - "column": 23 + "column": 21 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 19, - "column": 16 + "column": 9 }, "end": { "line": 19, - "column": 23 + "column": 21 } } }, @@ -324,7 +382,7 @@ }, "end": { "line": 19, - "column": 24 + "column": 22 } } } @@ -332,7 +390,7 @@ "loc": { "start": { "line": 18, - "column": 20 + "column": 24 }, "end": { "line": 20, @@ -343,7 +401,7 @@ "loc": { "start": { "line": 18, - "column": 14 + "column": 16 }, "end": { "line": 20, @@ -354,7 +412,7 @@ "loc": { "start": { "line": 18, - "column": 14 + "column": 16 }, "end": { "line": 20, @@ -379,20 +437,21 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "constructor", + "name": "f1", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 14 } } }, - "kind": "constructor", + "kind": "method", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -402,16 +461,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "constructor", + "name": "f1", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 14 } } }, @@ -419,39 +478,137 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 21, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 21, + "column": 21 + } + } + }, "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 20 + } + } + }, + "property": { + "type": "Identifier", + "name": "a0", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 24 + } + } + } + ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 20 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 6 } } }, @@ -460,11 +617,11 @@ "loc": { "start": { "line": 21, - "column": 2 + "column": 5 }, "end": { - "line": 21, - "column": 2 + "line": 23, + "column": 6 } } } @@ -475,7 +632,7 @@ "column": 27 }, "end": { - "line": 21, + "line": 24, "column": 2 } } @@ -486,7 +643,7 @@ "column": 1 }, "end": { - "line": 21, + "line": 24, "column": 2 } } @@ -500,11 +657,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 26, "column": 7 }, "end": { - "line": 23, + "line": 26, "column": 8 } } @@ -520,11 +677,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 27, "column": 12 }, "end": { - "line": 24, + "line": 27, "column": 15 } } @@ -544,11 +701,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 27, "column": 12 }, "end": { - "line": 24, + "line": 27, "column": 15 } } @@ -572,33 +729,33 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 27, "column": 23 }, "end": { - "line": 24, + "line": 27, "column": 29 } } }, "loc": { "start": { - "line": 24, + "line": 27, "column": 23 }, "end": { - "line": 24, + "line": 27, "column": 30 } } }, "loc": { "start": { - "line": 24, + "line": 27, "column": 23 }, "end": { - "line": 24, + "line": 27, "column": 30 } } @@ -606,22 +763,22 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 27, "column": 16 }, "end": { - "line": 24, + "line": 27, "column": 30 } } }, "loc": { "start": { - "line": 24, + "line": 27, "column": 16 }, "end": { - "line": 24, + "line": 27, "column": 30 } } @@ -631,11 +788,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 24, + "line": 27, "column": 33 }, "end": { - "line": 24, + "line": 27, "column": 37 } } @@ -661,11 +818,11 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 28, "column": 23 }, "end": { - "line": 25, + "line": 28, "column": 24 } } @@ -683,33 +840,33 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 28, "column": 25 }, "end": { - "line": 25, + "line": 28, "column": 31 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 25 }, "end": { - "line": 25, + "line": 28, "column": 32 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 25 }, "end": { - "line": 25, + "line": 28, "column": 32 } } @@ -717,33 +874,33 @@ ], "loc": { "start": { - "line": 25, + "line": 28, "column": 24 }, "end": { - "line": 25, + "line": 28, "column": 32 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 23 }, "end": { - "line": 25, + "line": 28, "column": 34 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 23 }, "end": { - "line": 25, + "line": 28, "column": 34 } } @@ -751,11 +908,11 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 28, "column": 13 }, "end": { - "line": 25, + "line": 28, "column": 21 } } @@ -770,11 +927,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 25, + "line": 28, "column": 35 }, "end": { - "line": 25, + "line": 28, "column": 39 } } @@ -785,11 +942,11 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 28, "column": 40 }, "end": { - "line": 25, + "line": 28, "column": 42 } } @@ -798,11 +955,11 @@ "optional": false, "loc": { "start": { - "line": 25, + "line": 28, "column": 35 }, "end": { - "line": 25, + "line": 28, "column": 42 } } @@ -811,11 +968,11 @@ "optional": false, "loc": { "start": { - "line": 25, + "line": 28, "column": 35 }, "end": { - "line": 25, + "line": 28, "column": 44 } } @@ -830,11 +987,11 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 28, "column": 48 }, "end": { - "line": 25, + "line": 28, "column": 49 } } @@ -852,33 +1009,33 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 28, "column": 50 }, "end": { - "line": 25, + "line": 28, "column": 56 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 50 }, "end": { - "line": 25, + "line": 28, "column": 57 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 50 }, "end": { - "line": 25, + "line": 28, "column": 57 } } @@ -886,55 +1043,55 @@ ], "loc": { "start": { - "line": 25, + "line": 28, "column": 49 }, "end": { - "line": 25, + "line": 28, "column": 57 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 48 }, "end": { - "line": 25, + "line": 28, "column": 58 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 48 }, "end": { - "line": 25, + "line": 28, "column": 58 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 35 }, "end": { - "line": 25, + "line": 28, "column": 44 } } }, "loc": { "start": { - "line": 25, + "line": 28, "column": 13 }, "end": { - "line": 25, + "line": 28, "column": 44 } } @@ -943,11 +1100,11 @@ "kind": "let", "loc": { "start": { - "line": 25, + "line": 28, "column": 9 }, "end": { - "line": 25, + "line": 28, "column": 58 } } @@ -955,33 +1112,33 @@ ], "loc": { "start": { - "line": 24, + "line": 27, "column": 38 }, "end": { - "line": 26, + "line": 29, "column": 6 } } }, "loc": { "start": { - "line": 24, + "line": 27, "column": 15 }, "end": { - "line": 26, + "line": 29, "column": 6 } } }, "loc": { "start": { - "line": 24, + "line": 27, "column": 15 }, "end": { - "line": 26, + "line": 29, "column": 6 } } @@ -990,11 +1147,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 27, "column": 5 }, "end": { - "line": 26, + "line": 29, "column": 6 } } @@ -1007,11 +1164,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 30, "column": 13 }, "end": { - "line": 27, + "line": 30, "column": 16 } } @@ -1031,11 +1188,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 30, "column": 13 }, "end": { - "line": 27, + "line": 30, "column": 16 } } @@ -1048,11 +1205,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 27, + "line": 30, "column": 21 }, "end": { - "line": 27, + "line": 30, "column": 25 } } @@ -1078,11 +1235,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 18 }, "end": { - "line": 28, + "line": 31, "column": 19 } } @@ -1100,33 +1257,33 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 20 }, "end": { - "line": 28, + "line": 31, "column": 26 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 20 }, "end": { - "line": 28, + "line": 31, "column": 27 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 20 }, "end": { - "line": 28, + "line": 31, "column": 27 } } @@ -1134,33 +1291,33 @@ ], "loc": { "start": { - "line": 28, + "line": 31, "column": 19 }, "end": { - "line": 28, + "line": 31, "column": 27 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 18 }, "end": { - "line": 28, + "line": 31, "column": 29 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 18 }, "end": { - "line": 28, + "line": 31, "column": 29 } } @@ -1168,11 +1325,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 13 }, "end": { - "line": 28, + "line": 31, "column": 16 } } @@ -1187,11 +1344,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 28, + "line": 31, "column": 30 }, "end": { - "line": 28, + "line": 31, "column": 34 } } @@ -1202,11 +1359,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 35 }, "end": { - "line": 28, + "line": 31, "column": 37 } } @@ -1215,11 +1372,11 @@ "optional": false, "loc": { "start": { - "line": 28, + "line": 31, "column": 30 }, "end": { - "line": 28, + "line": 31, "column": 37 } } @@ -1228,11 +1385,11 @@ "optional": false, "loc": { "start": { - "line": 28, + "line": 31, "column": 30 }, "end": { - "line": 28, + "line": 31, "column": 39 } } @@ -1247,11 +1404,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 43 }, "end": { - "line": 28, + "line": 31, "column": 44 } } @@ -1269,33 +1426,33 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 45 }, "end": { - "line": 28, + "line": 31, "column": 51 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 45 }, "end": { - "line": 28, + "line": 31, "column": 52 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 45 }, "end": { - "line": 28, + "line": 31, "column": 52 } } @@ -1303,55 +1460,55 @@ ], "loc": { "start": { - "line": 28, + "line": 31, "column": 44 }, "end": { - "line": 28, + "line": 31, "column": 52 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 43 }, "end": { - "line": 28, + "line": 31, "column": 53 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 43 }, "end": { - "line": 28, + "line": 31, "column": 53 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 30 }, "end": { - "line": 28, + "line": 31, "column": 39 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 13 }, "end": { - "line": 28, + "line": 31, "column": 39 } } @@ -1360,11 +1517,11 @@ "kind": "let", "loc": { "start": { - "line": 28, + "line": 31, "column": 9 }, "end": { - "line": 28, + "line": 31, "column": 53 } } @@ -1384,11 +1541,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 32, "column": 13 }, "end": { - "line": 29, + "line": 32, "column": 16 } } @@ -1399,11 +1556,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 32, "column": 17 }, "end": { - "line": 29, + "line": 32, "column": 19 } } @@ -1412,11 +1569,11 @@ "optional": false, "loc": { "start": { - "line": 29, + "line": 32, "column": 13 }, "end": { - "line": 29, + "line": 32, "column": 19 } } @@ -1425,11 +1582,11 @@ "optional": false, "loc": { "start": { - "line": 29, + "line": 32, "column": 13 }, "end": { - "line": 29, + "line": 32, "column": 21 } } @@ -1439,22 +1596,22 @@ "value": null, "loc": { "start": { - "line": 29, + "line": 32, "column": 25 }, "end": { - "line": 29, + "line": 32, "column": 29 } } }, "loc": { "start": { - "line": 29, + "line": 32, "column": 13 }, "end": { - "line": 29, + "line": 32, "column": 29 } } @@ -1464,11 +1621,11 @@ "statements": [], "loc": { "start": { - "line": 29, + "line": 32, "column": 31 }, "end": { - "line": 29, + "line": 32, "column": 33 } } @@ -1476,11 +1633,11 @@ "alternate": null, "loc": { "start": { - "line": 29, + "line": 32, "column": 9 }, "end": { - "line": 29, + "line": 32, "column": 33 } } @@ -1488,33 +1645,33 @@ ], "loc": { "start": { - "line": 27, + "line": 30, "column": 26 }, "end": { - "line": 30, + "line": 33, "column": 6 } } }, "loc": { "start": { - "line": 27, + "line": 30, "column": 16 }, "end": { - "line": 30, + "line": 33, "column": 6 } } }, "loc": { "start": { - "line": 27, + "line": 30, "column": 16 }, "end": { - "line": 30, + "line": 33, "column": 6 } } @@ -1523,11 +1680,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 30, "column": 5 }, "end": { - "line": 30, + "line": 33, "column": 6 } } @@ -1540,11 +1697,11 @@ "decorators": [], "loc": { "start": { - "line": 32, + "line": 35, "column": 13 }, "end": { - "line": 32, + "line": 35, "column": 15 } } @@ -1564,11 +1721,11 @@ "decorators": [], "loc": { "start": { - "line": 32, + "line": 35, "column": 13 }, "end": { - "line": 32, + "line": 35, "column": 15 } } @@ -1587,33 +1744,33 @@ "decorators": [], "loc": { "start": { - "line": 32, + "line": 35, "column": 20 }, "end": { - "line": 32, + "line": 35, "column": 26 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 20 }, "end": { - "line": 32, + "line": 35, "column": 28 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 20 }, "end": { - "line": 32, + "line": 35, "column": 28 } } @@ -1635,33 +1792,33 @@ "decorators": [], "loc": { "start": { - "line": 32, + "line": 35, "column": 40 }, "end": { - "line": 32, + "line": 35, "column": 46 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 40 }, "end": { - "line": 32, + "line": 35, "column": 47 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 40 }, "end": { - "line": 32, + "line": 35, "column": 47 } } @@ -1669,22 +1826,22 @@ "arguments": [], "loc": { "start": { - "line": 32, + "line": 35, "column": 36 }, "end": { - "line": 32, + "line": 35, "column": 49 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 29 }, "end": { - "line": 32, + "line": 35, "column": 49 } } @@ -1692,33 +1849,33 @@ ], "loc": { "start": { - "line": 32, + "line": 35, "column": 27 }, "end": { - "line": 32, + "line": 35, "column": 51 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 15 }, "end": { - "line": 32, + "line": 35, "column": 51 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 15 }, "end": { - "line": 32, + "line": 35, "column": 51 } } @@ -1727,11 +1884,11 @@ "decorators": [], "loc": { "start": { - "line": 32, + "line": 35, "column": 5 }, "end": { - "line": 32, + "line": 35, "column": 51 } } @@ -1820,11 +1977,11 @@ "decorators": [], "loc": { "start": { - "line": 33, + "line": 36, "column": 2 }, "end": { - "line": 33, + "line": 36, "column": 2 } } @@ -1832,22 +1989,22 @@ ], "loc": { "start": { - "line": 23, + "line": 26, "column": 9 }, "end": { - "line": 33, + "line": 36, "column": 2 } } }, "loc": { "start": { - "line": 23, + "line": 26, "column": 1 }, "end": { - "line": 33, + "line": 36, "column": 2 } } @@ -1997,7 +2154,7 @@ "column": 1 }, "end": { - "line": 34, + "line": 37, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_1.sts b/ets2panda/test/compiler/ets/generics_instantiation_1.sts index 447c496490..df2dda044c 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_1.sts +++ b/ets2panda/test/compiler/ets/generics_instantiation_1.sts @@ -15,6 +15,9 @@ class B { private a0: T; + constructor(a0: T) { + this.a0 = a0; + } public f1(): T { return this.a0; } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt b/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt index 757b511447..640fc2d1a9 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt +++ b/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt @@ -447,6 +447,20 @@ } } }, + "value": { + "type": "ArrayExpression", + "elements": [], + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, "accessibility": "private", "static": false, "readonly": false, @@ -499,11 +513,11 @@ "loc": { "start": { "line": 21, - "column": 22 + "column": 23 }, "end": { "line": 21, - "column": 23 + "column": 24 } } }, @@ -516,7 +530,7 @@ }, "end": { "line": 21, - "column": 23 + "column": 27 } } }, diff --git a/ets2panda/test/compiler/ets/generics_instantiation_3.sts b/ets2panda/test/compiler/ets/generics_instantiation_3.sts index 6a6fe0e309..02120a2c01 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_3.sts +++ b/ets2panda/test/compiler/ets/generics_instantiation_3.sts @@ -18,5 +18,5 @@ class A { this.data[2].equals(e); } - private data: T[]; + private data: T[] = []; } diff --git a/ets2panda/test/compiler/ets/generics_interface_bounds_1-expected.txt b/ets2panda/test/compiler/ets/generics_interface_bounds_1-expected.txt index 366732cf5e..457829d12b 100644 --- a/ets2panda/test/compiler/ets/generics_interface_bounds_1-expected.txt +++ b/ets2panda/test/compiler/ets/generics_interface_bounds_1-expected.txt @@ -494,15 +494,265 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "bar", + "name": "constructor", "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "my_var", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "U", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 17 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 17 + }, + "end": { + "line": 23, + "column": 27 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "my_var", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 14 + }, + "end": { + "line": 24, + "column": 20 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 20 + } + } + }, + "right": { + "type": "Identifier", + "name": "my_var", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 23 + }, + "end": { + "line": 24, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 30 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 28 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, "loc": { "start": { "line": 23, + "column": 16 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "bar", + "decorators": [], + "loc": { + "start": { + "line": 27, "column": 5 }, "end": { - "line": 23, + "line": 27, "column": 8 } } @@ -522,11 +772,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 27, "column": 5 }, "end": { - "line": 23, + "line": 27, "column": 8 } } @@ -539,11 +789,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 23, + "line": 27, "column": 12 }, "end": { - "line": 23, + "line": 27, "column": 16 } } @@ -569,33 +819,33 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 28, "column": 16 }, "end": { - "line": 24, + "line": 28, "column": 22 } } }, "loc": { "start": { - "line": 24, + "line": 28, "column": 16 }, "end": { - "line": 24, + "line": 28, "column": 24 } } }, "loc": { "start": { - "line": 24, + "line": 28, "column": 16 }, "end": { - "line": 24, + "line": 28, "column": 24 } } @@ -603,11 +853,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 28, "column": 13 }, "end": { - "line": 24, + "line": 28, "column": 14 } } @@ -618,11 +868,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 24, + "line": 28, "column": 25 }, "end": { - "line": 24, + "line": 28, "column": 29 } } @@ -633,11 +883,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 28, "column": 30 }, "end": { - "line": 24, + "line": 28, "column": 36 } } @@ -646,22 +896,22 @@ "optional": false, "loc": { "start": { - "line": 24, + "line": 28, "column": 25 }, "end": { - "line": 24, + "line": 28, "column": 36 } } }, "loc": { "start": { - "line": 24, + "line": 28, "column": 13 }, "end": { - "line": 24, + "line": 28, "column": 36 } } @@ -670,11 +920,11 @@ "kind": "let", "loc": { "start": { - "line": 24, + "line": 28, "column": 9 }, "end": { - "line": 24, + "line": 28, "column": 37 } } @@ -682,33 +932,33 @@ ], "loc": { "start": { - "line": 23, + "line": 27, "column": 17 }, "end": { - "line": 25, + "line": 29, "column": 6 } } }, "loc": { "start": { - "line": 23, + "line": 27, "column": 8 }, "end": { - "line": 25, + "line": 29, "column": 6 } } }, "loc": { "start": { - "line": 23, + "line": 27, "column": 8 }, "end": { - "line": 25, + "line": 29, "column": 6 } } @@ -717,107 +967,14 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 27, "column": 5 }, "end": { - "line": 25, + "line": 29, "column": 6 } } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "constructor", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 2 - }, - "end": { - "line": 26, - "column": 2 - } - } } ], "loc": { @@ -826,7 +983,7 @@ "column": 29 }, "end": { - "line": 26, + "line": 30, "column": 2 } } @@ -837,7 +994,7 @@ "column": 1 }, "end": { - "line": 26, + "line": 30, "column": 2 } } @@ -987,7 +1144,7 @@ "column": 1 }, "end": { - "line": 27, + "line": 31, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/generics_interface_bounds_1.sts b/ets2panda/test/compiler/ets/generics_interface_bounds_1.sts index 0b3b0d7244..7848a494f1 100644 --- a/ets2panda/test/compiler/ets/generics_interface_bounds_1.sts +++ b/ets2panda/test/compiler/ets/generics_interface_bounds_1.sts @@ -20,6 +20,10 @@ interface A{ class B>{ private my_var: U; + constructor(my_var: U) { + this.my_var = my_var; + } + bar(): void { let a: Object = this.my_var; } diff --git a/ets2panda/test/compiler/ets/identifierReference4-expected.txt b/ets2panda/test/compiler/ets/identifierReference4-expected.txt index 184b2438b9..117466c0f0 100644 --- a/ets2panda/test/compiler/ets/identifierReference4-expected.txt +++ b/ets2panda/test/compiler/ets/identifierReference4-expected.txt @@ -39,6 +39,20 @@ } } }, + "value": { + "type": "StringLiteral", + "value": "", + "loc": { + "start": { + "line": 19, + "column": 15 + }, + "end": { + "line": 19, + "column": 17 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -71,7 +85,7 @@ }, "end": { "line": 19, - "column": 13 + "column": 14 } } }, @@ -82,7 +96,7 @@ }, "end": { "line": 19, - "column": 13 + "column": 14 } } }, @@ -95,7 +109,7 @@ }, "end": { "line": 19, - "column": 13 + "column": 17 } } }, diff --git a/ets2panda/test/compiler/ets/identifierReference4.sts b/ets2panda/test/compiler/ets/identifierReference4.sts index 31b505d489..2acdc44525 100644 --- a/ets2panda/test/compiler/ets/identifierReference4.sts +++ b/ets2panda/test/compiler/ets/identifierReference4.sts @@ -16,7 +16,7 @@ let a: int = 1; class B { - a: String; + a: String = ""; } class A extends B { diff --git a/ets2panda/test/compiler/ets/invalidInheritance3-expected.txt b/ets2panda/test/compiler/ets/invalidInheritance3-expected.txt index 94dd696480..9689d7f00c 100644 --- a/ets2panda/test/compiler/ets/invalidInheritance3-expected.txt +++ b/ets2panda/test/compiler/ets/invalidInheritance3-expected.txt @@ -39,6 +39,149 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "a", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 17, + "column": 39 + }, + "end": { + "line": 17, + "column": 42 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 36 + }, + "end": { + "line": 17, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 36 + }, + "end": { + "line": 17, + "column": 42 + } + } + }, + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "b", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 17, + "column": 47 + }, + "end": { + "line": 17, + "column": 50 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 44 + }, + "end": { + "line": 17, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 44 + }, + "end": { + "line": 17, + "column": 50 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": null, + "loc": { + "start": { + "line": 17, + "column": 57 + }, + "end": { + "line": 17, + "column": 63 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 55 + }, + "end": { + "line": 17, + "column": 65 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 35 + }, + "end": { + "line": 17, + "column": 65 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 35 + }, + "end": { + "line": 17, + "column": 65 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -164,7 +307,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 65 } } }, diff --git a/ets2panda/test/compiler/ets/invalidInheritance3.sts b/ets2panda/test/compiler/ets/invalidInheritance3.sts index 9740cce9e0..0d96775fa4 100644 --- a/ets2panda/test/compiler/ets/invalidInheritance3.sts +++ b/ets2panda/test/compiler/ets/invalidInheritance3.sts @@ -14,7 +14,7 @@ */ class A { - a: (a: int, b: int) => void; + a: (a: int, b: int) => void = (a: int, b: int) => { return }; } class B extends A { diff --git a/ets2panda/test/compiler/ets/lowering-interaction-expected.txt b/ets2panda/test/compiler/ets/lowering-interaction-expected.txt index 190e0b48fd..8c44169256 100644 --- a/ets2panda/test/compiler/ets/lowering-interaction-expected.txt +++ b/ets2panda/test/compiler/ets/lowering-interaction-expected.txt @@ -176,6 +176,61 @@ } } }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 20 + }, + "end": { + "line": 19, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 20 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 20 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -207,8 +262,8 @@ "column": 12 }, "end": { - "line": 20, - "column": 2 + "line": 19, + "column": 15 } } }, @@ -218,8 +273,8 @@ "column": 12 }, "end": { - "line": 20, - "column": 2 + "line": 19, + "column": 15 } } }, diff --git a/ets2panda/test/compiler/ets/lowering-interaction.sts b/ets2panda/test/compiler/ets/lowering-interaction.sts index 8afc147d60..4f4b3e557f 100644 --- a/ets2panda/test/compiler/ets/lowering-interaction.sts +++ b/ets2panda/test/compiler/ets/lowering-interaction.sts @@ -16,7 +16,7 @@ class C {} class IR { - value: C + value: C = new C() } class CIterator { diff --git a/ets2panda/test/compiler/ets/tuple_types_19-expected.txt b/ets2panda/test/compiler/ets/tuple_types_19-expected.txt index c1e89ef573..6e894269ec 100644 --- a/ets2panda/test/compiler/ets/tuple_types_19-expected.txt +++ b/ets2panda/test/compiler/ets/tuple_types_19-expected.txt @@ -210,7 +210,7 @@ }, "end": { "line": 18, - "column": 11 + "column": 16 } } }, @@ -223,7 +223,7 @@ }, "end": { "line": 18, - "column": 11 + "column": 16 } } }, @@ -231,20 +231,20 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "provide", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 18, - "column": 12 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 19 + "line": 1, + "column": 1 } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", "static": false, "optional": false, @@ -255,177 +255,235 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "provide", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 18, - "column": 12 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 19 + "line": 1, + "column": 1 } } }, "generator": false, "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSTuple", - "types": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "X", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 24 + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "value", + "typeAnnotation": { + "type": "ETSTuple", + "types": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "X", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 27 + } + } }, - "end": { - "line": 18, - "column": 25 + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 27 + } } - } - }, - "loc": { - "start": { - "line": 18, - "column": 24 }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Y", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 27 + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Y", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 30 + } + } }, - "end": { - "line": 18, - "column": 28 + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 30 + } } } - }, + ], + "spreadType": null, "loc": { "start": { "line": 18, - "column": 27 + "column": 24 }, "end": { "line": 18, - "column": 29 + "column": 31 } } }, + "decorators": [], "loc": { "start": { "line": 18, - "column": 27 + "column": 17 }, "end": { "line": 18, - "column": 29 + "column": 31 } } - } - ], - "spreadType": null, - "loc": { - "start": { - "line": 18, - "column": 23 }, - "end": { - "line": 18, - "column": 31 + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 31 + } } } - }, + ], "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 18, + "column": 34 + }, + "end": { + "line": 18, + "column": 38 + } + } + }, + "property": { + "type": "Identifier", + "name": "one", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 39 + }, + "end": { + "line": 18, + "column": 42 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 18, - "column": 39 + "column": 34 }, "end": { "line": 18, - "column": 43 + "column": 42 } } }, - "property": { + "right": { "type": "Identifier", - "name": "one", + "name": "value", "decorators": [], "loc": { "start": { "line": 18, - "column": 44 + "column": 45 }, "end": { "line": 18, - "column": 47 + "column": 50 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 18, - "column": 39 + "column": 34 }, "end": { "line": 18, - "column": 47 + "column": 50 } } }, "loc": { "start": { "line": 18, - "column": 32 + "column": 34 }, "end": { "line": 18, - "column": 48 + "column": 51 } } } @@ -433,33 +491,33 @@ "loc": { "start": { "line": 18, - "column": 30 + "column": 32 }, "end": { "line": 18, - "column": 50 + "column": 52 } } }, "loc": { "start": { "line": 18, - "column": 19 + "column": 16 }, "end": { "line": 18, - "column": 50 + "column": 52 } } }, "loc": { "start": { "line": 18, - "column": 19 + "column": 16 }, "end": { "line": 18, - "column": 50 + "column": 52 } } }, @@ -472,7 +530,7 @@ }, "end": { "line": 18, - "column": 50 + "column": 52 } } }, @@ -480,20 +538,21 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "constructor", + "name": "provide", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 19 } } }, - "kind": "constructor", + "kind": "method", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -503,56 +562,211 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "constructor", + "name": "provide", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 19 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTuple", + "types": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "X", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 24 + }, + "end": { + "line": 19, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 24 + }, + "end": { + "line": 19, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 24 + }, + "end": { + "line": 19, + "column": 26 + } + } + }, + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Y", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 27 + }, + "end": { + "line": 19, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 27 + }, + "end": { + "line": 19, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 27 + }, + "end": { + "line": 19, + "column": 29 + } + } + } + ], + "spreadType": null, + "loc": { + "start": { + "line": 19, + "column": 23 + }, + "end": { + "line": 19, + "column": 31 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 19, + "column": 39 + }, + "end": { + "line": 19, + "column": 43 + } + } + }, + "property": { + "type": "Identifier", + "name": "one", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 44 + }, + "end": { + "line": 19, + "column": 47 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 19, + "column": 39 + }, + "end": { + "line": 19, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 32 + }, + "end": { + "line": 19, + "column": 48 + } + } } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], + ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 30 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 50 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 19 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 50 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 19 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 50 } } }, @@ -561,11 +775,11 @@ "loc": { "start": { "line": 19, - "column": 2 + "column": 5 }, "end": { "line": 19, - "column": 2 + "column": 50 } } } @@ -576,7 +790,7 @@ "column": 23 }, "end": { - "line": 19, + "line": 20, "column": 2 } } @@ -587,7 +801,7 @@ "column": 1 }, "end": { - "line": 19, + "line": 20, "column": 2 } } @@ -601,11 +815,11 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 22, "column": 7 }, "end": { - "line": 21, + "line": 22, "column": 20 } } @@ -621,22 +835,22 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 22, "column": 21 }, "end": { - "line": 21, + "line": 22, "column": 22 } } }, "loc": { "start": { - "line": 21, + "line": 22, "column": 21 }, "end": { - "line": 21, + "line": 22, "column": 23 } } @@ -644,11 +858,11 @@ ], "loc": { "start": { - "line": 21, + "line": 22, "column": 20 }, "end": { - "line": 21, + "line": 22, "column": 23 } } @@ -664,11 +878,11 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 23, "column": 5 }, "end": { - "line": 22, + "line": 23, "column": 9 } } @@ -692,33 +906,33 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 23, "column": 12 }, "end": { - "line": 22, + "line": 23, "column": 13 } } }, "loc": { "start": { - "line": 22, + "line": 23, "column": 12 }, "end": { - "line": 22, + "line": 23, "column": 14 } } }, "loc": { "start": { - "line": 22, + "line": 23, "column": 12 }, "end": { - "line": 22, + "line": 23, "column": 14 } } @@ -733,33 +947,33 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 23, "column": 15 }, "end": { - "line": 22, + "line": 23, "column": 16 } } }, "loc": { "start": { - "line": 22, + "line": 23, "column": 15 }, "end": { - "line": 22, + "line": 23, "column": 17 } } }, "loc": { "start": { - "line": 22, + "line": 23, "column": 15 }, "end": { - "line": 22, + "line": 23, "column": 17 } } @@ -768,11 +982,11 @@ "spreadType": null, "loc": { "start": { - "line": 22, + "line": 23, "column": 11 }, "end": { - "line": 22, + "line": 23, "column": 18 } } @@ -781,11 +995,11 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 23, "column": 5 }, "end": { - "line": 22, + "line": 23, "column": 18 } } @@ -853,33 +1067,33 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 24, "column": 25 }, "end": { - "line": 23, + "line": 24, "column": 26 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 25 }, "end": { - "line": 23, + "line": 24, "column": 27 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 25 }, "end": { - "line": 23, + "line": 24, "column": 27 } } @@ -894,33 +1108,33 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 24, "column": 28 }, "end": { - "line": 23, + "line": 24, "column": 29 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 28 }, "end": { - "line": 23, + "line": 24, "column": 30 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 28 }, "end": { - "line": 23, + "line": 24, "column": 30 } } @@ -929,11 +1143,11 @@ "spreadType": null, "loc": { "start": { - "line": 23, + "line": 24, "column": 24 }, "end": { - "line": 23, + "line": 24, "column": 31 } } @@ -941,22 +1155,22 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 24, "column": 17 }, "end": { - "line": 23, + "line": 24, "column": 31 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 17 }, "end": { - "line": 23, + "line": 24, "column": 31 } } @@ -976,11 +1190,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 23, + "line": 24, "column": 34 }, "end": { - "line": 23, + "line": 24, "column": 38 } } @@ -991,11 +1205,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 24, "column": 39 }, "end": { - "line": 23, + "line": 24, "column": 43 } } @@ -1004,11 +1218,11 @@ "optional": false, "loc": { "start": { - "line": 23, + "line": 24, "column": 34 }, "end": { - "line": 23, + "line": 24, "column": 43 } } @@ -1019,33 +1233,33 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 24, "column": 46 }, "end": { - "line": 23, + "line": 24, "column": 51 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 34 }, "end": { - "line": 23, + "line": 24, "column": 51 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 34 }, "end": { - "line": 23, + "line": 24, "column": 52 } } @@ -1053,33 +1267,33 @@ ], "loc": { "start": { - "line": 23, + "line": 24, "column": 32 }, "end": { - "line": 23, + "line": 24, "column": 53 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 16 }, "end": { - "line": 23, + "line": 24, "column": 53 } } }, "loc": { "start": { - "line": 23, + "line": 24, "column": 16 }, "end": { - "line": 23, + "line": 24, "column": 53 } } @@ -1088,11 +1302,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 24, "column": 5 }, "end": { - "line": 23, + "line": 24, "column": 53 } } @@ -1105,11 +1319,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 25, "column": 12 }, "end": { - "line": 24, + "line": 25, "column": 19 } } @@ -1129,11 +1343,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 25, "column": 12 }, "end": { - "line": 24, + "line": 25, "column": 19 } } @@ -1155,33 +1369,33 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 25, "column": 24 }, "end": { - "line": 24, + "line": 25, "column": 25 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 24 }, "end": { - "line": 24, + "line": 25, "column": 26 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 24 }, "end": { - "line": 24, + "line": 25, "column": 26 } } @@ -1196,33 +1410,33 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 25, "column": 27 }, "end": { - "line": 24, + "line": 25, "column": 28 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 27 }, "end": { - "line": 24, + "line": 25, "column": 29 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 27 }, "end": { - "line": 24, + "line": 25, "column": 29 } } @@ -1231,11 +1445,11 @@ "spreadType": null, "loc": { "start": { - "line": 24, + "line": 25, "column": 23 }, "end": { - "line": 24, + "line": 25, "column": 31 } } @@ -1251,11 +1465,11 @@ "type": "ThisExpression", "loc": { "start": { - "line": 24, + "line": 25, "column": 39 }, "end": { - "line": 24, + "line": 25, "column": 43 } } @@ -1266,11 +1480,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 25, "column": 44 }, "end": { - "line": 24, + "line": 25, "column": 48 } } @@ -1279,22 +1493,22 @@ "optional": false, "loc": { "start": { - "line": 24, + "line": 25, "column": 39 }, "end": { - "line": 24, + "line": 25, "column": 48 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 32 }, "end": { - "line": 24, + "line": 25, "column": 49 } } @@ -1302,33 +1516,33 @@ ], "loc": { "start": { - "line": 24, + "line": 25, "column": 30 }, "end": { - "line": 24, + "line": 25, "column": 51 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 19 }, "end": { - "line": 24, + "line": 25, "column": 51 } } }, "loc": { "start": { - "line": 24, + "line": 25, "column": 19 }, "end": { - "line": 24, + "line": 25, "column": 51 } } @@ -1337,11 +1551,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 25, "column": 5 }, "end": { - "line": 24, + "line": 25, "column": 51 } } @@ -1349,22 +1563,22 @@ ], "loc": { "start": { - "line": 21, + "line": 22, "column": 24 }, "end": { - "line": 25, + "line": 26, "column": 2 } } }, "loc": { "start": { - "line": 21, + "line": 22, "column": 1 }, "end": { - "line": 25, + "line": 26, "column": 2 } } @@ -1492,11 +1706,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 28, "column": 10 }, "end": { - "line": 27, + "line": 28, "column": 13 } } @@ -1516,11 +1730,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 28, "column": 10 }, "end": { - "line": 27, + "line": 28, "column": 13 } } @@ -1553,33 +1767,33 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 29, "column": 22 }, "end": { - "line": 28, + "line": 29, "column": 28 } } }, "loc": { "start": { - "line": 28, + "line": 29, "column": 22 }, "end": { - "line": 28, + "line": 29, "column": 29 } } }, "loc": { "start": { - "line": 28, + "line": 29, "column": 22 }, "end": { - "line": 28, + "line": 29, "column": 29 } } @@ -1594,33 +1808,33 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 29, "column": 30 }, "end": { - "line": 28, + "line": 29, "column": 36 } } }, "loc": { "start": { - "line": 28, + "line": 29, "column": 30 }, "end": { - "line": 28, + "line": 29, "column": 37 } } }, "loc": { "start": { - "line": 28, + "line": 29, "column": 30 }, "end": { - "line": 28, + "line": 29, "column": 37 } } @@ -1629,11 +1843,11 @@ "spreadType": null, "loc": { "start": { - "line": 28, + "line": 29, "column": 21 }, "end": { - "line": 28, + "line": 29, "column": 39 } } @@ -1641,11 +1855,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 29, "column": 9 }, "end": { - "line": 28, + "line": 29, "column": 19 } } @@ -1658,11 +1872,11 @@ "value": 42, "loc": { "start": { - "line": 28, + "line": 29, "column": 41 }, "end": { - "line": 28, + "line": 29, "column": 45 } } @@ -1672,11 +1886,11 @@ "value": 43, "loc": { "start": { - "line": 28, + "line": 29, "column": 47 }, "end": { - "line": 28, + "line": 29, "column": 51 } } @@ -1684,22 +1898,22 @@ ], "loc": { "start": { - "line": 28, + "line": 29, "column": 40 }, "end": { - "line": 28, + "line": 29, "column": 52 } } }, "loc": { "start": { - "line": 28, + "line": 29, "column": 9 }, "end": { - "line": 28, + "line": 29, "column": 52 } } @@ -1708,11 +1922,11 @@ "kind": "let", "loc": { "start": { - "line": 28, + "line": 29, "column": 5 }, "end": { - "line": 28, + "line": 29, "column": 53 } } @@ -1735,11 +1949,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 30, "column": 13 }, "end": { - "line": 29, + "line": 30, "column": 26 } } @@ -1757,33 +1971,33 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 30, "column": 27 }, "end": { - "line": 29, + "line": 30, "column": 33 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 27 }, "end": { - "line": 29, + "line": 30, "column": 34 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 27 }, "end": { - "line": 29, + "line": 30, "column": 34 } } @@ -1791,33 +2005,33 @@ ], "loc": { "start": { - "line": 29, + "line": 30, "column": 26 }, "end": { - "line": 29, + "line": 30, "column": 34 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 13 }, "end": { - "line": 29, + "line": 30, "column": 36 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 13 }, "end": { - "line": 29, + "line": 30, "column": 36 } } @@ -1825,11 +2039,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 30, "column": 9 }, "end": { - "line": 29, + "line": 30, "column": 11 } } @@ -1846,11 +2060,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 30, "column": 41 }, "end": { - "line": 29, + "line": 30, "column": 54 } } @@ -1868,33 +2082,33 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 30, "column": 55 }, "end": { - "line": 29, + "line": 30, "column": 61 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 55 }, "end": { - "line": 29, + "line": 30, "column": 62 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 55 }, "end": { - "line": 29, + "line": 30, "column": 62 } } @@ -1902,33 +2116,33 @@ ], "loc": { "start": { - "line": 29, + "line": 30, "column": 54 }, "end": { - "line": 29, + "line": 30, "column": 62 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 41 }, "end": { - "line": 29, + "line": 30, "column": 63 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 41 }, "end": { - "line": 29, + "line": 30, "column": 63 } } @@ -1940,11 +2154,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 30, "column": 63 }, "end": { - "line": 29, + "line": 30, "column": 73 } } @@ -1952,22 +2166,22 @@ ], "loc": { "start": { - "line": 29, + "line": 30, "column": 37 }, "end": { - "line": 29, + "line": 30, "column": 75 } } }, "loc": { "start": { - "line": 29, + "line": 30, "column": 9 }, "end": { - "line": 29, + "line": 30, "column": 75 } } @@ -1976,11 +2190,11 @@ "kind": "let", "loc": { "start": { - "line": 29, + "line": 30, "column": 5 }, "end": { - "line": 29, + "line": 30, "column": 75 } } @@ -2006,33 +2220,33 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 31, "column": 18 }, "end": { - "line": 30, + "line": 31, "column": 24 } } }, "loc": { "start": { - "line": 30, + "line": 31, "column": 18 }, "end": { - "line": 30, + "line": 31, "column": 25 } } }, "loc": { "start": { - "line": 30, + "line": 31, "column": 18 }, "end": { - "line": 30, + "line": 31, "column": 25 } } @@ -2047,33 +2261,33 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 31, "column": 26 }, "end": { - "line": 30, + "line": 31, "column": 32 } } }, "loc": { "start": { - "line": 30, + "line": 31, "column": 26 }, "end": { - "line": 30, + "line": 31, "column": 33 } } }, "loc": { "start": { - "line": 30, + "line": 31, "column": 26 }, "end": { - "line": 30, + "line": 31, "column": 33 } } @@ -2082,11 +2296,11 @@ "spreadType": null, "loc": { "start": { - "line": 30, + "line": 31, "column": 17 }, "end": { - "line": 30, + "line": 31, "column": 35 } } @@ -2094,11 +2308,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 31, "column": 9 }, "end": { - "line": 30, + "line": 31, "column": 15 } } @@ -2113,11 +2327,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 31, "column": 36 }, "end": { - "line": 30, + "line": 31, "column": 38 } } @@ -2128,11 +2342,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 31, "column": 39 }, "end": { - "line": 30, + "line": 31, "column": 46 } } @@ -2141,11 +2355,11 @@ "optional": false, "loc": { "start": { - "line": 30, + "line": 31, "column": 36 }, "end": { - "line": 30, + "line": 31, "column": 46 } } @@ -2154,22 +2368,22 @@ "optional": false, "loc": { "start": { - "line": 30, + "line": 31, "column": 36 }, "end": { - "line": 30, + "line": 31, "column": 48 } } }, "loc": { "start": { - "line": 30, + "line": 31, "column": 9 }, "end": { - "line": 30, + "line": 31, "column": 48 } } @@ -2178,11 +2392,11 @@ "kind": "let", "loc": { "start": { - "line": 30, + "line": 31, "column": 5 }, "end": { - "line": 30, + "line": 31, "column": 49 } } @@ -2190,33 +2404,33 @@ ], "loc": { "start": { - "line": 27, + "line": 28, "column": 16 }, "end": { - "line": 31, + "line": 32, "column": 2 } } }, "loc": { "start": { - "line": 27, + "line": 28, "column": 13 }, "end": { - "line": 31, + "line": 32, "column": 2 } } }, "loc": { "start": { - "line": 27, + "line": 28, "column": 13 }, "end": { - "line": 31, + "line": 32, "column": 2 } } @@ -2225,11 +2439,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 28, "column": 1 }, "end": { - "line": 31, + "line": 32, "column": 2 } } @@ -2264,7 +2478,7 @@ "column": 1 }, "end": { - "line": 32, + "line": 33, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/tuple_types_19.sts b/ets2panda/test/compiler/ets/tuple_types_19.sts index 5d1bf573da..7d6526e8ca 100644 --- a/ets2panda/test/compiler/ets/tuple_types_19.sts +++ b/ets2panda/test/compiler/ets/tuple_types_19.sts @@ -15,6 +15,7 @@ class TuplePair { one: [X, Y] + constructor(value: [X, Y]) { this.one = value;} public provide(): [X, Y] { return this.one; } } diff --git a/ets2panda/test/compiler/ets/union_types_5-expected.txt b/ets2panda/test/compiler/ets/union_types_5-expected.txt index f503ba0d24..523f377f4b 100644 --- a/ets2panda/test/compiler/ets/union_types_5-expected.txt +++ b/ets2panda/test/compiler/ets/union_types_5-expected.txt @@ -201,6 +201,7 @@ } }, "kind": "constructor", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -226,40 +227,196 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "union0", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 27 + } + } + } + ], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "union0", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + "right": { + "type": "Identifier", + "name": "union0", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 23 + }, + "end": { + "line": 19, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 29 + } + } + } + ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 28 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 6 } } }, @@ -268,11 +425,11 @@ "loc": { "start": { "line": 18, - "column": 2 + "column": 5 }, "end": { - "line": 18, - "column": 2 + "line": 20, + "column": 6 } } } @@ -283,7 +440,7 @@ "column": 27 }, "end": { - "line": 18, + "line": 21, "column": 2 } } @@ -294,7 +451,7 @@ "column": 1 }, "end": { - "line": 18, + "line": 21, "column": 2 } } @@ -308,11 +465,11 @@ "decorators": [], "loc": { "start": { - "line": 19, + "line": 22, "column": 7 }, "end": { - "line": 19, + "line": 22, "column": 8 } } @@ -328,11 +485,11 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 23, "column": 5 }, "end": { - "line": 20, + "line": 23, "column": 8 } } @@ -342,11 +499,11 @@ "value": 42, "loc": { "start": { - "line": 20, + "line": 23, "column": 16 }, "end": { - "line": 20, + "line": 23, "column": 18 } } @@ -361,11 +518,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 20, + "line": 23, "column": 10 }, "end": { - "line": 20, + "line": 23, "column": 13 } } @@ -374,11 +531,11 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 23, "column": 5 }, "end": { - "line": 20, + "line": 23, "column": 18 } } @@ -467,11 +624,11 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 24, "column": 2 }, "end": { - "line": 21, + "line": 24, "column": 2 } } @@ -479,22 +636,22 @@ ], "loc": { "start": { - "line": 19, + "line": 22, "column": 9 }, "end": { - "line": 21, + "line": 24, "column": 2 } } }, "loc": { "start": { - "line": 19, + "line": 22, "column": 1 }, "end": { - "line": 21, + "line": 24, "column": 2 } } @@ -508,11 +665,11 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 25, "column": 7 }, "end": { - "line": 22, + "line": 25, "column": 8 } } @@ -528,11 +685,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 26, "column": 5 }, "end": { - "line": 23, + "line": 26, "column": 8 } } @@ -542,11 +699,11 @@ "value": 43, "loc": { "start": { - "line": 23, + "line": 26, "column": 16 }, "end": { - "line": 23, + "line": 26, "column": 18 } } @@ -561,11 +718,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 23, + "line": 26, "column": 10 }, "end": { - "line": 23, + "line": 26, "column": 13 } } @@ -574,11 +731,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 26, "column": 5 }, "end": { - "line": 23, + "line": 26, "column": 18 } } @@ -667,11 +824,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 27, "column": 2 }, "end": { - "line": 24, + "line": 27, "column": 2 } } @@ -679,22 +836,22 @@ ], "loc": { "start": { - "line": 22, + "line": 25, "column": 9 }, "end": { - "line": 24, + "line": 27, "column": 2 } } }, "loc": { "start": { - "line": 22, + "line": 25, "column": 1 }, "end": { - "line": 24, + "line": 27, "column": 2 } } @@ -822,11 +979,11 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 29, "column": 10 }, "end": { - "line": 26, + "line": 29, "column": 13 } } @@ -846,11 +1003,11 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 29, "column": 10 }, "end": { - "line": 26, + "line": 29, "column": 13 } } @@ -877,33 +1034,33 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 29, "column": 17 }, "end": { - "line": 26, + "line": 29, "column": 18 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 17 }, "end": { - "line": 26, + "line": 29, "column": 19 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 17 }, "end": { - "line": 26, + "line": 29, "column": 19 } } @@ -918,33 +1075,33 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 29, "column": 19 }, "end": { - "line": 26, + "line": 29, "column": 20 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 19 }, "end": { - "line": 26, + "line": 29, "column": 21 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 19 }, "end": { - "line": 26, + "line": 29, "column": 21 } } @@ -952,11 +1109,11 @@ ], "loc": { "start": { - "line": 26, + "line": 29, "column": 17 }, "end": { - "line": 26, + "line": 29, "column": 21 } } @@ -964,22 +1121,22 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 29, "column": 14 }, "end": { - "line": 26, + "line": 29, "column": 21 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 14 }, "end": { - "line": 26, + "line": 29, "column": 21 } } @@ -999,11 +1156,11 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 30, "column": 9 }, "end": { - "line": 27, + "line": 30, "column": 10 } } @@ -1018,44 +1175,44 @@ "decorators": [], "loc": { "start": { - "line": 27, + "line": 30, "column": 22 }, "end": { - "line": 27, + "line": 30, "column": 23 } } }, "loc": { "start": { - "line": 27, + "line": 30, "column": 22 }, "end": { - "line": 27, + "line": 30, "column": 24 } } }, "loc": { "start": { - "line": 27, + "line": 30, "column": 22 }, "end": { - "line": 27, + "line": 30, "column": 24 } } }, "loc": { "start": { - "line": 27, + "line": 30, "column": 9 }, "end": { - "line": 27, + "line": 30, "column": 24 } } @@ -1076,11 +1233,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 16 }, "end": { - "line": 28, + "line": 31, "column": 17 } } @@ -1091,11 +1248,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 31, "column": 18 }, "end": { - "line": 28, + "line": 31, "column": 21 } } @@ -1104,11 +1261,11 @@ "optional": false, "loc": { "start": { - "line": 28, + "line": 31, "column": 16 }, "end": { - "line": 28, + "line": 31, "column": 21 } } @@ -1118,22 +1275,22 @@ "value": 42, "loc": { "start": { - "line": 28, + "line": 31, "column": 25 }, "end": { - "line": 28, + "line": 31, "column": 27 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 16 }, "end": { - "line": 28, + "line": 31, "column": 27 } } @@ -1143,22 +1300,22 @@ "value": "Error! num field must be 42", "loc": { "start": { - "line": 28, + "line": 31, "column": 29 }, "end": { - "line": 28, + "line": 31, "column": 58 } } }, "loc": { "start": { - "line": 28, + "line": 31, "column": 9 }, "end": { - "line": 28, + "line": 31, "column": 59 } } @@ -1166,11 +1323,11 @@ ], "loc": { "start": { - "line": 27, + "line": 30, "column": 25 }, "end": { - "line": 29, + "line": 32, "column": 6 } } @@ -1186,11 +1343,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 32, "column": 16 }, "end": { - "line": 29, + "line": 32, "column": 17 } } @@ -1205,44 +1362,44 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 32, "column": 29 }, "end": { - "line": 29, + "line": 32, "column": 30 } } }, "loc": { "start": { - "line": 29, + "line": 32, "column": 29 }, "end": { - "line": 29, + "line": 32, "column": 31 } } }, "loc": { "start": { - "line": 29, + "line": 32, "column": 29 }, "end": { - "line": 29, + "line": 32, "column": 31 } } }, "loc": { "start": { - "line": 29, + "line": 32, "column": 16 }, "end": { - "line": 29, + "line": 32, "column": 31 } } @@ -1263,11 +1420,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 33, "column": 16 }, "end": { - "line": 30, + "line": 33, "column": 17 } } @@ -1278,11 +1435,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 33, "column": 18 }, "end": { - "line": 30, + "line": 33, "column": 21 } } @@ -1291,11 +1448,11 @@ "optional": false, "loc": { "start": { - "line": 30, + "line": 33, "column": 16 }, "end": { - "line": 30, + "line": 33, "column": 21 } } @@ -1305,22 +1462,22 @@ "value": 43, "loc": { "start": { - "line": 30, + "line": 33, "column": 25 }, "end": { - "line": 30, + "line": 33, "column": 27 } } }, "loc": { "start": { - "line": 30, + "line": 33, "column": 16 }, "end": { - "line": 30, + "line": 33, "column": 27 } } @@ -1330,22 +1487,22 @@ "value": "Error! num field must be 43", "loc": { "start": { - "line": 30, + "line": 33, "column": 29 }, "end": { - "line": 30, + "line": 33, "column": 58 } } }, "loc": { "start": { - "line": 30, + "line": 33, "column": 9 }, "end": { - "line": 30, + "line": 33, "column": 59 } } @@ -1353,11 +1510,11 @@ ], "loc": { "start": { - "line": 29, + "line": 32, "column": 32 }, "end": { - "line": 31, + "line": 34, "column": 6 } } @@ -1372,11 +1529,11 @@ "value": false, "loc": { "start": { - "line": 32, + "line": 35, "column": 16 }, "end": { - "line": 32, + "line": 35, "column": 21 } } @@ -1386,22 +1543,22 @@ "value": "Error! x must be instanceof B|C", "loc": { "start": { - "line": 32, + "line": 35, "column": 23 }, "end": { - "line": 32, + "line": 35, "column": 56 } } }, "loc": { "start": { - "line": 32, + "line": 35, "column": 9 }, "end": { - "line": 32, + "line": 35, "column": 57 } } @@ -1409,33 +1566,33 @@ ], "loc": { "start": { - "line": 31, + "line": 34, "column": 12 }, "end": { - "line": 33, + "line": 36, "column": 6 } } }, "loc": { "start": { - "line": 29, + "line": 32, "column": 12 }, "end": { - "line": 33, + "line": 36, "column": 6 } } }, "loc": { "start": { - "line": 27, + "line": 30, "column": 5 }, "end": { - "line": 33, + "line": 36, "column": 6 } } @@ -1443,33 +1600,33 @@ ], "loc": { "start": { - "line": 26, + "line": 29, "column": 22 }, "end": { - "line": 34, + "line": 37, "column": 2 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 13 }, "end": { - "line": 34, + "line": 37, "column": 2 } } }, "loc": { "start": { - "line": 26, + "line": 29, "column": 13 }, "end": { - "line": 34, + "line": 37, "column": 2 } } @@ -1478,11 +1635,11 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 29, "column": 1 }, "end": { - "line": 34, + "line": 37, "column": 2 } } @@ -1495,11 +1652,11 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 10 }, "end": { - "line": 36, + "line": 39, "column": 13 } } @@ -1519,11 +1676,11 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 10 }, "end": { - "line": 36, + "line": 39, "column": 13 } } @@ -1547,11 +1704,11 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 17 }, "end": { - "line": 36, + "line": 39, "column": 18 } } @@ -1572,33 +1729,33 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 19 }, "end": { - "line": 36, + "line": 39, "column": 20 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 19 }, "end": { - "line": 36, + "line": 39, "column": 21 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 19 }, "end": { - "line": 36, + "line": 39, "column": 21 } } @@ -1613,33 +1770,33 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 21 }, "end": { - "line": 36, + "line": 39, "column": 22 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 21 }, "end": { - "line": 36, + "line": 39, "column": 23 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 21 }, "end": { - "line": 36, + "line": 39, "column": 23 } } @@ -1647,11 +1804,11 @@ ], "loc": { "start": { - "line": 36, + "line": 39, "column": 19 }, "end": { - "line": 36, + "line": 39, "column": 23 } } @@ -1659,33 +1816,33 @@ ], "loc": { "start": { - "line": 36, + "line": 39, "column": 18 }, "end": { - "line": 36, + "line": 39, "column": 23 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 17 }, "end": { - "line": 36, + "line": 39, "column": 24 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 17 }, "end": { - "line": 36, + "line": 39, "column": 24 } } @@ -1693,22 +1850,22 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 14 }, "end": { - "line": 36, + "line": 39, "column": 24 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 14 }, "end": { - "line": 36, + "line": 39, "column": 24 } } @@ -1730,11 +1887,11 @@ "decorators": [], "loc": { "start": { - "line": 37, + "line": 40, "column": 9 }, "end": { - "line": 37, + "line": 40, "column": 10 } } @@ -1745,11 +1902,11 @@ "decorators": [], "loc": { "start": { - "line": 37, + "line": 40, "column": 11 }, "end": { - "line": 37, + "line": 40, "column": 17 } } @@ -1758,11 +1915,11 @@ "optional": false, "loc": { "start": { - "line": 37, + "line": 40, "column": 9 }, "end": { - "line": 37, + "line": 40, "column": 17 } } @@ -1777,44 +1934,44 @@ "decorators": [], "loc": { "start": { - "line": 37, + "line": 40, "column": 29 }, "end": { - "line": 37, + "line": 40, "column": 30 } } }, "loc": { "start": { - "line": 37, + "line": 40, "column": 29 }, "end": { - "line": 37, + "line": 40, "column": 31 } } }, "loc": { "start": { - "line": 37, + "line": 40, "column": 29 }, "end": { - "line": 37, + "line": 40, "column": 31 } } }, "loc": { "start": { - "line": 37, + "line": 40, "column": 9 }, "end": { - "line": 37, + "line": 40, "column": 31 } } @@ -1837,11 +1994,11 @@ "decorators": [], "loc": { "start": { - "line": 38, + "line": 41, "column": 16 }, "end": { - "line": 38, + "line": 41, "column": 17 } } @@ -1852,11 +2009,11 @@ "decorators": [], "loc": { "start": { - "line": 38, + "line": 41, "column": 18 }, "end": { - "line": 38, + "line": 41, "column": 24 } } @@ -1865,11 +2022,11 @@ "optional": false, "loc": { "start": { - "line": 38, + "line": 41, "column": 16 }, "end": { - "line": 38, + "line": 41, "column": 24 } } @@ -1880,11 +2037,11 @@ "decorators": [], "loc": { "start": { - "line": 38, + "line": 41, "column": 25 }, "end": { - "line": 38, + "line": 41, "column": 28 } } @@ -1893,11 +2050,11 @@ "optional": false, "loc": { "start": { - "line": 38, + "line": 41, "column": 16 }, "end": { - "line": 38, + "line": 41, "column": 28 } } @@ -1907,22 +2064,22 @@ "value": 42, "loc": { "start": { - "line": 38, + "line": 41, "column": 32 }, "end": { - "line": 38, + "line": 41, "column": 34 } } }, "loc": { "start": { - "line": 38, + "line": 41, "column": 16 }, "end": { - "line": 38, + "line": 41, "column": 34 } } @@ -1932,22 +2089,22 @@ "value": "Error! x.union0.num field must be 42", "loc": { "start": { - "line": 38, + "line": 41, "column": 36 }, "end": { - "line": 38, + "line": 41, "column": 74 } } }, "loc": { "start": { - "line": 38, + "line": 41, "column": 9 }, "end": { - "line": 38, + "line": 41, "column": 75 } } @@ -1955,11 +2112,11 @@ ], "loc": { "start": { - "line": 37, + "line": 40, "column": 32 }, "end": { - "line": 39, + "line": 42, "column": 6 } } @@ -1977,11 +2134,11 @@ "decorators": [], "loc": { "start": { - "line": 39, + "line": 42, "column": 16 }, "end": { - "line": 39, + "line": 42, "column": 17 } } @@ -1992,11 +2149,11 @@ "decorators": [], "loc": { "start": { - "line": 39, + "line": 42, "column": 18 }, "end": { - "line": 39, + "line": 42, "column": 24 } } @@ -2005,11 +2162,11 @@ "optional": false, "loc": { "start": { - "line": 39, + "line": 42, "column": 16 }, "end": { - "line": 39, + "line": 42, "column": 24 } } @@ -2024,44 +2181,44 @@ "decorators": [], "loc": { "start": { - "line": 39, + "line": 42, "column": 36 }, "end": { - "line": 39, + "line": 42, "column": 37 } } }, "loc": { "start": { - "line": 39, + "line": 42, "column": 36 }, "end": { - "line": 39, + "line": 42, "column": 38 } } }, "loc": { "start": { - "line": 39, + "line": 42, "column": 36 }, "end": { - "line": 39, + "line": 42, "column": 38 } } }, "loc": { "start": { - "line": 39, + "line": 42, "column": 16 }, "end": { - "line": 39, + "line": 42, "column": 38 } } @@ -2084,11 +2241,11 @@ "decorators": [], "loc": { "start": { - "line": 40, + "line": 43, "column": 16 }, "end": { - "line": 40, + "line": 43, "column": 17 } } @@ -2099,11 +2256,11 @@ "decorators": [], "loc": { "start": { - "line": 40, + "line": 43, "column": 18 }, "end": { - "line": 40, + "line": 43, "column": 24 } } @@ -2112,11 +2269,11 @@ "optional": false, "loc": { "start": { - "line": 40, + "line": 43, "column": 16 }, "end": { - "line": 40, + "line": 43, "column": 24 } } @@ -2127,11 +2284,11 @@ "decorators": [], "loc": { "start": { - "line": 40, + "line": 43, "column": 25 }, "end": { - "line": 40, + "line": 43, "column": 28 } } @@ -2140,11 +2297,11 @@ "optional": false, "loc": { "start": { - "line": 40, + "line": 43, "column": 16 }, "end": { - "line": 40, + "line": 43, "column": 28 } } @@ -2154,22 +2311,22 @@ "value": 43, "loc": { "start": { - "line": 40, + "line": 43, "column": 32 }, "end": { - "line": 40, + "line": 43, "column": 34 } } }, "loc": { "start": { - "line": 40, + "line": 43, "column": 16 }, "end": { - "line": 40, + "line": 43, "column": 34 } } @@ -2179,22 +2336,22 @@ "value": "Error! x.union0.num field must be 43", "loc": { "start": { - "line": 40, + "line": 43, "column": 36 }, "end": { - "line": 40, + "line": 43, "column": 74 } } }, "loc": { "start": { - "line": 40, + "line": 43, "column": 9 }, "end": { - "line": 40, + "line": 43, "column": 75 } } @@ -2202,11 +2359,11 @@ ], "loc": { "start": { - "line": 39, + "line": 42, "column": 39 }, "end": { - "line": 41, + "line": 44, "column": 6 } } @@ -2221,11 +2378,11 @@ "value": false, "loc": { "start": { - "line": 42, + "line": 45, "column": 16 }, "end": { - "line": 42, + "line": 45, "column": 21 } } @@ -2235,22 +2392,22 @@ "value": "Error! x.union0 must be instanceof B|C", "loc": { "start": { - "line": 42, + "line": 45, "column": 23 }, "end": { - "line": 42, + "line": 45, "column": 63 } } }, "loc": { "start": { - "line": 42, + "line": 45, "column": 9 }, "end": { - "line": 42, + "line": 45, "column": 64 } } @@ -2258,33 +2415,33 @@ ], "loc": { "start": { - "line": 41, + "line": 44, "column": 12 }, "end": { - "line": 43, + "line": 46, "column": 6 } } }, "loc": { "start": { - "line": 39, + "line": 42, "column": 12 }, "end": { - "line": 43, + "line": 46, "column": 6 } } }, "loc": { "start": { - "line": 37, + "line": 40, "column": 5 }, "end": { - "line": 43, + "line": 46, "column": 6 } } @@ -2292,33 +2449,33 @@ ], "loc": { "start": { - "line": 36, + "line": 39, "column": 25 }, "end": { - "line": 44, + "line": 47, "column": 2 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 13 }, "end": { - "line": 44, + "line": 47, "column": 2 } } }, "loc": { "start": { - "line": 36, + "line": 39, "column": 13 }, "end": { - "line": 44, + "line": 47, "column": 2 } } @@ -2327,11 +2484,11 @@ "decorators": [], "loc": { "start": { - "line": 36, + "line": 39, "column": 1 }, "end": { - "line": 44, + "line": 47, "column": 2 } } @@ -2344,11 +2501,11 @@ "decorators": [], "loc": { "start": { - "line": 46, + "line": 49, "column": 10 }, "end": { - "line": 46, + "line": 49, "column": 14 } } @@ -2368,11 +2525,11 @@ "decorators": [], "loc": { "start": { - "line": 46, + "line": 49, "column": 10 }, "end": { - "line": 46, + "line": 49, "column": 14 } } @@ -2385,11 +2542,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 46, + "line": 49, "column": 18 }, "end": { - "line": 46, + "line": 49, "column": 22 } } @@ -2415,11 +2572,11 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 12 }, "end": { - "line": 47, + "line": 50, "column": 13 } } @@ -2440,33 +2597,33 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 14 }, "end": { - "line": 47, + "line": 50, "column": 15 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 14 }, "end": { - "line": 47, + "line": 50, "column": 16 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 14 }, "end": { - "line": 47, + "line": 50, "column": 16 } } @@ -2481,33 +2638,33 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 16 }, "end": { - "line": 47, + "line": 50, "column": 17 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 16 }, "end": { - "line": 47, + "line": 50, "column": 18 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 16 }, "end": { - "line": 47, + "line": 50, "column": 18 } } @@ -2515,11 +2672,11 @@ ], "loc": { "start": { - "line": 47, + "line": 50, "column": 14 }, "end": { - "line": 47, + "line": 50, "column": 18 } } @@ -2527,33 +2684,33 @@ ], "loc": { "start": { - "line": 47, + "line": 50, "column": 13 }, "end": { - "line": 47, + "line": 50, "column": 18 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 12 }, "end": { - "line": 47, + "line": 50, "column": 20 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 12 }, "end": { - "line": 47, + "line": 50, "column": 20 } } @@ -2561,11 +2718,11 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 9 }, "end": { - "line": 47, + "line": 50, "column": 10 } } @@ -2582,11 +2739,11 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 25 }, "end": { - "line": 47, + "line": 50, "column": 26 } } @@ -2607,33 +2764,33 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 27 }, "end": { - "line": 47, + "line": 50, "column": 28 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 27 }, "end": { - "line": 47, + "line": 50, "column": 29 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 27 }, "end": { - "line": 47, + "line": 50, "column": 29 } } @@ -2648,33 +2805,33 @@ "decorators": [], "loc": { "start": { - "line": 47, + "line": 50, "column": 29 }, "end": { - "line": 47, + "line": 50, "column": 30 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 29 }, "end": { - "line": 47, + "line": 50, "column": 31 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 29 }, "end": { - "line": 47, + "line": 50, "column": 31 } } @@ -2682,11 +2839,11 @@ ], "loc": { "start": { - "line": 47, + "line": 50, "column": 27 }, "end": { - "line": 47, + "line": 50, "column": 31 } } @@ -2694,197 +2851,126 @@ ], "loc": { "start": { - "line": 47, + "line": 50, "column": 26 }, "end": { - "line": 47, + "line": 50, "column": 31 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 25 }, "end": { - "line": 47, + "line": 50, "column": 32 } } }, "loc": { "start": { - "line": 47, + "line": 50, "column": 25 }, "end": { - "line": 47, + "line": 50, "column": 32 } } }, - "arguments": [], - "loc": { - "start": { - "line": 47, - "column": 21 - }, - "end": { - "line": 47, - "column": 34 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 9 - }, - "end": { - "line": 47, - "column": 34 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 47, - "column": 5 - }, - "end": { - "line": 47, - "column": 34 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 48, - "column": 5 - }, - "end": { - "line": 48, - "column": 6 - } - } - }, - "property": { - "type": "Identifier", - "name": "union0", - "decorators": [], - "loc": { - "start": { - "line": 48, - "column": 7 - }, - "end": { - "line": 48, - "column": 13 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 48, - "column": 5 - }, - "end": { - "line": 48, - "column": 13 - } - } - }, - "right": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], + "arguments": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 50, + "column": 36 + }, + "end": { + "line": 50, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 36 + }, + "end": { + "line": 50, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 36 + }, + "end": { + "line": 50, + "column": 38 + } + } + }, + "arguments": [], "loc": { "start": { - "line": 48, - "column": 20 + "line": 50, + "column": 32 }, "end": { - "line": 48, - "column": 21 + "line": 50, + "column": 40 } } - }, - "loc": { - "start": { - "line": 48, - "column": 20 - }, - "end": { - "line": 48, - "column": 22 - } } - }, + ], "loc": { "start": { - "line": 48, - "column": 20 + "line": 50, + "column": 21 }, "end": { - "line": 48, - "column": 22 + "line": 50, + "column": 41 } } }, - "arguments": [], "loc": { "start": { - "line": 48, - "column": 16 + "line": 50, + "column": 9 }, "end": { - "line": 48, - "column": 24 + "line": 50, + "column": 41 } } - }, - "loc": { - "start": { - "line": 48, - "column": 5 - }, - "end": { - "line": 48, - "column": 24 - } } - }, + ], + "kind": "let", "loc": { "start": { - "line": 48, + "line": 50, "column": 5 }, "end": { - "line": 48, - "column": 24 + "line": 50, + "column": 41 } } }, @@ -2898,11 +2984,11 @@ "decorators": [], "loc": { "start": { - "line": 49, + "line": 51, "column": 5 }, "end": { - "line": 49, + "line": 51, "column": 8 } } @@ -2916,11 +3002,11 @@ "decorators": [], "loc": { "start": { - "line": 49, + "line": 51, "column": 9 }, "end": { - "line": 49, + "line": 51, "column": 10 } } @@ -2931,11 +3017,11 @@ "decorators": [], "loc": { "start": { - "line": 49, + "line": 51, "column": 11 }, "end": { - "line": 49, + "line": 51, "column": 17 } } @@ -2944,11 +3030,11 @@ "optional": false, "loc": { "start": { - "line": 49, + "line": 51, "column": 9 }, "end": { - "line": 49, + "line": 51, "column": 17 } } @@ -2957,22 +3043,22 @@ "optional": false, "loc": { "start": { - "line": 49, + "line": 51, "column": 5 }, "end": { - "line": 49, + "line": 51, "column": 18 } } }, "loc": { "start": { - "line": 49, + "line": 51, "column": 5 }, "end": { - "line": 49, + "line": 51, "column": 19 } } @@ -2987,11 +3073,11 @@ "decorators": [], "loc": { "start": { - "line": 50, + "line": 52, "column": 5 }, "end": { - "line": 50, + "line": 52, "column": 8 } } @@ -3003,11 +3089,11 @@ "decorators": [], "loc": { "start": { - "line": 50, + "line": 52, "column": 9 }, "end": { - "line": 50, + "line": 52, "column": 10 } } @@ -3016,22 +3102,22 @@ "optional": false, "loc": { "start": { - "line": 50, + "line": 52, "column": 5 }, "end": { - "line": 50, + "line": 52, "column": 11 } } }, "loc": { "start": { - "line": 50, + "line": 52, "column": 5 }, "end": { - "line": 50, + "line": 52, "column": 12 } } @@ -3049,11 +3135,11 @@ "decorators": [], "loc": { "start": { - "line": 51, + "line": 53, "column": 5 }, "end": { - "line": 51, + "line": 53, "column": 6 } } @@ -3064,11 +3150,11 @@ "decorators": [], "loc": { "start": { - "line": 51, + "line": 53, "column": 7 }, "end": { - "line": 51, + "line": 53, "column": 13 } } @@ -3077,11 +3163,11 @@ "optional": false, "loc": { "start": { - "line": 51, + "line": 53, "column": 5 }, "end": { - "line": 51, + "line": 53, "column": 13 } } @@ -3098,33 +3184,33 @@ "decorators": [], "loc": { "start": { - "line": 51, + "line": 53, "column": 20 }, "end": { - "line": 51, + "line": 53, "column": 21 } } }, "loc": { "start": { - "line": 51, + "line": 53, "column": 20 }, "end": { - "line": 51, + "line": 53, "column": 22 } } }, "loc": { "start": { - "line": 51, + "line": 53, "column": 20 }, "end": { - "line": 51, + "line": 53, "column": 22 } } @@ -3132,33 +3218,33 @@ "arguments": [], "loc": { "start": { - "line": 51, + "line": 53, "column": 16 }, "end": { - "line": 51, + "line": 53, "column": 24 } } }, "loc": { "start": { - "line": 51, + "line": 53, "column": 5 }, "end": { - "line": 51, + "line": 53, "column": 24 } } }, "loc": { "start": { - "line": 51, + "line": 53, "column": 5 }, "end": { - "line": 51, + "line": 53, "column": 24 } } @@ -3173,11 +3259,11 @@ "decorators": [], "loc": { "start": { - "line": 52, + "line": 54, "column": 5 }, "end": { - "line": 52, + "line": 54, "column": 8 } } @@ -3189,11 +3275,11 @@ "decorators": [], "loc": { "start": { - "line": 52, + "line": 54, "column": 9 }, "end": { - "line": 52, + "line": 54, "column": 10 } } @@ -3202,22 +3288,22 @@ "optional": false, "loc": { "start": { - "line": 52, + "line": 54, "column": 5 }, "end": { - "line": 52, + "line": 54, "column": 11 } } }, "loc": { "start": { - "line": 52, + "line": 54, "column": 5 }, "end": { - "line": 52, + "line": 54, "column": 12 } } @@ -3232,11 +3318,11 @@ "decorators": [], "loc": { "start": { - "line": 53, + "line": 55, "column": 5 }, "end": { - "line": 53, + "line": 55, "column": 8 } } @@ -3250,11 +3336,11 @@ "decorators": [], "loc": { "start": { - "line": 53, + "line": 55, "column": 9 }, "end": { - "line": 53, + "line": 55, "column": 10 } } @@ -3265,11 +3351,11 @@ "decorators": [], "loc": { "start": { - "line": 53, + "line": 55, "column": 11 }, "end": { - "line": 53, + "line": 55, "column": 17 } } @@ -3278,11 +3364,11 @@ "optional": false, "loc": { "start": { - "line": 53, + "line": 55, "column": 9 }, "end": { - "line": 53, + "line": 55, "column": 17 } } @@ -3291,22 +3377,22 @@ "optional": false, "loc": { "start": { - "line": 53, + "line": 55, "column": 5 }, "end": { - "line": 53, + "line": 55, "column": 18 } } }, "loc": { "start": { - "line": 53, + "line": 55, "column": 5 }, "end": { - "line": 53, + "line": 55, "column": 19 } } @@ -3314,33 +3400,33 @@ ], "loc": { "start": { - "line": 46, + "line": 49, "column": 23 }, "end": { - "line": 54, + "line": 56, "column": 2 } } }, "loc": { "start": { - "line": 46, + "line": 49, "column": 14 }, "end": { - "line": 54, + "line": 56, "column": 2 } } }, "loc": { "start": { - "line": 46, + "line": 49, "column": 14 }, "end": { - "line": 54, + "line": 56, "column": 2 } } @@ -3349,11 +3435,11 @@ "decorators": [], "loc": { "start": { - "line": 46, + "line": 49, "column": 1 }, "end": { - "line": 54, + "line": 56, "column": 2 } } @@ -3388,7 +3474,7 @@ "column": 1 }, "end": { - "line": 56, + "line": 58, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/union_types_5.sts b/ets2panda/test/compiler/ets/union_types_5.sts index f7f8975f0c..9cf3dbbae6 100644 --- a/ets2panda/test/compiler/ets/union_types_5.sts +++ b/ets2panda/test/compiler/ets/union_types_5.sts @@ -15,6 +15,9 @@ class A { union0: T; + constructor(union0: T) { + this.union0 = union0 + } } class B { num: int = 42 @@ -44,8 +47,7 @@ function bar(x: A) { } function main(): void { - let a: A = new A(); - a.union0 = new B(); + let a: A = new A(new B()); foo(a.union0); bar(a); a.union0 = new C(); diff --git a/ets2panda/test/parser/ets/AccessNSieve-expected.txt b/ets2panda/test/parser/ets/AccessNSieve-expected.txt index d8edc02f31..b73e886168 100644 --- a/ets2panda/test/parser/ets/AccessNSieve-expected.txt +++ b/ets2panda/test/parser/ets/AccessNSieve-expected.txt @@ -228,6 +228,20 @@ } } }, + "value": { + "type": "ArrayExpression", + "elements": [], + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 33 + } + } + }, "accessibility": "public", "static": true, "readonly": false, @@ -252,11 +266,11 @@ "loc": { "start": { "line": 20, - "column": 28 + "column": 29 }, "end": { "line": 20, - "column": 29 + "column": 30 } } }, @@ -269,7 +283,7 @@ }, "end": { "line": 20, - "column": 29 + "column": 33 } } }, diff --git a/ets2panda/test/parser/ets/AccessNSieve.sts b/ets2panda/test/parser/ets/AccessNSieve.sts index 651c1699a7..0e884875be 100644 --- a/ets2panda/test/parser/ets/AccessNSieve.sts +++ b/ets2panda/test/parser/ets/AccessNSieve.sts @@ -17,7 +17,7 @@ export class AccessNSieve { static readonly n1: int = 3; static readonly n2: int = 10000; static readonly expected: int = 14302; - static isPrime: boolean[]; + static isPrime: boolean[] = []; public setup(): void { AccessNSieve.isPrime = new boolean[(1 << AccessNSieve.n1) * AccessNSieve.n2 + 1]; diff --git a/ets2panda/test/parser/ets/FunctionType-expected.txt b/ets2panda/test/parser/ets/FunctionType-expected.txt index a657be116c..e802d0e1c7 100644 --- a/ets2panda/test/parser/ets/FunctionType-expected.txt +++ b/ets2panda/test/parser/ets/FunctionType-expected.txt @@ -39,6 +39,149 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "a", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 24, + "column": 38 + }, + "end": { + "line": 24, + "column": 41 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 35 + }, + "end": { + "line": 24, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 35 + }, + "end": { + "line": 24, + "column": 41 + } + } + }, + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "b", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 24, + "column": 46 + }, + "end": { + "line": 24, + "column": 50 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 43 + }, + "end": { + "line": 24, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 43 + }, + "end": { + "line": 24, + "column": 50 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": null, + "loc": { + "start": { + "line": 24, + "column": 57 + }, + "end": { + "line": 24, + "column": 63 + } + } + } + ], + "loc": { + "start": { + "line": 24, + "column": 55 + }, + "end": { + "line": 24, + "column": 65 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 34 + }, + "end": { + "line": 24, + "column": 65 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 34 + }, + "end": { + "line": 24, + "column": 65 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -164,7 +307,7 @@ }, "end": { "line": 24, - "column": 31 + "column": 65 } } }, diff --git a/ets2panda/test/parser/ets/FunctionType.sts b/ets2panda/test/parser/ets/FunctionType.sts index fbef61021f..f477eba65e 100644 --- a/ets2panda/test/parser/ets/FunctionType.sts +++ b/ets2panda/test/parser/ets/FunctionType.sts @@ -21,5 +21,5 @@ function func(k: () => void): char { } class Klass { - a: (a: int, b: byte) => void; + a: (a: int, b: byte) => void = (a: int, b: byte) => { return }; } diff --git a/ets2panda/test/parser/ets/Morph3d-expected.txt b/ets2panda/test/parser/ets/Morph3d-expected.txt index d9f848ecd4..91f87fb3c3 100644 --- a/ets2panda/test/parser/ets/Morph3d-expected.txt +++ b/ets2panda/test/parser/ets/Morph3d-expected.txt @@ -237,6 +237,20 @@ } } }, + "value": { + "type": "ArrayExpression", + "elements": [], + "loc": { + "start": { + "line": 22, + "column": 24 + }, + "end": { + "line": 22, + "column": 26 + } + } + }, "accessibility": "public", "static": true, "readonly": false, @@ -261,11 +275,11 @@ "loc": { "start": { "line": 22, - "column": 21 + "column": 22 }, "end": { "line": 22, - "column": 22 + "column": 23 } } }, @@ -278,7 +292,7 @@ }, "end": { "line": 22, - "column": 22 + "column": 26 } } }, diff --git a/ets2panda/test/parser/ets/Morph3d.sts b/ets2panda/test/parser/ets/Morph3d.sts index 5cb7b99f08..58859374b8 100644 --- a/ets2panda/test/parser/ets/Morph3d.sts +++ b/ets2panda/test/parser/ets/Morph3d.sts @@ -19,7 +19,7 @@ export class Morph3d { private static readonly param: int = 120; private static readonly n: int = 15; - static a: double[]; + static a: double[] = []; public setup(): void { // Not parsed new double[...] diff --git a/ets2panda/test/parser/ets/array_creation_expression-expected.txt b/ets2panda/test/parser/ets/array_creation_expression-expected.txt index 6e0ab76f0c..392fa67f77 100644 --- a/ets2panda/test/parser/ets/array_creation_expression-expected.txt +++ b/ets2panda/test/parser/ets/array_creation_expression-expected.txt @@ -489,50 +489,67 @@ } }, { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 25, + "column": 9 + }, + "end": { + "line": 25, + "column": 13 + } + } + }, + "property": { "type": "Identifier", "name": "data", "decorators": [], "loc": { "start": { "line": 25, - "column": 13 + "column": 14 }, "end": { "line": 25, - "column": 17 + "column": 18 } } }, - "init": { - "type": "ETSNewArrayInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "T", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 24 - }, - "end": { - "line": 25, - "column": 25 - } - } - }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 25, + "column": 9 + }, + "end": { + "line": 25, + "column": 18 + } + } + }, + "right": { + "type": "ETSNewArrayInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], "loc": { "start": { "line": 25, - "column": 24 + "column": 25 }, "end": { "line": 25, @@ -543,61 +560,61 @@ "loc": { "start": { "line": 25, - "column": 24 + "column": 25 }, "end": { "line": 25, - "column": 26 + "column": 27 } } }, - "dimension": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 25, - "column": 26 - }, - "end": { - "line": 25, - "column": 30 - } - } + "loc": { + "start": { + "line": 25, + "column": 25 }, - "property": { - "type": "Identifier", - "name": "num", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 31 - }, - "end": { - "line": 25, - "column": 34 - } + "end": { + "line": 25, + "column": 27 + } + } + }, + "dimension": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 25, + "column": 27 + }, + "end": { + "line": 25, + "column": 31 } - }, - "computed": false, - "optional": false, + } + }, + "property": { + "type": "Identifier", + "name": "num", + "decorators": [], "loc": { "start": { "line": 25, - "column": 26 + "column": 32 }, "end": { "line": 25, - "column": 34 + "column": 35 } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 25, - "column": 20 + "column": 27 }, "end": { "line": 25, @@ -608,16 +625,25 @@ "loc": { "start": { "line": 25, - "column": 13 + "column": 21 }, "end": { "line": 25, - "column": 35 + "column": 36 } } + }, + "loc": { + "start": { + "line": 25, + "column": 9 + }, + "end": { + "line": 25, + "column": 36 + } } - ], - "kind": "let", + }, "loc": { "start": { "line": 25, @@ -625,7 +651,7 @@ }, "end": { "line": 25, - "column": 36 + "column": 37 } } } diff --git a/ets2panda/test/parser/ets/array_creation_expression.sts b/ets2panda/test/parser/ets/array_creation_expression.sts index 786edf0e62..567ae07292 100644 --- a/ets2panda/test/parser/ets/array_creation_expression.sts +++ b/ets2panda/test/parser/ets/array_creation_expression.sts @@ -22,7 +22,7 @@ class ListTest { constructor() { this.num = 10; - let data = new T[this.num]; + this.data = new T[this.num]; } private data: T[]; private num: int; diff --git a/ets2panda/test/parser/ets/generics_1-expected.txt b/ets2panda/test/parser/ets/generics_1-expected.txt index 2a9bd3f02a..044730a9f3 100644 --- a/ets2panda/test/parser/ets/generics_1-expected.txt +++ b/ets2panda/test/parser/ets/generics_1-expected.txt @@ -160,6 +160,7 @@ } }, "kind": "constructor", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -185,40 +186,196 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "a", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 22 + } + } + } + ], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 20 + } + } + } + ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 23 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 6 } } }, @@ -227,11 +384,11 @@ "loc": { "start": { "line": 18, - "column": 2 + "column": 5 }, "end": { - "line": 18, - "column": 2 + "line": 20, + "column": 6 } } } @@ -242,7 +399,7 @@ "column": 12 }, "end": { - "line": 18, + "line": 21, "column": 2 } } @@ -253,7 +410,7 @@ "column": 1 }, "end": { - "line": 18, + "line": 21, "column": 2 } } @@ -267,11 +424,11 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 23, "column": 7 }, "end": { - "line": 20, + "line": 23, "column": 8 } } @@ -287,22 +444,22 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 23, "column": 9 }, "end": { - "line": 20, + "line": 23, "column": 10 } } }, "loc": { "start": { - "line": 20, + "line": 23, "column": 9 }, "end": { - "line": 20, + "line": 23, "column": 11 } } @@ -310,11 +467,11 @@ ], "loc": { "start": { - "line": 20, + "line": 23, "column": 8 }, "end": { - "line": 20, + "line": 23, "column": 11 } } @@ -330,11 +487,11 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 24, "column": 5 }, "end": { - "line": 21, + "line": 24, "column": 6 } } @@ -355,11 +512,11 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 24, "column": 8 }, "end": { - "line": 21, + "line": 24, "column": 9 } } @@ -377,33 +534,33 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 24, "column": 10 }, "end": { - "line": 21, + "line": 24, "column": 11 } } }, "loc": { "start": { - "line": 21, + "line": 24, "column": 10 }, "end": { - "line": 21, + "line": 24, "column": 12 } } }, "loc": { "start": { - "line": 21, + "line": 24, "column": 10 }, "end": { - "line": 21, + "line": 24, "column": 12 } } @@ -411,33 +568,33 @@ ], "loc": { "start": { - "line": 21, + "line": 24, "column": 9 }, "end": { - "line": 21, + "line": 24, "column": 12 } } }, "loc": { "start": { - "line": 21, + "line": 24, "column": 8 }, "end": { - "line": 21, + "line": 24, "column": 13 } } }, "loc": { "start": { - "line": 21, + "line": 24, "column": 8 }, "end": { - "line": 21, + "line": 24, "column": 13 } } @@ -446,11 +603,11 @@ "decorators": [], "loc": { "start": { - "line": 21, + "line": 24, "column": 5 }, "end": { - "line": 21, + "line": 24, "column": 13 } } @@ -473,6 +630,7 @@ } }, "kind": "constructor", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -498,40 +656,252 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "b", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 21 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 25, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 25, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 25, + "column": 24 + } + } + } + ], + "loc": { + "start": { + "line": 25, + "column": 21 + }, + "end": { + "line": 25, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 25 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 17 + }, + "end": { + "line": 25, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 17 + }, + "end": { + "line": 25, + "column": 25 + } + } + } + ], "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 9 + }, + "end": { + "line": 26, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 14 + }, + "end": { + "line": 26, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 9 + }, + "end": { + "line": 26, + "column": 15 + } + } + }, + "right": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 18 + }, + "end": { + "line": 26, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 9 + }, + "end": { + "line": 26, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 9 + }, + "end": { + "line": 26, + "column": 20 + } + } + } + ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 25, + "column": 26 }, "end": { - "line": 1, - "column": 1 + "line": 27, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 25, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 27, + "column": 6 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 25, + "column": 16 }, "end": { - "line": 1, - "column": 1 + "line": 27, + "column": 6 } } }, @@ -539,34 +909,34 @@ "decorators": [], "loc": { "start": { - "line": 22, - "column": 2 + "line": 25, + "column": 5 }, "end": { - "line": 22, - "column": 2 + "line": 27, + "column": 6 } } } ], "loc": { "start": { - "line": 20, + "line": 23, "column": 12 }, "end": { - "line": 22, + "line": 28, "column": 2 } } }, "loc": { "start": { - "line": 20, + "line": 23, "column": 1 }, "end": { - "line": 22, + "line": 28, "column": 2 } } @@ -580,11 +950,11 @@ "decorators": [], "loc": { "start": { - "line": 24, + "line": 30, "column": 7 }, "end": { - "line": 24, + "line": 30, "column": 8 } } @@ -600,11 +970,11 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 31, "column": 5 }, "end": { - "line": 25, + "line": 31, "column": 6 } } @@ -614,11 +984,11 @@ "value": 12, "loc": { "start": { - "line": 25, + "line": 31, "column": 15 }, "end": { - "line": 25, + "line": 31, "column": 17 } } @@ -633,11 +1003,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 25, + "line": 31, "column": 8 }, "end": { - "line": 25, + "line": 31, "column": 12 } } @@ -646,11 +1016,11 @@ "decorators": [], "loc": { "start": { - "line": 25, + "line": 31, "column": 5 }, "end": { - "line": 25, + "line": 31, "column": 17 } } @@ -739,11 +1109,11 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 32, "column": 2 }, "end": { - "line": 26, + "line": 32, "column": 2 } } @@ -751,22 +1121,22 @@ ], "loc": { "start": { - "line": 24, + "line": 30, "column": 9 }, "end": { - "line": 26, + "line": 32, "column": 2 } } }, "loc": { "start": { - "line": 24, + "line": 30, "column": 1 }, "end": { - "line": 26, + "line": 32, "column": 2 } } @@ -894,11 +1264,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 34, "column": 10 }, "end": { - "line": 28, + "line": 34, "column": 14 } } @@ -918,11 +1288,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 34, "column": 10 }, "end": { - "line": 28, + "line": 34, "column": 14 } } @@ -935,11 +1305,11 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 28, + "line": 34, "column": 18 }, "end": { - "line": 28, + "line": 34, "column": 22 } } @@ -965,11 +1335,11 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 35, "column": 12 }, "end": { - "line": 29, + "line": 35, "column": 13 } } @@ -987,33 +1357,33 @@ "decorators": [], "loc": { "start": { - "line": 29, + "line": 35, "column": 14 }, "end": { - "line": 29, + "line": 35, "column": 15 } } }, "loc": { "start": { - "line": 29, + "line": 35, "column": 14 }, "end": { - "line": 29, + "line": 35, "column": 16 } } }, "loc": { "start": { - "line": 29, + "line": 35, "column": 14 }, "end": { - "line": 29, + "line": 35, "column": 16 } } @@ -1021,58 +1391,336 @@ ], "loc": { "start": { - "line": 29, + "line": 35, "column": 13 }, "end": { - "line": 29, + "line": 35, "column": 16 } } }, "loc": { "start": { - "line": 29, + "line": 35, "column": 12 }, "end": { - "line": 29, - "column": 17 + "line": 35, + "column": 18 } } }, "loc": { "start": { - "line": 29, + "line": 35, "column": 12 }, "end": { - "line": 29, - "column": 17 + "line": 35, + "column": 18 } } }, "decorators": [], "loc": { "start": { - "line": 29, + "line": 35, "column": 9 }, "end": { - "line": 29, + "line": 35, "column": 10 } } }, - "init": null, + "init": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 23 + }, + "end": { + "line": 35, + "column": 24 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Z", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 25 + }, + "end": { + "line": 35, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 25 + }, + "end": { + "line": 35, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 25 + }, + "end": { + "line": 35, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 35, + "column": 24 + }, + "end": { + "line": 35, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 23 + }, + "end": { + "line": 35, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 23 + }, + "end": { + "line": 35, + "column": 28 + } + } + }, + "arguments": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 32 + }, + "end": { + "line": 35, + "column": 33 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Z", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 34 + }, + "end": { + "line": 35, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 34 + }, + "end": { + "line": 35, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 34 + }, + "end": { + "line": 35, + "column": 36 + } + } + } + ], + "loc": { + "start": { + "line": 35, + "column": 33 + }, + "end": { + "line": 35, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 32 + }, + "end": { + "line": 35, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 32 + }, + "end": { + "line": 35, + "column": 37 + } + } + }, + "arguments": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Z", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 41 + }, + "end": { + "line": 35, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 41 + }, + "end": { + "line": 35, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 41 + }, + "end": { + "line": 35, + "column": 43 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 35, + "column": 37 + }, + "end": { + "line": 35, + "column": 45 + } + } + } + ], + "loc": { + "start": { + "line": 35, + "column": 28 + }, + "end": { + "line": 35, + "column": 46 + } + } + } + ], + "loc": { + "start": { + "line": 35, + "column": 19 + }, + "end": { + "line": 35, + "column": 47 + } + } + }, "loc": { "start": { - "line": 29, + "line": 35, "column": 9 }, "end": { - "line": 29, - "column": 10 + "line": 35, + "column": 47 } } } @@ -1080,12 +1728,12 @@ "kind": "let", "loc": { "start": { - "line": 29, + "line": 35, "column": 5 }, "end": { - "line": 29, - "column": 17 + "line": 35, + "column": 47 } } }, @@ -1106,11 +1754,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 36, "column": 5 }, "end": { - "line": 30, + "line": 36, "column": 6 } } @@ -1121,11 +1769,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 36, "column": 7 }, "end": { - "line": 30, + "line": 36, "column": 8 } } @@ -1134,11 +1782,11 @@ "optional": false, "loc": { "start": { - "line": 30, + "line": 36, "column": 5 }, "end": { - "line": 30, + "line": 36, "column": 8 } } @@ -1149,11 +1797,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 36, "column": 9 }, "end": { - "line": 30, + "line": 36, "column": 10 } } @@ -1162,11 +1810,11 @@ "optional": false, "loc": { "start": { - "line": 30, + "line": 36, "column": 5 }, "end": { - "line": 30, + "line": 36, "column": 10 } } @@ -1177,11 +1825,11 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 36, "column": 11 }, "end": { - "line": 30, + "line": 36, "column": 12 } } @@ -1190,11 +1838,11 @@ "optional": false, "loc": { "start": { - "line": 30, + "line": 36, "column": 5 }, "end": { - "line": 30, + "line": 36, "column": 12 } } @@ -1204,33 +1852,33 @@ "value": 127, "loc": { "start": { - "line": 30, + "line": 36, "column": 15 }, "end": { - "line": 30, + "line": 36, "column": 18 } } }, "loc": { "start": { - "line": 30, + "line": 36, "column": 5 }, "end": { - "line": 30, + "line": 36, "column": 18 } } }, "loc": { "start": { - "line": 30, + "line": 36, "column": 5 }, "end": { - "line": 30, + "line": 36, "column": 19 } } @@ -1238,33 +1886,33 @@ ], "loc": { "start": { - "line": 28, + "line": 34, "column": 23 }, "end": { - "line": 31, + "line": 37, "column": 2 } } }, "loc": { "start": { - "line": 28, + "line": 34, "column": 14 }, "end": { - "line": 31, + "line": 37, "column": 2 } } }, "loc": { "start": { - "line": 28, + "line": 34, "column": 14 }, "end": { - "line": 31, + "line": 37, "column": 2 } } @@ -1273,11 +1921,11 @@ "decorators": [], "loc": { "start": { - "line": 28, + "line": 34, "column": 1 }, "end": { - "line": 31, + "line": 37, "column": 2 } } @@ -1312,10 +1960,8 @@ "column": 1 }, "end": { - "line": 32, + "line": 38, "column": 1 } } } -Warning: Variable 'd' is used before being assigned. [generics_1.sts:30:5] -TypeError: There were errors during assign analysis (1) [generics_1.sts:1:1] diff --git a/ets2panda/test/parser/ets/generics_1.sts b/ets2panda/test/parser/ets/generics_1.sts index ca174b48ef..20fd0856d6 100644 --- a/ets2panda/test/parser/ets/generics_1.sts +++ b/ets2panda/test/parser/ets/generics_1.sts @@ -15,10 +15,16 @@ class B { a: T; + constructor(a: T) { + this.a = a; + } } class A { b: B; + constructor(b: B) { + this.b = b; + } } class Z { @@ -26,6 +32,6 @@ class Z { } function main(): void { - let d: A; + let d: A = new A(new B(new Z())); d.b.a.c = 127; } diff --git a/ets2panda/test/parser/ets/re_export/folderIndex2/key-expected.txt b/ets2panda/test/parser/ets/re_export/folderIndex2/key-expected.txt index 7b3d527b0e..f2a4ce6469 100644 --- a/ets2panda/test/parser/ets/re_export/folderIndex2/key-expected.txt +++ b/ets2panda/test/parser/ets/re_export/folderIndex2/key-expected.txt @@ -39,6 +39,20 @@ } } }, + "value": { + "type": "StringLiteral", + "value": "", + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -71,7 +85,7 @@ }, "end": { "line": 17, - "column": 17 + "column": 18 } } }, @@ -82,7 +96,7 @@ }, "end": { "line": 17, - "column": 17 + "column": 18 } } }, @@ -95,7 +109,7 @@ }, "end": { "line": 17, - "column": 17 + "column": 21 } } }, @@ -253,6 +267,20 @@ } } }, + "value": { + "type": "StringLiteral", + "value": "", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -285,7 +313,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 18 } } }, @@ -296,7 +324,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 18 } } }, @@ -309,7 +337,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 21 } } }, diff --git a/ets2panda/test/parser/ets/re_export/folderIndex2/key.sts b/ets2panda/test/parser/ets/re_export/folderIndex2/key.sts index 4bcccea396..016e2cd49e 100644 --- a/ets2panda/test/parser/ets/re_export/folderIndex2/key.sts +++ b/ets2panda/test/parser/ets/re_export/folderIndex2/key.sts @@ -14,8 +14,8 @@ */ export class Test1{ - name:String; + name:String = ""; } export class Test2{ - name:String; + name:String = ""; } diff --git a/ets2panda/test/parser/ets/test-type-alias-call1-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call1-expected.txt index 9488599338..b30ed81e0a 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call1-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call1-expected.txt @@ -136,6 +136,121 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 18, + "column": 37 + }, + "end": { + "line": 18, + "column": 40 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 34 + }, + "end": { + "line": 18, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 34 + }, + "end": { + "line": 18, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 18, + "column": 45 + }, + "end": { + "line": 18, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 33 + }, + "end": { + "line": 18, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 33 + }, + "end": { + "line": 18, + "column": 46 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -167,8 +282,8 @@ "column": 22 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 32 } } }, @@ -178,8 +293,8 @@ "column": 22 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 32 } } }, @@ -191,8 +306,8 @@ "column": 12 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 46 } } }, diff --git a/ets2panda/test/parser/ets/test-type-alias-call1.sts b/ets2panda/test/parser/ets/test-type-alias-call1.sts index 0fad13b77e..81f6081ac4 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call1.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call1.sts @@ -15,7 +15,7 @@ type Callback = (n: int) => int class A { - public callback: Callback + public callback: Callback = (n: int) => 0 public increment() { this.callback(1) } diff --git a/ets2panda/test/parser/ets/test-type-alias-call2-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call2-expected.txt index 8913c68014..b17b2d2797 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call2-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call2-expected.txt @@ -274,6 +274,121 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 37 + }, + "end": { + "line": 20, + "column": 40 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 34 + }, + "end": { + "line": 20, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 34 + }, + "end": { + "line": 20, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 45 + }, + "end": { + "line": 20, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 33 + }, + "end": { + "line": 20, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 33 + }, + "end": { + "line": 20, + "column": 46 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -305,8 +420,8 @@ "column": 22 }, "end": { - "line": 21, - "column": 11 + "line": 20, + "column": 32 } } }, @@ -316,8 +431,8 @@ "column": 22 }, "end": { - "line": 21, - "column": 11 + "line": 20, + "column": 32 } } }, @@ -329,8 +444,8 @@ "column": 12 }, "end": { - "line": 21, - "column": 11 + "line": 20, + "column": 46 } } }, diff --git a/ets2panda/test/parser/ets/test-type-alias-call2.sts b/ets2panda/test/parser/ets/test-type-alias-call2.sts index a33a36b6f9..79d9c72158 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call2.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call2.sts @@ -17,7 +17,7 @@ type First = (n: int) => int type Second = First type Callback = Second class A { - public callback: Callback + public callback: Callback = (n: int) => 0 public increment() { this.callback(1) } diff --git a/ets2panda/test/parser/ets/test-type-alias-call3-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call3-expected.txt index 1076dcd57a..beeeb0c7d9 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call3-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call3-expected.txt @@ -136,6 +136,121 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 18, + "column": 44 + }, + "end": { + "line": 18, + "column": 47 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 41 + }, + "end": { + "line": 18, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 41 + }, + "end": { + "line": 18, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 18, + "column": 52 + }, + "end": { + "line": 18, + "column": 53 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 40 + }, + "end": { + "line": 18, + "column": 53 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 40 + }, + "end": { + "line": 18, + "column": 53 + } + } + }, "accessibility": "public", "static": true, "readonly": false, @@ -167,8 +282,8 @@ "column": 29 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 39 } } }, @@ -178,8 +293,8 @@ "column": 29 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 39 } } }, @@ -191,8 +306,8 @@ "column": 19 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 53 } } }, diff --git a/ets2panda/test/parser/ets/test-type-alias-call3.sts b/ets2panda/test/parser/ets/test-type-alias-call3.sts index 27de0d5201..d7e5f3bd88 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call3.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call3.sts @@ -15,7 +15,7 @@ type Callback = (n: int) => int class A { - public static callback: Callback + public static callback: Callback = (n: int) => 0 public increment() { A.callback(1) } diff --git a/ets2panda/test/parser/ets/test-type-alias-call4-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call4-expected.txt index 9c15b8c34f..2a1b3c16d1 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call4-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call4-expected.txt @@ -136,6 +136,121 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 18, + "column": 44 + }, + "end": { + "line": 18, + "column": 47 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 41 + }, + "end": { + "line": 18, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 41 + }, + "end": { + "line": 18, + "column": 47 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 18, + "column": 52 + }, + "end": { + "line": 18, + "column": 53 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 40 + }, + "end": { + "line": 18, + "column": 53 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 40 + }, + "end": { + "line": 18, + "column": 53 + } + } + }, "accessibility": "public", "static": true, "readonly": false, @@ -167,8 +282,8 @@ "column": 29 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 39 } } }, @@ -178,8 +293,8 @@ "column": 29 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 39 } } }, @@ -191,8 +306,8 @@ "column": 19 }, "end": { - "line": 19, - "column": 11 + "line": 18, + "column": 53 } } }, diff --git a/ets2panda/test/parser/ets/test-type-alias-call4.sts b/ets2panda/test/parser/ets/test-type-alias-call4.sts index 604055175b..e7c398d6da 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call4.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call4.sts @@ -15,7 +15,7 @@ type Callback = (n: int) => int class A { - public static callback: Callback + public static callback: Callback = (n: int) => 0 public static increment() { A.callback(1) } diff --git a/ets2panda/test/parser/ets/test-type-alias-call5-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call5-expected.txt index f26b502997..a24c36d559 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call5-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call5-expected.txt @@ -330,6 +330,121 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 37 + }, + "end": { + "line": 21, + "column": 40 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 34 + }, + "end": { + "line": 21, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 34 + }, + "end": { + "line": 21, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 21, + "column": 45 + }, + "end": { + "line": 21, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 33 + }, + "end": { + "line": 21, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 33 + }, + "end": { + "line": 21, + "column": 46 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -362,7 +477,7 @@ }, "end": { "line": 21, - "column": 31 + "column": 32 } } }, @@ -373,7 +488,7 @@ }, "end": { "line": 21, - "column": 31 + "column": 32 } } }, @@ -386,7 +501,7 @@ }, "end": { "line": 21, - "column": 31 + "column": 46 } } }, diff --git a/ets2panda/test/parser/ets/test-type-alias-call5.sts b/ets2panda/test/parser/ets/test-type-alias-call5.sts index a6b3b48945..881304affd 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call5.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call5.sts @@ -18,7 +18,7 @@ type Second = First type Callback = First | Second; class A { - public callback: Callback; + public callback: Callback = (n: int) => 0; public increment() { this.callback(1); } diff --git a/ets2panda/test/parser/ets/test-type-alias-call6-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call6-expected.txt index 3a470a4b77..9c412c261d 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call6-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call6-expected.txt @@ -399,6 +399,121 @@ } } }, + "value": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 37 + }, + "end": { + "line": 22, + "column": 40 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 34 + }, + "end": { + "line": 22, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 34 + }, + "end": { + "line": 22, + "column": 40 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 22, + "column": 45 + }, + "end": { + "line": 22, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 33 + }, + "end": { + "line": 22, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 33 + }, + "end": { + "line": 22, + "column": 46 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -431,7 +546,7 @@ }, "end": { "line": 22, - "column": 31 + "column": 32 } } }, @@ -442,7 +557,7 @@ }, "end": { "line": 22, - "column": 31 + "column": 32 } } }, @@ -455,7 +570,7 @@ }, "end": { "line": 22, - "column": 31 + "column": 46 } } }, diff --git a/ets2panda/test/parser/ets/test-type-alias-call6.sts b/ets2panda/test/parser/ets/test-type-alias-call6.sts index f27684f84e..bc0928b1b9 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call6.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call6.sts @@ -19,7 +19,7 @@ type Third = First | Second; type Callback = Third; class A { - public callback: Callback; + public callback: Callback = (n: int) => 0; public increment() { this.callback(1); } diff --git a/ets2panda/test/parser/ets/union_lowering_common_property-expected.txt b/ets2panda/test/parser/ets/union_lowering_common_property-expected.txt index e127887fee..abcc01a8f3 100644 --- a/ets2panda/test/parser/ets/union_lowering_common_property-expected.txt +++ b/ets2panda/test/parser/ets/union_lowering_common_property-expected.txt @@ -39,6 +39,20 @@ } } }, + "value": { + "type": "StringLiteral", + "value": "", + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 24 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -71,7 +85,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 21 } } }, @@ -82,7 +96,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 21 } } }, @@ -95,7 +109,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 24 } } }, @@ -253,6 +267,20 @@ } } }, + "value": { + "type": "StringLiteral", + "value": "", + "loc": { + "start": { + "line": 21, + "column": 22 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, "accessibility": "public", "static": false, "readonly": false, @@ -285,7 +313,7 @@ }, "end": { "line": 21, - "column": 20 + "column": 21 } } }, @@ -296,7 +324,7 @@ }, "end": { "line": 21, - "column": 20 + "column": 21 } } }, @@ -309,7 +337,7 @@ }, "end": { "line": 21, - "column": 20 + "column": 24 } } }, diff --git a/ets2panda/test/parser/ets/union_lowering_common_property.sts b/ets2panda/test/parser/ets/union_lowering_common_property.sts index b67735916e..68a137ba1a 100644 --- a/ets2panda/test/parser/ets/union_lowering_common_property.sts +++ b/ets2panda/test/parser/ets/union_lowering_common_property.sts @@ -14,11 +14,11 @@ */ class A { - status: string; + status: string = ""; } class B { - status: string; + status: string = ""; } type Union = A | B; diff --git a/ets2panda/test/runtime/ets/AccessNSieve.sts b/ets2panda/test/runtime/ets/AccessNSieve.sts index de57a2c40e..381b1d218f 100644 --- a/ets2panda/test/runtime/ets/AccessNSieve.sts +++ b/ets2panda/test/runtime/ets/AccessNSieve.sts @@ -17,7 +17,7 @@ export class AccessNSieve { static readonly n1: int = 3; static readonly n2: int = 10000; static readonly expected: int = 14302; - static isPrime: boolean[]; + static isPrime: boolean[] = []; public setup(): void { AccessNSieve.isPrime = new boolean[(1 << AccessNSieve.n1) * AccessNSieve.n2 + 1]; diff --git a/ets2panda/test/runtime/ets/InterfaceOverrideReturnTypes.sts b/ets2panda/test/runtime/ets/InterfaceOverrideReturnTypes.sts index 4357f88c8f..acf3188570 100644 --- a/ets2panda/test/runtime/ets/InterfaceOverrideReturnTypes.sts +++ b/ets2panda/test/runtime/ets/InterfaceOverrideReturnTypes.sts @@ -22,7 +22,7 @@ interface B extends A { } class C implements A { - private value: string; + private value: string = ""; foo(): A { this.value = "foo(): A" @@ -35,7 +35,7 @@ class C implements A { } class D implements B { - private value: string; + private value: string = ""; foo(): B { this.value = "foo(): B" diff --git a/ets2panda/test/runtime/ets/Morph3d.sts b/ets2panda/test/runtime/ets/Morph3d.sts index 0f98007725..b4e21a7cef 100644 --- a/ets2panda/test/runtime/ets/Morph3d.sts +++ b/ets2panda/test/runtime/ets/Morph3d.sts @@ -19,7 +19,7 @@ export class Morph3d { private static readonly param: int = 120; private static readonly n: int = 15; - static a: double[]; + static a: double[] = []; public setup(): void { // Not parsed new double[...] diff --git a/ets2panda/test/runtime/ets/accessor_functional.sts b/ets2panda/test/runtime/ets/accessor_functional.sts index cb43f4f310..692960b739 100644 --- a/ets2panda/test/runtime/ets/accessor_functional.sts +++ b/ets2panda/test/runtime/ets/accessor_functional.sts @@ -14,7 +14,7 @@ */ class A { - xstate: () => int; + xstate: () => int = () => { return 0; }; get x(): () => int { return this.xstate; } set x(v: () => int) { this.xstate = v } diff --git a/ets2panda/test/runtime/ets/common_property_union_access.sts b/ets2panda/test/runtime/ets/common_property_union_access.sts index b37c927b08..8b3077a29b 100644 --- a/ets2panda/test/runtime/ets/common_property_union_access.sts +++ b/ets2panda/test/runtime/ets/common_property_union_access.sts @@ -14,11 +14,11 @@ */ class A { - status: string; + status: string = ""; } class B { - status: string; + status: string = ""; } type Union = A | B; diff --git a/ets2panda/test/runtime/ets/partialTypeRuntime_1.sts b/ets2panda/test/runtime/ets/partialTypeRuntime_1.sts index bae1101053..8ba780cf75 100644 --- a/ets2panda/test/runtime/ets/partialTypeRuntime_1.sts +++ b/ets2panda/test/runtime/ets/partialTypeRuntime_1.sts @@ -17,8 +17,8 @@ type partial_A = Partial; class A { num_memb: number; - str_memb: String; - b_memb: B; + str_memb: String = ""; + b_memb: B = new B(); } class B { fld: number = 6 } diff --git a/ets2panda/test/runtime/ets/readonlyTypeRuntime.sts b/ets2panda/test/runtime/ets/readonlyTypeRuntime.sts index a675141826..f986936e40 100644 --- a/ets2panda/test/runtime/ets/readonlyTypeRuntime.sts +++ b/ets2panda/test/runtime/ets/readonlyTypeRuntime.sts @@ -16,16 +16,16 @@ type readonly_A = Readonly; class A { - num_mem: Number - str_mem: String - b_mem: B + num_mem: Number = 0 + str_mem: String = "" + b_mem: B = new B() } class B {fld: Number = 6} -class C {c_num_mem: Number} +class C {c_num_mem: Number = 0} -class D extends C {d_num_mem: Number} +class D extends C {d_num_mem: Number = 0} function main(): void { diff --git a/ets2panda/test/runtime/ets/this_type.sts b/ets2panda/test/runtime/ets/this_type.sts index 56999bc85f..3f0a3c717a 100644 --- a/ets2panda/test/runtime/ets/this_type.sts +++ b/ets2panda/test/runtime/ets/this_type.sts @@ -28,7 +28,7 @@ class Component { } class Button extends Component { - title: string; + title: string = ""; getTitle(): string { return this.title; -- Gitee