13af6ab5fSopenharmony_ci/*
23af6ab5fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License.
53af6ab5fSopenharmony_ci * You may obtain a copy of the License at
63af6ab5fSopenharmony_ci *
73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
83af6ab5fSopenharmony_ci *
93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and
133af6ab5fSopenharmony_ci * limitations under the License.
143af6ab5fSopenharmony_ci */
153af6ab5fSopenharmony_ci
163af6ab5fSopenharmony_ci#include "helpers.h"
173af6ab5fSopenharmony_ci
183af6ab5fSopenharmony_ci#include "checker/types/typeFlag.h"
193af6ab5fSopenharmony_ci#include "checker/types/type.h"
203af6ab5fSopenharmony_ci#include "checker/types/ets/etsObjectType.h"
213af6ab5fSopenharmony_ci#include "ir/statements/blockStatement.h"
223af6ab5fSopenharmony_ci#include "ir/ets/etsScript.h"
233af6ab5fSopenharmony_ci#include "parser/program/program.h"
243af6ab5fSopenharmony_ci#include "ir/expressions/memberExpression.h"
253af6ab5fSopenharmony_ci#include "ir/expressions/callExpression.h"
263af6ab5fSopenharmony_ci
273af6ab5fSopenharmony_cinamespace ark::es2panda::compiler::ast_verifier {
283af6ab5fSopenharmony_ci
293af6ab5fSopenharmony_cibool IsImportLike(const ir::AstNode *ast)
303af6ab5fSopenharmony_ci{
313af6ab5fSopenharmony_ci    return (ast->IsETSImportDeclaration() || ast->IsETSReExportDeclaration() || ast->IsImportExpression() ||
323af6ab5fSopenharmony_ci            ast->IsImportSpecifier() || ast->IsImportDefaultSpecifier() || ast->IsImportNamespaceSpecifier());
333af6ab5fSopenharmony_ci}
343af6ab5fSopenharmony_ci
353af6ab5fSopenharmony_cibool IsExportLike(const ir::AstNode *ast)
363af6ab5fSopenharmony_ci{
373af6ab5fSopenharmony_ci    return (ast->IsExportDefaultDeclaration() || ast->IsExportSpecifier() || ast->IsExportAllDeclaration() ||
383af6ab5fSopenharmony_ci            ast->IsExportNamedDeclaration() || ast->IsETSReExportDeclaration());
393af6ab5fSopenharmony_ci}
403af6ab5fSopenharmony_ci
413af6ab5fSopenharmony_cibool IsBooleanType(const ir::AstNode *ast)
423af6ab5fSopenharmony_ci{
433af6ab5fSopenharmony_ci    if (ast == nullptr) {
443af6ab5fSopenharmony_ci        return false;
453af6ab5fSopenharmony_ci    }
463af6ab5fSopenharmony_ci
473af6ab5fSopenharmony_ci    if (!ast->IsTyped()) {
483af6ab5fSopenharmony_ci        return false;
493af6ab5fSopenharmony_ci    }
503af6ab5fSopenharmony_ci
513af6ab5fSopenharmony_ci    auto typedAst = static_cast<const ir::TypedAstNode *>(ast);
523af6ab5fSopenharmony_ci
533af6ab5fSopenharmony_ci    if (typedAst->TsType() == nullptr) {
543af6ab5fSopenharmony_ci        return false;
553af6ab5fSopenharmony_ci    }
563af6ab5fSopenharmony_ci
573af6ab5fSopenharmony_ci    if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) &&
583af6ab5fSopenharmony_ci        ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) {
593af6ab5fSopenharmony_ci        return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN);
603af6ab5fSopenharmony_ci    }
613af6ab5fSopenharmony_ci
623af6ab5fSopenharmony_ci    return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) ||
633af6ab5fSopenharmony_ci           typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BOOLEAN_LIKE);
643af6ab5fSopenharmony_ci}
653af6ab5fSopenharmony_ci
663af6ab5fSopenharmony_cibool IsValidTypeForBinaryOp(const ir::AstNode *ast, bool isBitwise)
673af6ab5fSopenharmony_ci{
683af6ab5fSopenharmony_ci    if (ast == nullptr) {
693af6ab5fSopenharmony_ci        std::cout << __LINE__ << std::endl;
703af6ab5fSopenharmony_ci        return false;
713af6ab5fSopenharmony_ci    }
723af6ab5fSopenharmony_ci
733af6ab5fSopenharmony_ci    if (!ast->IsTyped()) {
743af6ab5fSopenharmony_ci        std::cout << __LINE__ << std::endl;
753af6ab5fSopenharmony_ci        return false;
763af6ab5fSopenharmony_ci    }
773af6ab5fSopenharmony_ci
783af6ab5fSopenharmony_ci    auto typedAst = static_cast<const ir::TypedAstNode *>(ast);
793af6ab5fSopenharmony_ci
803af6ab5fSopenharmony_ci    if (typedAst->TsType() == nullptr) {
813af6ab5fSopenharmony_ci        // std::cout << typedAst
823af6ab5fSopenharmony_ci        std::cout << __LINE__ << std::endl;
833af6ab5fSopenharmony_ci        return false;
843af6ab5fSopenharmony_ci    }
853af6ab5fSopenharmony_ci
863af6ab5fSopenharmony_ci    if (IsBooleanType(ast)) {
873af6ab5fSopenharmony_ci        return isBitwise;
883af6ab5fSopenharmony_ci    }
893af6ab5fSopenharmony_ci
903af6ab5fSopenharmony_ci    if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) &&
913af6ab5fSopenharmony_ci        typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BIGINT)) {
923af6ab5fSopenharmony_ci        return true;
933af6ab5fSopenharmony_ci    }
943af6ab5fSopenharmony_ci
953af6ab5fSopenharmony_ci    if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) &&
963af6ab5fSopenharmony_ci        ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) {
973af6ab5fSopenharmony_ci        return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE) &&
983af6ab5fSopenharmony_ci               !typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN);
993af6ab5fSopenharmony_ci    }
1003af6ab5fSopenharmony_ci
1013af6ab5fSopenharmony_ci    return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) ||
1023af6ab5fSopenharmony_ci           typedAst->TsType()->HasTypeFlag(checker::TypeFlag::NUMBER_LITERAL) ||
1033af6ab5fSopenharmony_ci           typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT) ||
1043af6ab5fSopenharmony_ci           typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT_LITERAL);
1053af6ab5fSopenharmony_ci}
1063af6ab5fSopenharmony_ci
1073af6ab5fSopenharmony_cibool IsStringType(const ir::AstNode *ast)
1083af6ab5fSopenharmony_ci{
1093af6ab5fSopenharmony_ci    if (ast == nullptr) {
1103af6ab5fSopenharmony_ci        return false;
1113af6ab5fSopenharmony_ci    }
1123af6ab5fSopenharmony_ci
1133af6ab5fSopenharmony_ci    if (!ast->IsTyped()) {
1143af6ab5fSopenharmony_ci        return false;
1153af6ab5fSopenharmony_ci    }
1163af6ab5fSopenharmony_ci
1173af6ab5fSopenharmony_ci    auto typedAst = static_cast<const ir::TypedAstNode *>(ast);
1183af6ab5fSopenharmony_ci
1193af6ab5fSopenharmony_ci    if (typedAst->TsType() == nullptr) {
1203af6ab5fSopenharmony_ci        return false;
1213af6ab5fSopenharmony_ci    }
1223af6ab5fSopenharmony_ci
1233af6ab5fSopenharmony_ci    if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) {
1243af6ab5fSopenharmony_ci        return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::STRING) ||
1253af6ab5fSopenharmony_ci               typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_STRING);
1263af6ab5fSopenharmony_ci    }
1273af6ab5fSopenharmony_ci
1283af6ab5fSopenharmony_ci    return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::STRING_LIKE);
1293af6ab5fSopenharmony_ci}
1303af6ab5fSopenharmony_ci
1313af6ab5fSopenharmony_cibool IsVisibleInternalNode(const ir::AstNode *ast, const ir::AstNode *objTypeDeclNode)
1323af6ab5fSopenharmony_ci{
1333af6ab5fSopenharmony_ci    // NOTE(orlovskymaxim) This relies on the fact, that GetTopStatement has no bugs, that is not the case for now
1343af6ab5fSopenharmony_ci    if (!ast->GetTopStatement()->IsETSScript()) {
1353af6ab5fSopenharmony_ci        return false;
1363af6ab5fSopenharmony_ci    }
1373af6ab5fSopenharmony_ci    auto *currentTopStatement = (static_cast<const ir::ETSScript *>(ast->GetTopStatement()));
1383af6ab5fSopenharmony_ci    auto *currentProgram = currentTopStatement->Program();
1393af6ab5fSopenharmony_ci    if (currentProgram == nullptr) {
1403af6ab5fSopenharmony_ci        return false;
1413af6ab5fSopenharmony_ci    }
1423af6ab5fSopenharmony_ci    util::StringView moduleNameCurrent = currentProgram->ModuleName();
1433af6ab5fSopenharmony_ci    // NOTE(orlovskymaxim) This relies on the fact, that GetTopStatement has no bugs, that is not the case for now
1443af6ab5fSopenharmony_ci    if (!objTypeDeclNode->GetTopStatement()->IsETSScript()) {
1453af6ab5fSopenharmony_ci        return false;
1463af6ab5fSopenharmony_ci    }
1473af6ab5fSopenharmony_ci    auto *objectTopStatement = (static_cast<const ir::ETSScript *>(objTypeDeclNode->GetTopStatement()));
1483af6ab5fSopenharmony_ci    auto *objectProgram = objectTopStatement->Program();
1493af6ab5fSopenharmony_ci    if (objectProgram == nullptr) {
1503af6ab5fSopenharmony_ci        return false;
1513af6ab5fSopenharmony_ci    }
1523af6ab5fSopenharmony_ci    util::StringView moduleNameObject = objectProgram->ModuleName();
1533af6ab5fSopenharmony_ci    return currentTopStatement == objectTopStatement || moduleNameCurrent == moduleNameObject;
1543af6ab5fSopenharmony_ci}
1553af6ab5fSopenharmony_ci
1563af6ab5fSopenharmony_ciconst checker::Type *GetClassDefinitionType(const ir::AstNode *ast)
1573af6ab5fSopenharmony_ci{
1583af6ab5fSopenharmony_ci    const ir::AstNode *tmpNode = ast;
1593af6ab5fSopenharmony_ci    while (tmpNode->Parent() != nullptr && !tmpNode->IsClassDefinition()) {
1603af6ab5fSopenharmony_ci        tmpNode = tmpNode->Parent();
1613af6ab5fSopenharmony_ci    }
1623af6ab5fSopenharmony_ci    if (!tmpNode->IsClassDefinition()) {
1633af6ab5fSopenharmony_ci        return nullptr;
1643af6ab5fSopenharmony_ci    }
1653af6ab5fSopenharmony_ci    auto *classDefinition = tmpNode->AsClassDefinition();
1663af6ab5fSopenharmony_ci    return classDefinition->TsType();
1673af6ab5fSopenharmony_ci}
1683af6ab5fSopenharmony_ci
1693af6ab5fSopenharmony_ciconst checker::Type *GetTSInterfaceDeclarationType(const ir::AstNode *ast)
1703af6ab5fSopenharmony_ci{
1713af6ab5fSopenharmony_ci    const ir::AstNode *tmpNode = ast;
1723af6ab5fSopenharmony_ci    while (tmpNode->Parent() != nullptr && !tmpNode->IsTSInterfaceDeclaration()) {
1733af6ab5fSopenharmony_ci        tmpNode = tmpNode->Parent();
1743af6ab5fSopenharmony_ci    }
1753af6ab5fSopenharmony_ci    if (!tmpNode->IsTSInterfaceDeclaration()) {
1763af6ab5fSopenharmony_ci        return nullptr;
1773af6ab5fSopenharmony_ci    }
1783af6ab5fSopenharmony_ci    auto *tsInterfaceDeclaration = tmpNode->AsTSInterfaceDeclaration();
1793af6ab5fSopenharmony_ci    return tsInterfaceDeclaration->TsType();
1803af6ab5fSopenharmony_ci}
1813af6ab5fSopenharmony_ci
1823af6ab5fSopenharmony_cibool ValidateMethodAccessForClass(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode,
1833af6ab5fSopenharmony_ci                                  checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode)
1843af6ab5fSopenharmony_ci{
1853af6ab5fSopenharmony_ci    // Check if the method is used where it is declared
1863af6ab5fSopenharmony_ci    if (IsContainedIn<const ir::AstNode>(ast, ownerSignDeclNode)) {
1873af6ab5fSopenharmony_ci        return true;
1883af6ab5fSopenharmony_ci    }
1893af6ab5fSopenharmony_ci    if (signature->HasSignatureFlag(checker::SignatureFlags::PRIVATE)) {
1903af6ab5fSopenharmony_ci        return false;
1913af6ab5fSopenharmony_ci    }
1923af6ab5fSopenharmony_ci    if (signature->HasSignatureFlag(checker::SignatureFlags::PROTECTED)) {
1933af6ab5fSopenharmony_ci        // Check if the method is inherited and is used in class in which it is inherited
1943af6ab5fSopenharmony_ci        auto *classDefinitionType = GetClassDefinitionType(ast);
1953af6ab5fSopenharmony_ci        if (classDefinitionType == nullptr || !classDefinitionType->IsETSObjectType()) {
1963af6ab5fSopenharmony_ci            return false;
1973af6ab5fSopenharmony_ci        }
1983af6ab5fSopenharmony_ci        auto *classObjectType = classDefinitionType->AsETSObjectType();
1993af6ab5fSopenharmony_ci        return classObjectType->IsDescendantOf(signature->Owner());
2003af6ab5fSopenharmony_ci    }
2013af6ab5fSopenharmony_ci    if (signature->HasSignatureFlag(checker::SignatureFlags::INTERNAL)) {
2023af6ab5fSopenharmony_ci        return IsVisibleInternalNode(ast, memberObjTypeDeclNode);
2033af6ab5fSopenharmony_ci    }
2043af6ab5fSopenharmony_ci    return true;
2053af6ab5fSopenharmony_ci}
2063af6ab5fSopenharmony_ci
2073af6ab5fSopenharmony_cibool ValidateMethodAccessForTSInterface(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode,
2083af6ab5fSopenharmony_ci                                        checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode)
2093af6ab5fSopenharmony_ci{
2103af6ab5fSopenharmony_ci    // Check if the method is used where it is declared
2113af6ab5fSopenharmony_ci    if (IsContainedIn<const ir::AstNode>(ast, ownerSignDeclNode)) {
2123af6ab5fSopenharmony_ci        return true;
2133af6ab5fSopenharmony_ci    }
2143af6ab5fSopenharmony_ci    if (signature->HasSignatureFlag(checker::SignatureFlags::PRIVATE)) {
2153af6ab5fSopenharmony_ci        return false;
2163af6ab5fSopenharmony_ci    }
2173af6ab5fSopenharmony_ci    if (signature->HasSignatureFlag(checker::SignatureFlags::PROTECTED)) {
2183af6ab5fSopenharmony_ci        // Check if the method is inherited and is used in class in which it is inherited
2193af6ab5fSopenharmony_ci        auto *tsInterfaceDeclarationType = GetTSInterfaceDeclarationType(ast);
2203af6ab5fSopenharmony_ci        if (tsInterfaceDeclarationType == nullptr || !tsInterfaceDeclarationType->IsETSObjectType()) {
2213af6ab5fSopenharmony_ci            return false;
2223af6ab5fSopenharmony_ci        }
2233af6ab5fSopenharmony_ci        auto *tsInterfaceObjectType = tsInterfaceDeclarationType->AsETSObjectType();
2243af6ab5fSopenharmony_ci        return tsInterfaceObjectType->IsDescendantOf(signature->Owner());
2253af6ab5fSopenharmony_ci    }
2263af6ab5fSopenharmony_ci    if (signature->HasSignatureFlag(checker::SignatureFlags::INTERNAL)) {
2273af6ab5fSopenharmony_ci        return IsVisibleInternalNode(ast, memberObjTypeDeclNode);
2283af6ab5fSopenharmony_ci    }
2293af6ab5fSopenharmony_ci    return true;
2303af6ab5fSopenharmony_ci}
2313af6ab5fSopenharmony_ci
2323af6ab5fSopenharmony_cibool ValidatePropertyAccessForClass(const ir::AstNode *ast, const ir::AstNode *propVarDeclNode,
2333af6ab5fSopenharmony_ci                                    const ir::AstNode *propVarDeclNodeParent, const varbinder::LocalVariable *propVar,
2343af6ab5fSopenharmony_ci                                    const ir::AstNode *objTypeDeclNode)
2353af6ab5fSopenharmony_ci{
2363af6ab5fSopenharmony_ci    // Check if the variable is used where it is declared
2373af6ab5fSopenharmony_ci    if (IsContainedIn<const ir::AstNode>(ast, propVarDeclNodeParent)) {
2383af6ab5fSopenharmony_ci        return true;
2393af6ab5fSopenharmony_ci    }
2403af6ab5fSopenharmony_ci    if (propVarDeclNode->IsPrivate()) {
2413af6ab5fSopenharmony_ci        return false;
2423af6ab5fSopenharmony_ci    }
2433af6ab5fSopenharmony_ci    if (propVarDeclNode->IsProtected()) {
2443af6ab5fSopenharmony_ci        auto *classDefinitionType = GetClassDefinitionType(ast);
2453af6ab5fSopenharmony_ci        if (classDefinitionType == nullptr || !classDefinitionType->IsETSObjectType()) {
2463af6ab5fSopenharmony_ci            return false;
2473af6ab5fSopenharmony_ci        }
2483af6ab5fSopenharmony_ci        auto *classObjectType = classDefinitionType->AsETSObjectType();
2493af6ab5fSopenharmony_ci        return classObjectType->IsPropertyOfAscendant(propVar);
2503af6ab5fSopenharmony_ci    }
2513af6ab5fSopenharmony_ci    if (propVarDeclNode->IsInternal()) {
2523af6ab5fSopenharmony_ci        return IsVisibleInternalNode(ast, objTypeDeclNode);
2533af6ab5fSopenharmony_ci    }
2543af6ab5fSopenharmony_ci    return true;
2553af6ab5fSopenharmony_ci}
2563af6ab5fSopenharmony_ci
2573af6ab5fSopenharmony_cibool ValidateVariableAccess(const varbinder::LocalVariable *propVar, const ir::MemberExpression *ast)
2583af6ab5fSopenharmony_ci{
2593af6ab5fSopenharmony_ci    const auto *propVarDecl = propVar->Declaration();
2603af6ab5fSopenharmony_ci    if (propVarDecl == nullptr) {
2613af6ab5fSopenharmony_ci        return false;
2623af6ab5fSopenharmony_ci    }
2633af6ab5fSopenharmony_ci    const auto *propVarDeclNode = propVarDecl->Node();
2643af6ab5fSopenharmony_ci    if (propVarDeclNode == nullptr) {
2653af6ab5fSopenharmony_ci        return false;
2663af6ab5fSopenharmony_ci    }
2673af6ab5fSopenharmony_ci    auto *objType = ast->ObjType();
2683af6ab5fSopenharmony_ci    if (objType == nullptr) {
2693af6ab5fSopenharmony_ci        return false;
2703af6ab5fSopenharmony_ci    }
2713af6ab5fSopenharmony_ci    const auto *objTypeDeclNode = objType->GetDeclNode();
2723af6ab5fSopenharmony_ci    if (objTypeDeclNode == nullptr) {
2733af6ab5fSopenharmony_ci        return false;
2743af6ab5fSopenharmony_ci    }
2753af6ab5fSopenharmony_ci    if (objTypeDeclNode->Parent() != nullptr && objTypeDeclNode->Parent()->IsImportNamespaceSpecifier()) {
2763af6ab5fSopenharmony_ci        return true;
2773af6ab5fSopenharmony_ci    }
2783af6ab5fSopenharmony_ci    const auto *propVarDeclNodeParent = propVarDeclNode->Parent();
2793af6ab5fSopenharmony_ci    if (propVarDeclNodeParent == nullptr) {
2803af6ab5fSopenharmony_ci        return false;
2813af6ab5fSopenharmony_ci    }
2823af6ab5fSopenharmony_ci    if (propVarDeclNodeParent->IsClassDefinition() && objTypeDeclNode->IsClassDefinition()) {
2833af6ab5fSopenharmony_ci        return ValidatePropertyAccessForClass(ast, propVarDeclNode, propVarDeclNodeParent, propVar, objTypeDeclNode);
2843af6ab5fSopenharmony_ci    }
2853af6ab5fSopenharmony_ci    return false;
2863af6ab5fSopenharmony_ci}
2873af6ab5fSopenharmony_ci
2883af6ab5fSopenharmony_cibool ValidateMethodAccess(const ir::MemberExpression *memberExpression, const ir::CallExpression *ast)
2893af6ab5fSopenharmony_ci{
2903af6ab5fSopenharmony_ci    auto *memberObjType = memberExpression->ObjType();
2913af6ab5fSopenharmony_ci    if (memberObjType == nullptr) {
2923af6ab5fSopenharmony_ci        return false;
2933af6ab5fSopenharmony_ci    }
2943af6ab5fSopenharmony_ci    if (memberObjType->HasObjectFlag(checker::ETSObjectFlags::RESOLVED_SUPER) &&
2953af6ab5fSopenharmony_ci        memberObjType->SuperType() != nullptr &&
2963af6ab5fSopenharmony_ci        memberObjType->SuperType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE |
2973af6ab5fSopenharmony_ci                                                  checker::ETSObjectFlags::GLOBAL)) {
2983af6ab5fSopenharmony_ci        return true;
2993af6ab5fSopenharmony_ci    }
3003af6ab5fSopenharmony_ci    const auto *memberObjTypeDeclNode = memberObjType->GetDeclNode();
3013af6ab5fSopenharmony_ci    if (memberObjTypeDeclNode == nullptr) {
3023af6ab5fSopenharmony_ci        return false;
3033af6ab5fSopenharmony_ci    }
3043af6ab5fSopenharmony_ci    if (memberObjTypeDeclNode->Parent() != nullptr && memberObjTypeDeclNode->Parent()->IsImportNamespaceSpecifier()) {
3053af6ab5fSopenharmony_ci        return true;
3063af6ab5fSopenharmony_ci    }
3073af6ab5fSopenharmony_ci    auto *signature = ast->Signature();
3083af6ab5fSopenharmony_ci    if (signature == nullptr) {
3093af6ab5fSopenharmony_ci        return false;
3103af6ab5fSopenharmony_ci    }
3113af6ab5fSopenharmony_ci    auto *ownerSign = signature->Owner();
3123af6ab5fSopenharmony_ci    if (ownerSign == nullptr) {
3133af6ab5fSopenharmony_ci        return false;
3143af6ab5fSopenharmony_ci    }
3153af6ab5fSopenharmony_ci    auto *ownerSignDeclNode = ownerSign->GetDeclNode();
3163af6ab5fSopenharmony_ci    if (ownerSignDeclNode == nullptr) {
3173af6ab5fSopenharmony_ci        return false;
3183af6ab5fSopenharmony_ci    }
3193af6ab5fSopenharmony_ci    if (!ownerSignDeclNode->IsClassDefinition() && !ownerSignDeclNode->IsTSInterfaceDeclaration()) {
3203af6ab5fSopenharmony_ci        return false;
3213af6ab5fSopenharmony_ci    }
3223af6ab5fSopenharmony_ci    bool ret = false;
3233af6ab5fSopenharmony_ci    if (memberObjTypeDeclNode->IsClassDefinition()) {
3243af6ab5fSopenharmony_ci        ret = ValidateMethodAccessForClass(ast, ownerSignDeclNode, signature, memberObjTypeDeclNode);
3253af6ab5fSopenharmony_ci    } else if (memberObjTypeDeclNode->IsTSInterfaceDeclaration()) {
3263af6ab5fSopenharmony_ci        ret = ValidateMethodAccessForTSInterface(ast, ownerSignDeclNode, signature, memberObjTypeDeclNode);
3273af6ab5fSopenharmony_ci    }
3283af6ab5fSopenharmony_ci    return ret;
3293af6ab5fSopenharmony_ci}
3303af6ab5fSopenharmony_ci
3313af6ab5fSopenharmony_ci}  // namespace ark::es2panda::compiler::ast_verifier
332