From a7667897951660d27f7d344382398a321efe940a Mon Sep 17 00:00:00 2001 From: Vsevolod Pukhov Date: Mon, 28 Jul 2025 11:14:54 +0300 Subject: [PATCH] Optimize functional types and lowerings Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICW96G Signed-off-by: Vsevolod Pukhov --- ets2panda/checker/ETSchecker.h | 4 +- ets2panda/checker/ets/object.cpp | 38 +++++++++--- ets2panda/checker/ets/typeCreation.cpp | 58 ++++++++++++++++++- .../checker/types/ets/etsFunctionType.cpp | 6 +- ets2panda/checker/types/ets/etsObjectType.cpp | 3 +- ets2panda/checker/types/ets/etsObjectType.h | 5 ++ ets2panda/checker/types/signature.cpp | 8 ++- ets2panda/checker/types/type.cpp | 2 - ets2panda/checker/types/type.h | 6 +- .../lowering/ets/genericBridgesLowering.cpp | 27 +++++++-- .../lowering/ets/genericBridgesLowering.h | 3 +- .../compiler/lowering/ets/lambdaLowering.cpp | 14 ++--- ets2panda/parser/ETSFormattedParser.cpp | 39 +++++++------ ets2panda/parser/ETSparser.cpp | 2 +- ets2panda/parser/ETSparser.h | 2 + ets2panda/parser/innerSourceParser.h | 2 +- ets2panda/parser/program/program.h | 8 +++ .../ets/FixedArray/lambda_type_mismatch.ets | 6 +- .../test/ast/compiler/ets/FunctionType1.ets | 2 +- .../compiler/ets/arrow_function_mismatch.ets | 4 +- .../ast/compiler/ets/etsObjectToString5.ets | 2 +- ...uplicated_with_interface_lambda_member.ets | 2 +- .../ast/compiler/ets/function_subtyping_2.ets | 2 +- .../ast/compiler/ets/function_subtyping_3.ets | 2 +- .../ast/compiler/ets/generic_callback.ets | 12 ++-- .../ets/generics_implicit_lambda2.ets | 2 +- .../compiler/ets/incorrect_call_getter.ets | 4 +- .../test/ast/compiler/ets/lambdaFunction3.ets | 2 +- ...lambda_param_type_cannot_be_determined.ets | 2 +- .../ets/lambda_type_infer_to_rest_type.ets | 2 +- .../ast/compiler/ets/lambda_type_mismatch.ets | 6 +- .../compiler/ets/lambda_type_param_bad.ets | 2 +- .../ets/recordWithLambdaFunction1.ets | 2 +- .../ets/recordWithLambdaFunction2.ets | 2 +- .../ast/compiler/ets/type_error_test2.ets | 2 +- .../ets/variance_typeparam_lambda.ets | 14 ++--- .../ast/compiler/ts/functionWithPattern1.ts | 4 +- .../ast/compiler/ts/functionWithPattern2.ts | 4 +- .../ast/compiler/ts/functionWithPattern3.ts | 4 +- .../ast/compiler/ts/functionWithPattern4.ts | 4 +- .../ast/compiler/ts/functionWithPattern8.ts | 4 +- .../ts/objectLiteralAssignability20.ts | 4 +- .../test/ast/compiler/ts/varRedeclaration9.ts | 4 +- .../test/ast/parser/ets/TypeInferFunc.ets | 2 +- .../annotationUsage_bad_param06.ets | 2 +- .../ets/function_implicit_return_type3.ets | 2 +- .../lambda-type-inference-overloaded-1.ets | 2 +- .../parser/ets/lambda_optional_param_2.ets | 2 +- .../parser/ets/lambda_optional_param_3.ets | 2 +- ...pe_lambda_definition_parameter_invalid.ets | 2 +- ..._type_lambda_definition_return_invalid.ets | 2 +- .../ast/parser/ets/unexpected_token_22.ets | 2 +- .../ast/parser/ets/update_funcscope_error.ets | 2 +- .../astchecker/astchecker-ets-ignored.txt | 3 + ...plugin_proceed_to_state_dump_decl_test.cpp | 2 +- 55 files changed, 235 insertions(+), 117 deletions(-) diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 81fed860b6..51b3e31dae 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -66,6 +66,7 @@ using ComputedAbstracts = ArenaUnorderedMap, ArenaUnorderedSet>>; using ArrayMap = ArenaUnorderedMap, ETSArrayType *, PairHash>; using ObjectInstantiationMap = ArenaUnorderedMap>; +using FunctionTypeInstantiationMap = std::unordered_map; using GlobalArraySignatureMap = ArenaUnorderedMap; using FunctionSignatureMap = ArenaUnorderedMap; using FunctionInterfaceMap = ArenaUnorderedMap; @@ -203,7 +204,7 @@ public: ETSObjectType *BuildAnonymousClassProperties(ir::ClassDefinition *classDef, ETSObjectType *superType); Type *BuildBasicInterfaceProperties(ir::TSInterfaceDeclaration *interfaceDecl); ETSObjectType *GetSuperType(ETSObjectType *type); - ArenaVector GetInterfaces(ETSObjectType *type); + ArenaVector const &GetInterfaces(ETSObjectType *type); void GetInterfacesOfClass(ETSObjectType *type); void GetInterfacesOfInterface(ETSObjectType *type); void ValidateImplementedInterface(ETSObjectType *type, Type *interface, std::unordered_set *extendsSet, @@ -1090,6 +1091,7 @@ private: ArrayMap arrayTypes_; std::vector pendingConstraintCheckRecords_ {}; ObjectInstantiationMap objectInstantiationMap_; + FunctionTypeInstantiationMap functionTypeInstantiationMap_; // not an arena container FunctionSignatureMap invokeToArrowSignatures_; FunctionInterfaceMap arrowToFuncInterfaces_; size_t constraintCheckScopesCount_ {0}; diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index a9e62345ac..94fddc0a46 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -287,7 +287,7 @@ void ETSChecker::GetInterfacesOfInterface(ETSObjectType *type) type->AddObjectFlag(ETSObjectFlags::RESOLVED_INTERFACES); } -ArenaVector ETSChecker::GetInterfaces(ETSObjectType *type) +ArenaVector const &ETSChecker::GetInterfaces(ETSObjectType *type) { ES2PANDA_ASSERT(type->GetDeclNode()->IsClassDefinition() || type->GetDeclNode()->IsTSInterfaceDeclaration()); @@ -2478,6 +2478,20 @@ void ETSChecker::WarnForEndlessLoopInGetterSetter(const ir::MemberExpression *co } } +[[maybe_unused]] static std::unordered_set CollectInstancePropsTransitive(ETSObjectType *classType) +{ + std::unordered_set transitivePropNames; + for (auto const t : classType->TransitiveSupertypes()) { + for (auto const p : t->InstanceMethods()) { + transitivePropNames.insert(p.first); + } + for (auto const p : t->InstanceFields()) { + transitivePropNames.insert(p.first); + } + } + return transitivePropNames; +} + void ETSChecker::CheckValidInheritance(ETSObjectType *classType, ir::ClassDefinition *classDef) { if (classType->SuperType() == nullptr) { @@ -2485,6 +2499,8 @@ void ETSChecker::CheckValidInheritance(ETSObjectType *classType, ir::ClassDefini } const auto &allProps = classType->GetAllProperties(); + auto const interfaceList = GetInterfaces(classType); + auto const instancePropNamesTransitive = CollectInstancePropsTransitive(classType); for (auto *it : allProps) { auto *node = it->Declaration()->Node(); @@ -2492,21 +2508,26 @@ void ETSChecker::CheckValidInheritance(ETSObjectType *classType, ir::ClassDefini node->AsClassProperty()->TsType()->IsTypeError()) { continue; } + if (instancePropNamesTransitive.find(it->Name()) == instancePropNamesTransitive.end()) { + continue; + } - const auto searchFlag = PropertySearchFlags::SEARCH_ALL | PropertySearchFlags::SEARCH_IN_BASE | - PropertySearchFlags::SEARCH_IN_INTERFACES | - PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; - auto *foundInSuper = classType->SuperType()->GetProperty(it->Name(), searchFlag); + const auto searchFlagsSuper = PropertySearchFlags::SEARCH_INSTANCE | PropertySearchFlags::SEARCH_IN_BASE | + PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; + auto *foundInSuper = classType->SuperType()->GetProperty(it->Name(), searchFlagsSuper); ETSObjectType *interfaceFound = nullptr; if (foundInSuper != nullptr) { CheckProperties(classType, classDef, it, foundInSuper, interfaceFound); } - auto interfaceList = GetInterfaces(classType); varbinder::LocalVariable *foundInInterface = nullptr; for (auto *interface : interfaceList) { - auto *propertyFound = interface->GetProperty(it->Name(), searchFlag); + const auto searchFlagsInterfaces = PropertySearchFlags::SEARCH_INSTANCE_METHOD | + PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; + auto *propertyFound = interface->GetProperty(it->Name(), searchFlagsInterfaces); if (propertyFound == nullptr) { continue; } @@ -2820,7 +2841,8 @@ void ETSChecker::CheckInvokeMethodsLegitimacy(ETSObjectType *const classType) } auto searchFlag = PropertySearchFlags::SEARCH_IN_INTERFACES | PropertySearchFlags::SEARCH_IN_BASE | - PropertySearchFlags::SEARCH_STATIC_METHOD; + PropertySearchFlags::SEARCH_STATIC_METHOD | + PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; auto *const invokeMethod = classType->GetProperty(compiler::Signatures::STATIC_INVOKE_METHOD, searchFlag); if (invokeMethod == nullptr) { diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index 99a80c8624..5fd4e60ce5 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -156,9 +156,65 @@ ETSTypeAliasType *ETSChecker::CreateETSTypeAliasType(util::StringView name, cons return ProgramAllocator()->New(this, name, declNode, isRecursive); } +// the "inference" routine of the generic type inference _mutates_ arrow function signature +// even in the case when the arrow signature is computed from the arrow function expression +// Conservatively disable the type caching in that case +static bool WorkaroundForSignatureMutationsInTypeInference(Signature *signature) +{ + if (!signature->HasFunction()) { + return false; + } + auto ast = signature->Function(); + if (!(ast->Parent()->IsArrowFunctionExpression() && ast->Parent()->Parent()->IsCallExpression())) { + return false; + } + + auto callee = ast->Parent()->Parent()->AsCallExpression()->Callee()->TsType(); + if (callee == nullptr || !callee->IsETSMethodType()) { + return false; + } + for (auto sig : callee->AsETSFunctionType()->CallSignatures()) { + if (!sig->TypeParams().empty()) { + return true; + } + } + return false; +} + ETSFunctionType *ETSChecker::CreateETSArrowType(Signature *signature) { - return ProgramAllocator()->New(this, signature); + bool noCaching = false; + auto const typeRef = [&noCaching](Type *t) { + noCaching |= t->IsTypeError(); // "inference" has not succeeded yet + return t; + }; + noCaching |= WorkaroundForSignatureMutationsInTypeInference(signature); + + std::stringstream ss; + ss << "/" << helpers::ToUnderlying(signature->Flags()); + ss << "/"; + for (auto p : signature->GetSignatureInfo()->typeParams) { + ss << ":" << p; + } + ss << "/" << signature->GetSignatureInfo()->minArgCount; + ss << "/r" << typeRef(signature->ReturnType()); + ss << "/"; + for (auto p : signature->GetSignatureInfo()->params) { + ss << ":" << typeRef(p->TsType()); + } + auto restVar = signature->GetSignatureInfo()->restVar; + if (restVar != nullptr) { + ss << "/" << typeRef(restVar->TsType()); + } + auto hash = ss.str(); + + auto &cache = functionTypeInstantiationMap_; + if (auto it = cache.find(hash); !noCaching && it != cache.end()) { + return it->second; + } + auto type = ProgramAllocator()->New(this, signature); + cache.insert({hash, type}); + return type; } ETSFunctionType *ETSChecker::CreateETSMethodType(util::StringView name, ArenaVector &&signatures) diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 669ab5d1ed..aaf6cd4468 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -415,8 +415,10 @@ void ETSFunctionType::CheckVarianceRecursively(TypeRelation *relation, VarianceF relation->TransferVariant(varianceFlag, VarianceFlag::COVARIANT)); } for (auto *typeParam : sig->Params()) { - relation->SetNode( - typeParam->Declaration()->AsParameterDecl()->Node()->AsETSParameterExpression()->TypeAnnotation()); + if (sig->HasFunction()) { + relation->SetNode( + typeParam->Declaration()->AsParameterDecl()->Node()->AsETSParameterExpression()->TypeAnnotation()); + } relation->CheckVarianceRecursively(typeParam->TsType(), relation->TransferVariant(varianceFlag, VarianceFlag::CONTRAVARIANT)); } diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index e107167503..4ca73193be 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -703,7 +703,8 @@ ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const std::string invokeName = checker->FunctionalInterfaceInvokeName(foundArity, hasRest); auto *invoke = GetProperty(util::StringView(invokeName), - PropertySearchFlags::SEARCH_INSTANCE_METHOD | PropertySearchFlags::SEARCH_IN_INTERFACES); + PropertySearchFlags::SEARCH_INSTANCE_METHOD | PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION); ES2PANDA_ASSERT(invoke != nullptr && invoke->TsType() != nullptr && invoke->TsType()->IsETSFunctionType()); return invoke->TsType()->AsETSFunctionType(); } diff --git a/ets2panda/checker/types/ets/etsObjectType.h b/ets2panda/checker/types/ets/etsObjectType.h index 2d9cafe8c9..e14f9c1085 100644 --- a/ets2panda/checker/types/ets/etsObjectType.h +++ b/ets2panda/checker/types/ets/etsObjectType.h @@ -212,6 +212,11 @@ public: return baseType_; } + const ArenaSet &TransitiveSupertypes() const noexcept + { + return transitiveSupertypes_; + } + ETSObjectType const *GetConstOriginalBaseType() const noexcept; ETSObjectType *GetOriginalBaseType() const noexcept diff --git a/ets2panda/checker/types/signature.cpp b/ets2panda/checker/types/signature.cpp index 156647880f..e70ac60c2e 100644 --- a/ets2panda/checker/types/signature.cpp +++ b/ets2panda/checker/types/signature.cpp @@ -153,9 +153,12 @@ void Signature::ToString(std::stringstream &ss, const varbinder::Variable *varia } ss << "("; + size_t pidx = 1; for (auto it = signatureInfo_->params.begin(); it != signatureInfo_->params.end(); it++) { - ss << (!(*it)->Name().StartsWith(compiler::GENSYM_CORE) ? (*it)->Name().Utf8() : compiler::DUMMY_ID); + ss << (!this->HasFunction() + ? "p" + std::to_string(pidx++) + : (!(*it)->Name().StartsWith(compiler::GENSYM_CORE) ? (*it)->Name().Utf8() : compiler::DUMMY_ID)); if ((*it)->HasFlag(varbinder::VariableFlags::OPTIONAL)) { ss << "?"; @@ -176,7 +179,8 @@ void Signature::ToString(std::stringstream &ss, const varbinder::Variable *varia } ss << "..."; - ss << (!signatureInfo_->restVar->Name().StartsWith(compiler::GENSYM_CORE) + ss << (!this->HasFunction() ? "p" + std::to_string(pidx++) + : !signatureInfo_->restVar->Name().StartsWith(compiler::GENSYM_CORE) ? signatureInfo_->restVar->Name().Utf8() : compiler::DUMMY_ID); ss << ": "; diff --git a/ets2panda/checker/types/type.cpp b/ets2panda/checker/types/type.cpp index cc2f70dcd8..08be5eedcd 100644 --- a/ets2panda/checker/types/type.cpp +++ b/ets2panda/checker/types/type.cpp @@ -22,8 +22,6 @@ namespace ark::es2panda::checker { -std::mutex Type::idLock_ {}; - bool Type::IsETSResizableArrayType() const { return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_ARRAY); diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index 96526b3089..9489e0873d 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -50,17 +50,15 @@ class Type { public: explicit Type(TypeFlag flag) : typeFlags_(flag) { - std::lock_guard lock(idLock_); - static uint32_t typeId = 0; - ES2PANDA_ASSERT(typeId < std::numeric_limits::max()); + static std::atomic typeId = 0; id_ = ++typeId; + ES2PANDA_ASSERT(id_ != std::numeric_limits::max()); } NO_COPY_SEMANTIC(Type); NO_MOVE_SEMANTIC(Type); virtual ~Type() = default; - static std::mutex idLock_; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define TYPE_IS_CHECKS(typeFlag, typeName) \ diff --git a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp index bc15ac423a..0fa3241d61 100644 --- a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp +++ b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp @@ -405,9 +405,28 @@ GenericBridgesPhase::Substitutions GenericBridgesPhase::GetSubstitutions( return substitutions; } -void GenericBridgesPhase::ProcessInterfaces(ir::ClassDefinition *const classDefinition, - ArenaVector const &interfaces) const +static std::unordered_set CollectInterfacesTransitive(checker::ETSObjectType *type) { + std::unordered_set collected; + + auto traverse = [&collected](auto &&self, checker::ETSObjectType *t) { + if (t->TypeArguments().empty() || !collected.insert(t).second) { + return; + } + for (auto itf : t->Interfaces()) { + self(self, itf); + } + }; + for (auto itf : type->Interfaces()) { + traverse(traverse, itf); + } + return collected; +} + +void GenericBridgesPhase::ProcessInterfaces(ir::ClassDefinition *const classDefinition) const +{ + auto interfaces = CollectInterfacesTransitive(classDefinition->TsType()->AsETSObjectType()); + for (auto const *interfaceType : interfaces) { auto const &typeParameters = interfaceType->GetConstOriginalBaseType()->AsETSObjectType()->TypeArguments(); if (!typeParameters.empty()) { @@ -418,15 +437,13 @@ void GenericBridgesPhase::ProcessInterfaces(ir::ClassDefinition *const classDefi CreateGenericBridges(classDefinition, substitutions, interfaceBody); } } - - ProcessInterfaces(classDefinition, interfaceType->Interfaces()); } } ir::ClassDefinition *GenericBridgesPhase::ProcessClassDefinition(ir::ClassDefinition *const classDefinition) const { // Check class interfaces. - ProcessInterfaces(classDefinition, classDefinition->TsType()->AsETSObjectType()->Interfaces()); + ProcessInterfaces(classDefinition); // Check if the base class is a generic class. if (classDefinition->Super() == nullptr || classDefinition->Super()->TsType() == nullptr || diff --git a/ets2panda/compiler/lowering/ets/genericBridgesLowering.h b/ets2panda/compiler/lowering/ets/genericBridgesLowering.h index 2a6feba7c6..03e24cbe5b 100644 --- a/ets2panda/compiler/lowering/ets/genericBridgesLowering.h +++ b/ets2panda/compiler/lowering/ets/genericBridgesLowering.h @@ -38,8 +38,7 @@ private: ir::ClassDefinition *ProcessClassDefinition(ir::ClassDefinition *classDefinition) const; - void ProcessInterfaces(ir::ClassDefinition *classDefinition, - ArenaVector const &interfaces) const; + void ProcessInterfaces(ir::ClassDefinition *classDefinition) const; Substitutions GetSubstitutions(checker::ETSObjectType const *const objectType, ArenaVector const &typeParameters) const; diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index b173028694..333700f333 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -1590,8 +1590,11 @@ static ir::AstNode *InsertInvokeCall(public_lib::Context *ctx, ir::CallExpressio util::StringView invokeMethodName = util::UString {checker->FunctionalInterfaceInvokeName(arity, hasRestParam), allocator}.View(); - auto *prop = ifaceType->GetProperty(invokeMethodName, checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD | - checker::PropertySearchFlags::SEARCH_IN_INTERFACES); + auto *prop = + ifaceType->GetProperty(invokeMethodName, checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD | + checker::PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION | + checker::PropertySearchFlags::SEARCH_IN_BASE | + checker::PropertySearchFlags::SEARCH_IN_INTERFACES); ES2PANDA_ASSERT(prop != nullptr); auto *invoke0Id = allocator->New(invokeMethodName, allocator); ES2PANDA_ASSERT(invoke0Id != nullptr); @@ -1688,12 +1691,7 @@ static ir::AstNode *BuildLambdaClassWhenNeeded(public_lib::Context *ctx, ir::Ast mexpr->TsType()->IsETSFunctionType() && mexpr->Object()->TsType()->IsETSObjectType() && mexpr->PropVar() != nullptr && !mexpr->PropVar()->HasFlag(varbinder::VariableFlags::DYNAMIC)) { ES2PANDA_ASSERT(mexpr->Property()->IsIdentifier()); - auto *var = mexpr->Object()->TsType()->AsETSObjectType()->GetProperty( - mexpr->Property()->AsIdentifier()->Name(), - checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD | - checker::PropertySearchFlags::SEARCH_STATIC_METHOD | checker::PropertySearchFlags::SEARCH_IN_BASE | - checker::PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION); - if (IsValidFunctionDeclVar(var) && !IsInCalleePosition(mexpr) && !IsOverloadedName(mexpr)) { + if (IsValidFunctionDeclVar(mexpr->PropVar()) && !IsInCalleePosition(mexpr) && !IsOverloadedName(mexpr)) { return ConvertFunctionReference(ctx, mexpr); } } diff --git a/ets2panda/parser/ETSFormattedParser.cpp b/ets2panda/parser/ETSFormattedParser.cpp index b999b9a7bf..6fb21ed010 100644 --- a/ets2panda/parser/ETSFormattedParser.cpp +++ b/ets2panda/parser/ETSFormattedParser.cpp @@ -15,6 +15,7 @@ #include "ETSparser.h" +#include "lexer/ETSLexer.h" #include "lexer/lexer.h" #include "ir/typeNode.h" #include "ir/expressions/identifier.h" @@ -283,9 +284,8 @@ ArenaVector &ETSParser::ParseExpressionsArrayFormatPlaceholder ir::Statement *ETSParser::CreateStatement(std::string_view const sourceCode) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); lexer::SourcePosition const startLoc = lexer->GetToken().Start(); lexer->NextToken(); @@ -334,9 +334,8 @@ ir::Statement *ETSParser::CreateFormattedStatement(std::string_view const source ir::TypeNode *ETSParser::CreateFormattedTypeAnnotation(std::string_view const sourceCode) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); lexer->NextToken(); TypeAnnotationParsingOptions options = TypeAnnotationParsingOptions::NO_OPTS; return ParseTypeAnnotation(&options); @@ -353,9 +352,8 @@ ir::TypeNode *ETSParser::CreateFormattedTypeAnnotation(std::string_view const so ArenaVector ETSParser::CreateStatements(std::string_view const sourceCode) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); lexer->NextToken(); return ParseStatementList(StatementParsingFlags::STMT_GLOBAL_LEXICAL); @@ -423,9 +421,8 @@ ir::AstNode *ETSParser::CreateFormattedClassElement(std::string_view sourceCode, ir::AstNode *ETSParser::CreateClassElement(std::string_view sourceCode, const ArenaVector &properties, ir::ClassDefinitionModifiers modifiers) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); auto savedCtx = SavedStatusContext(&GetContext()); SavedClassPrivateContext classContext(this); @@ -447,9 +444,8 @@ ir::Statement *ETSParser::CreateFormattedClassDeclaration(std::string_view sourc ir::Statement *ETSParser::CreateClassDeclaration(std::string_view sourceCode, bool allowStatic) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); auto savedCtx = SavedStatusContext(&GetContext()); @@ -490,9 +486,8 @@ ir::Statement *ETSParser::CreateClassDeclaration(std::string_view sourceCode, bo ir::MethodDefinition *ETSParser::CreateConstructorDefinition(ir::ModifierFlags modifiers, std::string_view const sourceCode) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); auto const startLoc = Lexer()->GetToken().Start(); Lexer()->NextToken(); @@ -523,9 +518,8 @@ ir::MethodDefinition *ETSParser::CreateConstructorDefinition(ir::ModifierFlags m ir::Expression *ETSParser::CreateExpression(std::string_view const sourceCode, ExpressionParseFlags const flags) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); lexer->NextToken(); @@ -550,11 +544,21 @@ ir::Expression *ETSParser::CreateFormattedExpression(std::string_view const sour return returnExpression; } -ir::Statement *ETSParser::CreateTopLevelStatement(std::string_view const sourceCode) +[[nodiscard]] std::unique_ptr ETSParser::InitFormattedLexer( + // CC-OFFNXT(G.FMT.06-CPP) project code style + [[maybe_unused]] std::string_view formattedName, std::string_view sourceCode) { util::UString source {sourceCode, Allocator()}; + GetProgram()->SetSource(source.View().Utf8(), util::Path(), ""); + auto lexer = std::make_unique(&GetContext(), DiagnosticEngine()); + SetLexer(lexer.get()); + return lexer; +} + +ir::Statement *ETSParser::CreateTopLevelStatement(std::string_view const sourceCode) +{ auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); lexer->NextToken(); @@ -572,9 +576,8 @@ ir::Statement *ETSParser::CreateFormattedTopLevelStatement(std::string_view cons ir::TypeNode *ETSParser::CreateTypeAnnotation(TypeAnnotationParsingOptions *options, std::string_view const sourceCode) { - util::UString source {sourceCode, Allocator()}; auto const isp = InnerSourceParser(this); - auto const lexer = InitLexer({GetContext().FormattingFileName(), source.View().Utf8()}); + auto const lexer = InitFormattedLexer(GetContext().FormattingFileName(), sourceCode); lexer->NextToken(); return ParseTypeAnnotation(options); diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 0e9894d3ff..0ede9666e1 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -2515,7 +2515,7 @@ InnerSourceParser::InnerSourceParser(ETSParser *parser) : parser_(parser), savedLexer_(parser_->Lexer()), savedSourceCode_(parser_->GetProgram()->SourceCode()), - savedSourceFile_(parser_->GetProgram()->SourceFilePath()), + savedSourceFile_(parser_->GetProgram()->SourceFile()), savedSourceFilePath_(parser_->GetProgram()->SourceFileFolder()), savedRelativeFilePath_(parser_->GetProgram()->RelativeFilePath()) { diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index eeb70f15dc..f2fd60e423 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -160,6 +160,8 @@ private: ArenaVector &ParseAstNodesArrayFormatPlaceholder() override; ArenaVector &ParseStatementsArrayFormatPlaceholder() override; ArenaVector &ParseExpressionsArrayFormatPlaceholder() override; + [[nodiscard]] std::unique_ptr InitFormattedLexer(std::string_view formattedName, + std::string_view sourceCode); ir::Statement *CreateStatement(std::string_view sourceCode); ir::MethodDefinition *CreateConstructorDefinition(ir::ModifierFlags modifiers, std::string_view sourceCode); ir::Statement *CreateClassDeclaration(std::string_view sourceCode, bool allowStatic = false); diff --git a/ets2panda/parser/innerSourceParser.h b/ets2panda/parser/innerSourceParser.h index c8d1385747..e3c31989bb 100644 --- a/ets2panda/parser/innerSourceParser.h +++ b/ets2panda/parser/innerSourceParser.h @@ -42,7 +42,7 @@ private: ETSParser *parser_; lexer::Lexer *savedLexer_; util::StringView savedSourceCode_ {}; - util::StringView savedSourceFile_ {}; + util::Path savedSourceFile_ {}; util::StringView savedSourceFilePath_ {}; util::StringView savedRelativeFilePath_ {}; }; diff --git a/ets2panda/parser/program/program.h b/ets2panda/parser/program/program.h index fbb24ddfd2..0d6e9fe5c6 100644 --- a/ets2panda/parser/program/program.h +++ b/ets2panda/parser/program/program.h @@ -226,6 +226,14 @@ public: packageStartPosition_ = start; } + void SetSource(const util::StringView &sourceCode, const util::Path &sourceFilePath, + const util::StringView &sourceFileFolder) + { + sourceCode_ = sourceCode; + sourceFile_ = sourceFilePath; + sourceFileFolder_ = sourceFileFolder; + } + void SetSource(const util::StringView &sourceCode, const util::StringView &sourceFilePath, const util::StringView &sourceFileFolder) { diff --git a/ets2panda/test/ast/compiler/ets/FixedArray/lambda_type_mismatch.ets b/ets2panda/test/ast/compiler/ets/FixedArray/lambda_type_mismatch.ets index f7e4961dcd..50ae65365c 100644 --- a/ets2panda/test/ast/compiler/ets/FixedArray/lambda_type_mismatch.ets +++ b/ets2panda/test/ast/compiler/ets/FixedArray/lambda_type_mismatch.ets @@ -19,6 +19,6 @@ let fob:(...args:FixedArray)=>number = (...args:FixedArray) =>{} let foc:(c:string, ...args:FixedArray)=>string = (c:number, ...args:FixedArray):string=>{} -/* @@? 16:56 Error TypeError: Type '(c: Double, ...args: FixedArray) => void' cannot be assigned to type '(c: String, ...args: FixedArray) => void' */ -/* @@? 18:48 Error TypeError: Type '(...args: FixedArray) => void' cannot be assigned to type '(...args: FixedArray) => Double' */ -/* @@? 20:58 Error TypeError: Type '(c: Double, ...args: FixedArray) => String' cannot be assigned to type '(c: String, ...args: FixedArray) => String' */ +/* @@? 16:56 Error TypeError: Type '(p1: Double, ...p2: FixedArray) => void' cannot be assigned to type '(p1: String, ...p2: FixedArray) => void' */ +/* @@? 18:48 Error TypeError: Type '(...p1: FixedArray) => void' cannot be assigned to type '(...p1: FixedArray) => Double' */ +/* @@? 20:58 Error TypeError: Type '(p1: Double, ...p2: FixedArray) => String' cannot be assigned to type '(p1: String, ...p2: FixedArray) => String' */ diff --git a/ets2panda/test/ast/compiler/ets/FunctionType1.ets b/ets2panda/test/ast/compiler/ets/FunctionType1.ets index a69431d215..e8d1d5c16e 100644 --- a/ets2panda/test/ast/compiler/ets/FunctionType1.ets +++ b/ets2panda/test/ast/compiler/ets/FunctionType1.ets @@ -26,4 +26,4 @@ function main(): void { func = /* @@ label */klass.a; } -/* @@@ label Error TypeError: Type '(a: Int, b: Int) => int' cannot be assigned to type '(a: Int, b: Int) => void' */ +/* @@@ label Error TypeError: Type '(p1: Int, p2: Int) => int' cannot be assigned to type '(p1: Int, p2: Int) => void' */ diff --git a/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets b/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets index 8ada0b3f4a..67654e178e 100644 --- a/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets +++ b/ets2panda/test/ast/compiler/ets/arrow_function_mismatch.ets @@ -17,5 +17,5 @@ let foo: (P: string, Q: string) => void foo((value: Object): void => { }, (err: Error): void => { }) -/* @@? 18:1 Error TypeError: No matching call signature for ((value: Object) => void, (err: Error) => void) */ -/* @@? 18:5 Error TypeError: Type '(value: Object) => void' is not compatible with type 'String' at index 1 */ +/* @@? 18:1 Error TypeError: No matching call signature for ((p1: Object) => void, (p1: Error) => void) */ +/* @@? 18:5 Error TypeError: Type '(p1: Object) => void' is not compatible with type 'String' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/etsObjectToString5.ets b/ets2panda/test/ast/compiler/ets/etsObjectToString5.ets index faae74dd13..d05bfd4701 100644 --- a/ets2panda/test/ast/compiler/ets/etsObjectToString5.ets +++ b/ets2panda/test/ast/compiler/ets/etsObjectToString5.ets @@ -19,4 +19,4 @@ let g:((y:A) => A|null)|null = /* @@ label */(y:A): A| return y; } -/* @@@ label Error TypeError: Type '(y: A) => A|null' cannot be assigned to type '((y: A) => A|null)|null' */ +/* @@@ label Error TypeError: Type '(p1: A) => A|null' cannot be assigned to type '((p1: A) => A|null)|null' */ diff --git a/ets2panda/test/ast/compiler/ets/extension_function_duplicated_with_interface_lambda_member.ets b/ets2panda/test/ast/compiler/ets/extension_function_duplicated_with_interface_lambda_member.ets index 266caefbf3..d28bab4fce 100644 --- a/ets2panda/test/ast/compiler/ets/extension_function_duplicated_with_interface_lambda_member.ets +++ b/ets2panda/test/ast/compiler/ets/extension_function_duplicated_with_interface_lambda_member.ets @@ -29,4 +29,4 @@ let a:A = { console.log(a.foo()) /* @@@ label Error TypeError: The extension function 'foo' has the same name with public method in class A */ -/* @@@ label1 Error TypeError: Type '(=t: A) => String' is not compatible with type '() => String' at property 'foo' */ +/* @@@ label1 Error TypeError: Type '(p1: A) => String' is not compatible with type '() => String' at property 'foo' */ diff --git a/ets2panda/test/ast/compiler/ets/function_subtyping_2.ets b/ets2panda/test/ast/compiler/ets/function_subtyping_2.ets index 4c5b9c11ed..73201059ad 100644 --- a/ets2panda/test/ast/compiler/ets/function_subtyping_2.ets +++ b/ets2panda/test/ast/compiler/ets/function_subtyping_2.ets @@ -19,4 +19,4 @@ class B extends A {} function main(): void { let x: (p: B) => B = /* @@ label */(p: A): A => { return new B() } } -/* @@@ label Error TypeError: Type '(p: A) => A' cannot be assigned to type '(p: B) => B' */ +/* @@@ label Error TypeError: Type '(p1: A) => A' cannot be assigned to type '(p1: B) => B' */ diff --git a/ets2panda/test/ast/compiler/ets/function_subtyping_3.ets b/ets2panda/test/ast/compiler/ets/function_subtyping_3.ets index a27238968e..4728492c5b 100644 --- a/ets2panda/test/ast/compiler/ets/function_subtyping_3.ets +++ b/ets2panda/test/ast/compiler/ets/function_subtyping_3.ets @@ -19,4 +19,4 @@ class B extends A {} function main(): void { let x: (p: A) => A = /* @@ label */(p: B): B => { return new B() } } -/* @@@ label Error TypeError: Type '(p: B) => B' cannot be assigned to type '(p: A) => A' */ +/* @@@ label Error TypeError: Type '(p1: B) => B' cannot be assigned to type '(p1: A) => A' */ diff --git a/ets2panda/test/ast/compiler/ets/generic_callback.ets b/ets2panda/test/ast/compiler/ets/generic_callback.ets index 6e6c2919d4..988db1f0fc 100644 --- a/ets2panda/test/ast/compiler/ets/generic_callback.ets +++ b/ets2panda/test/ast/compiler/ets/generic_callback.ets @@ -18,11 +18,11 @@ } let x = [1, 2, 3].map(identity)[0]; -/* @@? 19:9 Error TypeError: No matching call signature for map((a: A) => A) */ +/* @@? 19:9 Error TypeError: No matching call signature for map((p1: A) => A) */ /* @@? 19:9 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 19:9 Error TypeError: No matching call signature for map((a: A) => A) */ +/* @@? 19:9 Error TypeError: No matching call signature for map((p1: A) => A) */ /* @@? 19:9 Error TypeError: Indexed access is not supported for such expression type. */ -/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Int, array: Array) => A' at index 1 */ -/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Int, array: ReadonlyArray) => A' at index 1 */ -/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Int, array: Array) => A' at index 1 */ -/* @@? 19:23 Error TypeError: Type '(a: A) => A' is not compatible with type '(value: Int, index: Int, array: ReadonlyArray) => A' at index 1 */ +/* @@? 19:23 Error TypeError: Type '(p1: A) => A' is not compatible with type '(p1: Int, p2: Int, p3: Array) => A' at index 1 */ +/* @@? 19:23 Error TypeError: Type '(p1: A) => A' is not compatible with type '(p1: Int, p2: Int, p3: ReadonlyArray) => A' at index 1 */ +/* @@? 19:23 Error TypeError: Type '(p1: A) => A' is not compatible with type '(p1: Int, p2: Int, p3: Array) => A' at index 1 */ +/* @@? 19:23 Error TypeError: Type '(p1: A) => A' is not compatible with type '(p1: Int, p2: Int, p3: ReadonlyArray) => A' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/generics_implicit_lambda2.ets b/ets2panda/test/ast/compiler/ets/generics_implicit_lambda2.ets index 5b39271b37..340c91b8e3 100644 --- a/ets2panda/test/ast/compiler/ets/generics_implicit_lambda2.ets +++ b/ets2panda/test/ast/compiler/ets/generics_implicit_lambda2.ets @@ -19,4 +19,4 @@ function main() { foo(/* @@ label */(a: int, b: String, c: String): String => { return "XXX" }); } -/* @@@ label Error TypeError: Type '(a: Int, b: String, c: String) => String' is not compatible with type '(a: Int, b: String, c: Int) => String' at index 1 */ +/* @@@ label Error TypeError: Type '(p1: Int, p2: String, p3: String) => String' is not compatible with type '(p1: Int, p2: String, p3: Int) => String' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/incorrect_call_getter.ets b/ets2panda/test/ast/compiler/ets/incorrect_call_getter.ets index 5b4c4d31db..61d54f1ecd 100644 --- a/ets2panda/test/ast/compiler/ets/incorrect_call_getter.ets +++ b/ets2panda/test/ast/compiler/ets/incorrect_call_getter.ets @@ -32,6 +32,6 @@ export class ConM implements inter { /* @@? 22:10 Error TypeError: 'The special predefined method '$_get' shouldn't have void return type. */ /* @@? 25:36 Error TypeError: ConM is not abstract and does not override abstract method gett(k: Double): Double in inter */ -/* @@? 29:9 Error TypeError: No matching indexing signature for $_get((k: Double) => Double) */ -/* @@? 29:22 Error TypeError: Type '(k: Double) => Double' is not compatible with type 'Double' at index 1 */ +/* @@? 29:9 Error TypeError: No matching indexing signature for $_get((p1: Double) => Double) */ +/* @@? 29:22 Error TypeError: Type '(p1: Double) => Double' is not compatible with type 'Double' at index 1 */ /* @@? 29:22 Error TypeError: Cannot find index access method with the required signature. */ diff --git a/ets2panda/test/ast/compiler/ets/lambdaFunction3.ets b/ets2panda/test/ast/compiler/ets/lambdaFunction3.ets index 27787e59c7..c57775d264 100644 --- a/ets2panda/test/ast/compiler/ets/lambdaFunction3.ets +++ b/ets2panda/test/ast/compiler/ets/lambdaFunction3.ets @@ -19,4 +19,4 @@ function foo(): void { } } -/* @@@ label Error TypeError: Type '(b: Int) => void' cannot be assigned to type '(b: String) => void' */ +/* @@@ label Error TypeError: Type '(p1: Int) => void' cannot be assigned to type '(p1: String) => void' */ diff --git a/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.ets b/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.ets index 03909d6e39..c97d4a4f45 100644 --- a/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.ets +++ b/ets2panda/test/ast/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.ets @@ -19,4 +19,4 @@ function main() { /* @@ label */foo((value) => {}) } -/* @@@ label Error TypeError: No matching call signature for foo((value: *ERROR_TYPE*) => void) */ \ No newline at end of file +/* @@@ label Error TypeError: No matching call signature for foo((p1: *ERROR_TYPE*) => void) */ \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/lambda_type_infer_to_rest_type.ets b/ets2panda/test/ast/compiler/ets/lambda_type_infer_to_rest_type.ets index 1a44914293..1c5366e750 100644 --- a/ets2panda/test/ast/compiler/ets/lambda_type_infer_to_rest_type.ets +++ b/ets2panda/test/ast/compiler/ets/lambda_type_infer_to_rest_type.ets @@ -17,4 +17,4 @@ declare function testRest(a: (t: T, t1: T, ...ts: T[]) => void): T testRest((t1:number, t2:boolean, t3) => {}) -/* @@? 18:10 Error TypeError: Type '(t1: Double, t2: Boolean, t3: never) => void' is not compatible with type '(t: never, t1: never, ...ts: Array) => void' at index 1 */ +/* @@? 18:10 Error TypeError: Type '(p1: Double, p2: Boolean, p3: never) => void' is not compatible with type '(p1: never, p2: never, ...p3: Array) => void' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/lambda_type_mismatch.ets b/ets2panda/test/ast/compiler/ets/lambda_type_mismatch.ets index 4c0ce6a576..6c0759b713 100644 --- a/ets2panda/test/ast/compiler/ets/lambda_type_mismatch.ets +++ b/ets2panda/test/ast/compiler/ets/lambda_type_mismatch.ets @@ -19,6 +19,6 @@ let fob:(...args:number[])=>number = (...args:number[]) =>{} let foc:(c:string, ...args:number[])=>string = (c:number, ...args:string[]):string=>{} -/* @@? 16:46 Error TypeError: Type '(c: Double, ...args: Array) => void' cannot be assigned to type '(c: String, ...args: Array) => void' */ -/* @@? 18:38 Error TypeError: Type '(...args: Array) => void' cannot be assigned to type '(...args: Array) => Double' */ -/* @@? 20:48 Error TypeError: Type '(c: Double, ...args: Array) => String' cannot be assigned to type '(c: String, ...args: Array) => String' */ +/* @@? 16:46 Error TypeError: Type '(p1: Double, ...p2: Array) => void' cannot be assigned to type '(p1: String, ...p2: Array) => void' */ +/* @@? 18:38 Error TypeError: Type '(...p1: Array) => void' cannot be assigned to type '(...p1: Array) => Double' */ +/* @@? 20:48 Error TypeError: Type '(p1: Double, ...p2: Array) => String' cannot be assigned to type '(p1: String, ...p2: Array) => String' */ diff --git a/ets2panda/test/ast/compiler/ets/lambda_type_param_bad.ets b/ets2panda/test/ast/compiler/ets/lambda_type_param_bad.ets index 00bb143037..d9802fb401 100644 --- a/ets2panda/test/ast/compiler/ets/lambda_type_param_bad.ets +++ b/ets2panda/test/ast/compiler/ets/lambda_type_param_bad.ets @@ -28,4 +28,4 @@ class A { } } -/* @@? 19:40 Error TypeError: Type '(sr: String) => void' is not compatible with type '(sr: Double) => void' at index 1 */ +/* @@? 19:40 Error TypeError: Type '(p1: String) => void' is not compatible with type '(p1: Double) => void' at index 1 */ diff --git a/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction1.ets b/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction1.ets index c496f27239..ea86b7f81d 100644 --- a/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction1.ets +++ b/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction1.ets @@ -21,4 +21,4 @@ function main(): void { } } -/* @@? 20:12 Error TypeError: Type '(param: String) => String' is not compatible with type '(param: Double) => String' at index 2 */ +/* @@? 20:12 Error TypeError: Type '(p1: String) => String' is not compatible with type '(p1: Double) => String' at index 2 */ diff --git a/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction2.ets b/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction2.ets index 662eea658f..125802b3b0 100644 --- a/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction2.ets +++ b/ets2panda/test/ast/compiler/ets/recordWithLambdaFunction2.ets @@ -25,4 +25,4 @@ function main(): void { /* @@? 23:5 Error TypeError: No matching indexing signature for $_set(Int, Int) */ /* @@? 23:16 Error TypeError: Cannot find index access method with the required signature. */ -/* @@? 23:21 Error TypeError: Type 'Int' is not compatible with type '(param: Double) => String' at index 2 */ +/* @@? 23:21 Error TypeError: Type 'Int' is not compatible with type '(p1: Double) => String' at index 2 */ diff --git a/ets2panda/test/ast/compiler/ets/type_error_test2.ets b/ets2panda/test/ast/compiler/ets/type_error_test2.ets index 08c72c921a..2763e7ec55 100644 --- a/ets2panda/test/ast/compiler/ets/type_error_test2.ets +++ b/ets2panda/test/ast/compiler/ets/type_error_test2.ets @@ -18,7 +18,7 @@ let f:(c:string, ...abe])=>void = (c:be ...abe])=>{} /* @@? 16:18 Error SyntaxError: Rest parameter should be either array or tuple type. */ /* @@? 16:24 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ /* @@? 16:24 Error SyntaxError: Rest parameter must be the last formal parameter. */ -/* @@? 16:35 Error TypeError: Type '(c: *ERROR_TYPE*) => void' cannot be assigned to type '(c: String, ...abe: *ERROR_TYPE*) => void' */ +/* @@? 16:35 Error TypeError: Type '(p1: *ERROR_TYPE*) => void' cannot be assigned to type '(p1: String, ...p2: *ERROR_TYPE*) => void' */ /* @@? 16:38 Error TypeError: Cannot find type 'be'. */ /* @@? 16:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */ /* @@? 16:41 Error SyntaxError: Expected '=>', got '...'. */ diff --git a/ets2panda/test/ast/compiler/ets/variance_typeparam_lambda.ets b/ets2panda/test/ast/compiler/ets/variance_typeparam_lambda.ets index d481632145..89adc5dea1 100644 --- a/ets2panda/test/ast/compiler/ets/variance_typeparam_lambda.ets +++ b/ets2panda/test/ast/compiler/ets/variance_typeparam_lambda.ets @@ -37,20 +37,20 @@ class A{ paramsFunc2(a:(a:T2)=>T1){} paramsFunc3(a:(a:T3)=>T3){} paramsFunc4(a:(a:(a:T1)=>T2)=>T1){} - paramsFunc5(a:(a:/* @@ label11*/(a:T1)=>T1)=>T1){} //CTE - paramsFunc6(a:(a:(a:/* @@ label12*/T2)=>T2)=>T1){} //CTE + paramsFunc5(a:/* @@ label11*/(a:(a:T1)=>T1)=>T1){} //CTE + paramsFunc6(a:/* @@ label12*/(a:(a:T2)=>T2)=>T1){} //CTE paramsFunc7(a:(a:(a:(a:T2)=>T1)=>T2)=>T1){} } /* @@@ label1 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'invariant' position. */ -/* @@@ label2 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'invariant' position. */ +/* @@@ label1 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'invariant' position. */ /* @@@ label3 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'invariant' position. */ -/* @@@ label4 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'invariant' position. */ +/* @@@ label3 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'invariant' position. */ /* @@@ label5 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'out' position. */ -/* @@@ label6 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'in' position. */ +/* @@@ label5 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'in' position. */ /* @@@ label7 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'out' position. */ -/* @@@ label8 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'in' position. */ +/* @@@ label7 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'in' position. */ /* @@@ label9 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'in' position. */ -/* @@@ label10 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'out' position. */ +/* @@@ label9 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'out' position. */ /* @@@ label11 Error TypeError: Type Parameter 'T1' is declared as 'in' but occurs in 'out' position. */ /* @@@ label12 Error TypeError: Type Parameter 'T2' is declared as 'out' but occurs in 'in' position. */ diff --git a/ets2panda/test/ast/compiler/ts/functionWithPattern1.ts b/ets2panda/test/ast/compiler/ts/functionWithPattern1.ts index 789085d752..9e9c761aa8 100644 --- a/ets2panda/test/ast/compiler/ts/functionWithPattern1.ts +++ b/ets2panda/test/ast/compiler/ts/functionWithPattern1.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ function foo([{ x = 6 }, y = "foo", z] = [{ x: "foo" }, 2, 3]) { } /* @@ label */foo + 5; -/* @@@ label Error TypeError: operator + cannot be applied to types ([{ x }, y, z]?: [{ x: string; }, number, number]) => void and number */ +/* @@@ label Error TypeError: operator + cannot be applied to types (p1?: [{ x: string; }, number, number]) => void and number */ diff --git a/ets2panda/test/ast/compiler/ts/functionWithPattern2.ts b/ets2panda/test/ast/compiler/ts/functionWithPattern2.ts index 20b78adc61..997d11fb5d 100644 --- a/ets2panda/test/ast/compiler/ts/functionWithPattern2.ts +++ b/ets2panda/test/ast/compiler/ts/functionWithPattern2.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ function foo({ x = 6, y = "foo" } = { x: "foo" }) { } /* @@ label */foo + 5; -/* @@@ label Error TypeError: operator + cannot be applied to types ({ x, y }?: { x?: string; y?: string; }) => void and number */ +/* @@@ label Error TypeError: operator + cannot be applied to types (p1?: { x?: string; y?: string; }) => void and number */ diff --git a/ets2panda/test/ast/compiler/ts/functionWithPattern3.ts b/ets2panda/test/ast/compiler/ts/functionWithPattern3.ts index 88e8ef801b..ebade52ee8 100644 --- a/ets2panda/test/ast/compiler/ts/functionWithPattern3.ts +++ b/ets2panda/test/ast/compiler/ts/functionWithPattern3.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ function foo({ x: { asd }, y: { t = 6, r = "foo" } = { t: "foo" } }) { } /* @@ label */foo + 5; -/* @@@ label Error TypeError: operator + cannot be applied to types ({ x: { asd }, y: { t, r } }: { x?: { asd: any; }; y?: { t: string; }; }) => void and number */ +/* @@@ label Error TypeError: operator + cannot be applied to types (p1: { x?: { asd: any; }; y?: { t: string; }; }) => void and number */ diff --git a/ets2panda/test/ast/compiler/ts/functionWithPattern4.ts b/ets2panda/test/ast/compiler/ts/functionWithPattern4.ts index 2421b9b8a0..369b21c020 100644 --- a/ets2panda/test/ast/compiler/ts/functionWithPattern4.ts +++ b/ets2panda/test/ast/compiler/ts/functionWithPattern4.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,4 +19,4 @@ function foo({ a, b: { t = "foo" } = { t: 3 }, d: [e = {}, f = 6] = [3, ["foo", } /* @@ label */foo + 5; -/* @@@ label Error TypeError: operator + cannot be applied to types ({ a, b: { t }, d: [e, f] }?: { a: boolean; b?: { t: number; }; d?: [number, [string, string]]; }) => void and number */ +/* @@@ label Error TypeError: operator + cannot be applied to types (p1?: { a: boolean; b?: { t: number; }; d?: [number, [string, string]]; }) => void and number */ diff --git a/ets2panda/test/ast/compiler/ts/functionWithPattern8.ts b/ets2panda/test/ast/compiler/ts/functionWithPattern8.ts index 5795cb9bf0..f278b44b03 100644 --- a/ets2panda/test/ast/compiler/ts/functionWithPattern8.ts +++ b/ets2panda/test/ast/compiler/ts/functionWithPattern8.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,4 +20,4 @@ function foo([a = 2, { b: [c = 6, d] = [true, [5n, "foo"]], t = { a: 3, b: { a: /* @@ label */foo + 5; -/* @@@ label Error TypeError: operator + cannot be applied to types ([a, { b: [c, d], t }]: [number, { b?: [boolean, (bigint | string)[]]; t?: { a: number; b: { a: number; b: bigint; }; }; }], { r: [[r, z]] }: { r?: [[number, string]]; }) => void and number */ +/* @@@ label Error TypeError: operator + cannot be applied to types (p1: [number, { b?: [boolean, (bigint | string)[]]; t?: { a: number; b: { a: number; b: bigint; }; }; }], p2: { r?: [[number, string]]; }) => void and number */ diff --git a/ets2panda/test/ast/compiler/ts/objectLiteralAssignability20.ts b/ets2panda/test/ast/compiler/ts/objectLiteralAssignability20.ts index c3bf663f86..e43f77519c 100644 --- a/ets2panda/test/ast/compiler/ts/objectLiteralAssignability20.ts +++ b/ets2panda/test/ast/compiler/ts/objectLiteralAssignability20.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,4 +18,4 @@ var a: { new(a: number, b: string): number, (a: number, b: string): string }; var b: { new(a: number, b: string): number, (a: string, b: string): string } /* @@ label */a = b; -/* @@@ label Error TypeError: Type '{ (a: string, b: string): string; new (a: number, b: string): number; }' is not assignable to type '{ (a: number, b: string): string; new (a: number, b: string): number; }'. */ +/* @@@ label Error TypeError: Type '{ (p1: string, p2: string): string; new (p1: number, p2: string): number; }' is not assignable to type '{ (p1: number, p2: string): string; new (p1: number, p2: string): number; }'. */ diff --git a/ets2panda/test/ast/compiler/ts/varRedeclaration9.ts b/ets2panda/test/ast/compiler/ts/varRedeclaration9.ts index f513c5e59f..2601b4eae3 100644 --- a/ets2panda/test/ast/compiler/ts/varRedeclaration9.ts +++ b/ets2panda/test/ast/compiler/ts/varRedeclaration9.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,4 +16,4 @@ var a: (a: number, b?: number) => number; var /* @@ label */a: (a: number, b: number) => number; -/* @@@ label Error TypeError: Subsequent variable declaration must have the same type. Variable 'a' must be of type '(a: number, b?: number) => number', but here has type '(a: number, b: number) => number'. */ +/* @@@ label Error TypeError: Subsequent variable declaration must have the same type. Variable 'a' must be of type '(p1: number, p2?: number) => number', but here has type '(p1: number, p2: number) => number'. */ diff --git a/ets2panda/test/ast/parser/ets/TypeInferFunc.ets b/ets2panda/test/ast/parser/ets/TypeInferFunc.ets index 97f84e1e73..83cc64faeb 100644 --- a/ets2panda/test/ast/parser/ets/TypeInferFunc.ets +++ b/ets2panda/test/ast/parser/ets/TypeInferFunc.ets @@ -25,4 +25,4 @@ function main(): void { foo(bar); } -/* @@@ label Error TypeError: (...numbers: double[]) => void is not compatible with type T */ +/* @@@ label Error TypeError: (...p1: double[]) => void is not compatible with type T */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param06.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param06.ets index 785dbfea7e..34a1f1fdfa 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param06.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param06.ets @@ -21,5 +21,5 @@ class B{} /* @@@ label Error SyntaxError: Invalid value for annotation field, expected a constant literal. */ -/* @@? 20:23 Error TypeError: Type '(a: Int) => void' cannot be assigned to type 'String' */ +/* @@? 20:23 Error TypeError: Type '(p1: Int) => void' cannot be assigned to type 'String' */ /* @@? 20:23 Error TypeError: Invalid value for annotation field, expected a constant literal. */ diff --git a/ets2panda/test/ast/parser/ets/function_implicit_return_type3.ets b/ets2panda/test/ast/parser/ets/function_implicit_return_type3.ets index 615533dfc4..0d49c52c50 100644 --- a/ets2panda/test/ast/parser/ets/function_implicit_return_type3.ets +++ b/ets2panda/test/ast/parser/ets/function_implicit_return_type3.ets @@ -17,4 +17,4 @@ function void1(i: int) {} let fn: (i: int) => int = /* @@ label */void1; -/* @@@ label Error TypeError: Type '(i: Int) => void' cannot be assigned to type '(i: Int) => Int' */ +/* @@@ label Error TypeError: Type '(p1: Int) => void' cannot be assigned to type '(p1: Int) => Int' */ diff --git a/ets2panda/test/ast/parser/ets/lambda-type-inference-overloaded-1.ets b/ets2panda/test/ast/parser/ets/lambda-type-inference-overloaded-1.ets index be682f7d2f..59f291366d 100644 --- a/ets2panda/test/ast/parser/ets/lambda-type-inference-overloaded-1.ets +++ b/ets2panda/test/ast/parser/ets/lambda-type-inference-overloaded-1.ets @@ -36,4 +36,4 @@ function main(): void { /* @@@ label Error TypeError: Function foo with this assembly signature already declared. */ /* @@@ label1 Error TypeError: Type 'void' is not compatible with the enclosing method's return type 'Boolean' */ -/* @@? 28:9 Error TypeError: Type '(x: Double, y: String) => Boolean' is not compatible with type '(x: Int, y: String) => Boolean' at index 1 */ +/* @@? 28:9 Error TypeError: Type '(p1: Double, p2: String) => Boolean' is not compatible with type '(p1: Int, p2: String) => Boolean' at index 1 */ diff --git a/ets2panda/test/ast/parser/ets/lambda_optional_param_2.ets b/ets2panda/test/ast/parser/ets/lambda_optional_param_2.ets index 5e7f4e4636..240eb7c202 100644 --- a/ets2panda/test/ast/parser/ets/lambda_optional_param_2.ets +++ b/ets2panda/test/ast/parser/ets/lambda_optional_param_2.ets @@ -21,4 +21,4 @@ function main(): void { gf("abc" as String, /* @@ label */(x: String): Int => { return x=="TEST"?0:1}) } -/* @@@ label Error TypeError: Type '(x: String) => Int' is not compatible with type '(x: String|undefined) => Int' at index 2 */ +/* @@@ label Error TypeError: Type '(p1: String) => Int' is not compatible with type '(p1: String|undefined) => Int' at index 2 */ diff --git a/ets2panda/test/ast/parser/ets/lambda_optional_param_3.ets b/ets2panda/test/ast/parser/ets/lambda_optional_param_3.ets index 243d1920d6..98f67c9681 100644 --- a/ets2panda/test/ast/parser/ets/lambda_optional_param_3.ets +++ b/ets2panda/test/ast/parser/ets/lambda_optional_param_3.ets @@ -22,4 +22,4 @@ function main(): void { } /* @@@ label Error SyntaxError: Default value is allowed only for optional parameters. */ -/* @@? 21:24 Error TypeError: Type '(x: String) => Int' is not compatible with type '(x: String|undefined) => Int' at index 2 */ +/* @@? 21:24 Error TypeError: Type '(p1: String) => Int' is not compatible with type '(p1: String|undefined) => Int' at index 2 */ diff --git a/ets2panda/test/ast/parser/ets/this_type_lambda_definition_parameter_invalid.ets b/ets2panda/test/ast/parser/ets/this_type_lambda_definition_parameter_invalid.ets index 43749ac5f7..06872469f6 100644 --- a/ets2panda/test/ast/parser/ets/this_type_lambda_definition_parameter_invalid.ets +++ b/ets2panda/test/ast/parser/ets/this_type_lambda_definition_parameter_invalid.ets @@ -19,4 +19,4 @@ let x: (i: int, a: A) => number; x = (i: int, t: /* @@ label */this): number => { return 2.0; }; /* @@@ label Error SyntaxError: A 'this' type is available only as return type in a non-static method of a class or struct and extension functions. */ -/* @@? 19:5 Error TypeError: Type '(i: int, t: ETSGLOBAL) => double' cannot be assigned to type '(p1: Int, p2: A) => Double' */ +/* @@? 19:5 Error TypeError: Type '(p1: int, p2: ETSGLOBAL) => double' cannot be assigned to type '(p1: Int, p2: A) => Double' */ diff --git a/ets2panda/test/ast/parser/ets/this_type_lambda_definition_return_invalid.ets b/ets2panda/test/ast/parser/ets/this_type_lambda_definition_return_invalid.ets index b61df45287..0a3e1ee4c9 100644 --- a/ets2panda/test/ast/parser/ets/this_type_lambda_definition_return_invalid.ets +++ b/ets2panda/test/ast/parser/ets/this_type_lambda_definition_return_invalid.ets @@ -18,6 +18,6 @@ class A {} let x: (i: int, n: number) => A; x = (i: int, n: number): /* @@ label */this => { return new A(); }; -/* @@? 19:5 Error TypeError: Type '(i: int, n: double) => ETSGLOBAL' cannot be assigned to type '(p1: Int, p2: Double) => A' */ +/* @@? 19:5 Error TypeError: Type '(p1: int, p2: double) => ETSGLOBAL' cannot be assigned to type '(p1: Int, p2: Double) => A' */ /* @@@ label Error SyntaxError: A 'this' type is available only as return type in a non-static method of a class or struct and extension functions. */ /* @@? 19:50 Error TypeError: Only extension function or a class method can return 'this' */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_22.ets b/ets2panda/test/ast/parser/ets/unexpected_token_22.ets index 19b5147c4d..844628de89 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_22.ets +++ b/ets2panda/test/ast/parser/ets/unexpected_token_22.ets @@ -37,6 +37,6 @@ function main(): void { } /* @@? 25:43 Error SyntaxError: Unexpected token, expected '('. */ -/* @@? 25:43 Error TypeError: Type '(_: Promise) => Promise' cannot be assigned to type '() => Promise' */ +/* @@? 25:43 Error TypeError: Type '(p1: Promise) => Promise' cannot be assigned to type '() => Promise' */ /* @@? 25:44 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 25:60 Error SyntaxError: Unexpected token, expected ',' or ')'. */ diff --git a/ets2panda/test/ast/parser/ets/update_funcscope_error.ets b/ets2panda/test/ast/parser/ets/update_funcscope_error.ets index d9c34e105c..704622f81a 100644 --- a/ets2panda/test/ast/parser/ets/update_funcscope_error.ets +++ b/ets2panda/test/ast/parser/ets/update_funcscope_error.ets @@ -36,7 +36,7 @@ export const updateIfChanged = (t: Record) => { /* @@? 21:19 Error TypeError: Indexed access is not supported for such expression type. */ /* @@? 21:19 Error TypeError: Unresolved reference u */ -/* @@? 24:7 Error TypeError: Type '(v: Record) => Boolean' is not compatible with type '(previousValue: Boolean, currentValue: Boolean, index: Int, array: FixedArray) => Boolean' at index 2 */ +/* @@? 24:7 Error TypeError: Type '(p1: Record) => Boolean' is not compatible with type '(p1: Boolean, p2: Boolean, p3: Int, p4: FixedArray) => Boolean' at index 2 */ /* @@? 27:11 Error TypeError: Invalid record property */ /* @@? 28:11 Error SyntaxError: Unexpected token. */ /* @@? 28:12 Error SyntaxError: Unexpected token. */ diff --git a/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt b/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt index b320a8c7ac..b1566c2781 100644 --- a/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt +++ b/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt @@ -174,3 +174,6 @@ ast/parser/ts/test_decorator5.ts ast/parser/ts/InvalidStatements.ts ast/parser/ets/dynamic_import_tests/readonly_dynamic_class_interface.ets + +#29727 +ast/compiler/ets/first_match/override.ets diff --git a/ets2panda/test/unit/plugin/plugin_proceed_to_state_dump_decl_test.cpp b/ets2panda/test/unit/plugin/plugin_proceed_to_state_dump_decl_test.cpp index 834b799b5a..ae5c92e608 100644 --- a/ets2panda/test/unit/plugin/plugin_proceed_to_state_dump_decl_test.cpp +++ b/ets2panda/test/unit/plugin/plugin_proceed_to_state_dump_decl_test.cpp @@ -34,7 +34,7 @@ class A { } )"; -static std::string expected = R"(public prop: ((done: () => void) => void)|((done: () => void) => Promise); +static std::string expected = R"(public prop: ((p1: () => void) => void)|((p1: () => void) => Promise); )"; static es2panda_AstNode *prop = nullptr; -- Gitee