From 431b4750adecc6b8830bf7ea5e3cbba18d05d024 Mon Sep 17 00:00:00 2001 From: xuxinjie4 Date: Wed, 16 Jul 2025 11:47:29 +0800 Subject: [PATCH] Fix lambda bug Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICMK8W?from=project-issue Signed-off-by: xuxinjie4 --- ets2panda/checker/ETSAnalyzer.cpp | 4 +--- ets2panda/compiler/lowering/ets/lambdaLowering.cpp | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index fb821fb4234..59bd40ad218 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1796,9 +1796,7 @@ checker::Type *ETSAnalyzer::Check(ir::ConditionalExpression *expr) const static Type *TransformTypeForMethodReference(ETSChecker *checker, ir::Expression *const use, Type *type) { ES2PANDA_ASSERT(use->IsIdentifier() || use->IsMemberExpression()); - if (!type->IsETSMethodType() || - (use->IsMemberExpression() && use->AsMemberExpression()->PropVar() != nullptr && - use->AsMemberExpression()->PropVar()->HasFlag(varbinder::VariableFlags::DYNAMIC))) { + if (!type->IsETSMethodType()) { return type; } auto const getUseSite = [use]() { diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index f621292487d..3533aac4ae8 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -1311,14 +1311,15 @@ static ir::AstNode *BuildLambdaClassWhenNeeded(public_lib::Context *ctx, ir::Ast // so it is correct to pass ETS extension here to isReference() if (id->IsReference(ScriptExtension::ETS) && id->TsType() != nullptr && id->TsType()->IsETSFunctionType() && !IsInCalleePosition(id) && !IsEnumFunctionCall(id) && IsValidFunctionDeclVar(var) && - !id->Variable()->HasFlag(varbinder::VariableFlags::DYNAMIC) && !IsOverloadedName(id)) { + !IsOverloadedName(id)) { return ConvertFunctionReference(ctx, id); } } if (node->IsMemberExpression()) { auto *mexpr = node->AsMemberExpression(); if (mexpr->Kind() == ir::MemberExpressionKind::PROPERTY_ACCESS && mexpr->TsType() != nullptr && - mexpr->TsType()->IsETSFunctionType() && mexpr->Object()->TsType()->IsETSObjectType()) { + 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(), -- Gitee