diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index cd5bf515fce5509f56efc5a94ce2ac644eb946be..96e428681c0126885281b8771b89d4527fb85b54 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -1357,7 +1357,9 @@ static std::pair, bool> CreateLambdaObjectPropertiesF properties.push_back(checker->CreateLambdaCapturedField(it, classScope, idx, lambda->Start())); idx++; } else if (!it->HasFlag(varbinder::VariableFlags::STATIC) && - !checker->Context().ContainingClass()->HasObjectFlag(ETSObjectFlags::GLOBAL)) { + !checker->Context().ContainingClass()->HasObjectFlag(ETSObjectFlags::GLOBAL) && + !(checker->Context().ContainingSignature() != nullptr && + checker->Context().ContainingSignature()->HasSignatureFlag(SignatureFlags::STATIC))) { saveThis = true; } } diff --git a/ets2panda/test/parser/ets/globalVarInLambdaInStatic-expected.txt b/ets2panda/test/parser/ets/globalVarInLambdaInStatic-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..298e98ddeea802e1b8df6290ff926fd921125d06 --- /dev/null +++ b/ets2panda/test/parser/ets/globalVarInLambdaInStatic-expected.txt @@ -0,0 +1,1674 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "NativeModule", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 7 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "MethodeOfClass", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "MethodeOfClass", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 23 + }, + "end": { + "line": 22, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 23 + }, + "end": { + "line": 22, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 23 + }, + "end": { + "line": 22, + "column": 30 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 30 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 31 + }, + "end": { + "line": 22, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 31 + }, + "end": { + "line": 22, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 31 + }, + "end": { + "line": 22, + "column": 37 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 22, + "column": 36 + }, + "end": { + "line": 22, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 19 + }, + "end": { + "line": 22, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 19 + }, + "end": { + "line": 22, + "column": 38 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 38 + } + } + }, + { + "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": 23, + "column": 2 + }, + "end": { + "line": 23, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 20 + }, + "end": { + "line": 23, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 23, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "NativeString", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 7 + }, + "end": { + "line": 29, + "column": 19 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "MethodeOfStatic", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 30, + "column": 27 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "MethodeOfStatic", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 30, + "column": 27 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "tmp", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 13 + }, + "end": { + "line": 31, + "column": 16 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "globalFunction", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 19 + }, + "end": { + "line": 31, + "column": 33 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "len", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 40 + }, + "end": { + "line": 31, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 40 + }, + "end": { + "line": 31, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 40 + }, + "end": { + "line": 31, + "column": 47 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 35 + }, + "end": { + "line": 31, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 35 + }, + "end": { + "line": 31, + "column": 47 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 48 + }, + "end": { + "line": 31, + "column": 52 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 48 + }, + "end": { + "line": 31, + "column": 55 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 48 + }, + "end": { + "line": 31, + "column": 55 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "nativeModule", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 13 + }, + "end": { + "line": 32, + "column": 25 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 32, + "column": 13 + }, + "end": { + "line": 32, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "MethodeOfClass", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 28 + }, + "end": { + "line": 32, + "column": 42 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 32, + "column": 13 + }, + "end": { + "line": 32, + "column": 42 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "len", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 43 + }, + "end": { + "line": 32, + "column": 46 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 32, + "column": 13 + }, + "end": { + "line": 32, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 13 + }, + "end": { + "line": 32, + "column": 48 + } + } + } + ], + "loc": { + "start": { + "line": 31, + "column": 56 + }, + "end": { + "line": 33, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 34 + }, + "end": { + "line": 33, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 34 + }, + "end": { + "line": 33, + "column": 10 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 31, + "column": 19 + }, + "end": { + "line": 33, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 13 + }, + "end": { + "line": 33, + "column": 11 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 31, + "column": 9 + }, + "end": { + "line": 33, + "column": 12 + } + } + } + ], + "loc": { + "start": { + "line": 30, + "column": 30 + }, + "end": { + "line": 34, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 27 + }, + "end": { + "line": 34, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 27 + }, + "end": { + "line": 34, + "column": 6 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 5 + }, + "end": { + "line": 34, + "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": 35, + "column": 2 + }, + "end": { + "line": 35, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 29, + "column": 20 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "globalFunction", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "globalFunction", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "exec", + "typeAnnotation": { + "type": "ETSFunctionType", + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "len", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 37 + }, + "end": { + "line": 16, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 37 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 37 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 32 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 32 + }, + "end": { + "line": 16, + "column": 44 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 47 + }, + "end": { + "line": 16, + "column": 51 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 47 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 47 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 16, + "column": 52 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "length", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 17, + "column": 26 + }, + "end": { + "line": 17, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 27 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 28 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "exec", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 9 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 16 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 18 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 52 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "nativeModule", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 22 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "nativeModule", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 22 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "NativeModule", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 26 + }, + "end": { + "line": 25, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 26 + }, + "end": { + "line": 25, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 26 + }, + "end": { + "line": 25, + "column": 40 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "NativeModule", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 5 + }, + "end": { + "line": 26, + "column": 31 + } + } + } + ], + "loc": { + "start": { + "line": 25, + "column": 39 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 1 + }, + "end": { + "line": 27, + "column": 2 + } + } + } + ], + "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": 36, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/globalVarInLambdaInStatic.ets b/ets2panda/test/parser/ets/globalVarInLambdaInStatic.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c61a8cd810007aaa443329ac834dfdf7e939051 --- /dev/null +++ b/ets2panda/test/parser/ets/globalVarInLambdaInStatic.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function globalFunction(exec: (len: number) =>void){ + let length: number = 0; + exec(length); +} + +class NativeModule { + MethodeOfClass(n: number):void {} +} + +function nativeModule(): NativeModule { + return new NativeModule(); +} + +class NativeString { + static MethodeOfStatic() { + let tmp = globalFunction((len: number):void => { + nativeModule().MethodeOfClass(len); + }); + } +}