From cad8e914880b4745cc37d5a145df620ca3e53dea Mon Sep 17 00:00:00 2001 From: ctw-ian Date: Tue, 25 Apr 2023 19:49:19 +0800 Subject: [PATCH] Remove redundant ThrowIfsupernotcorrectcall insns Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I6YV4B Signed-off-by: ctw-ian Change-Id: I5bedcfe120f52b6d6100100d0d1e34063143a95d --- es2panda/compiler/function/functionBuilder.cpp | 13 +++++++++---- es2panda/ir/expressions/thisExpression.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/es2panda/compiler/function/functionBuilder.cpp b/es2panda/compiler/function/functionBuilder.cpp index 824e6a0385..10a02a800b 100644 --- a/es2panda/compiler/function/functionBuilder.cpp +++ b/es2panda/compiler/function/functionBuilder.cpp @@ -16,11 +16,12 @@ #include "functionBuilder.h" #include -#include -#include -#include #include #include +#include +#include +#include +#include namespace panda::es2panda::compiler { @@ -57,7 +58,11 @@ void FunctionBuilder::ImplicitReturn(const ir::AstNode *node) const } pg_->GetThis(rootNode); - pg_->ThrowIfSuperNotCorrectCall(rootNode, 0); + if (rootNode->AsScriptFunction()->IsConstructor() && + util::Helpers::GetClassDefiniton(rootNode->AsScriptFunction())->Super()) { + pg_->ThrowIfSuperNotCorrectCall(rootNode, 0); + } + pg_->NotifyConcurrentResult(node); pg_->EmitReturn(node); } diff --git a/es2panda/ir/expressions/thisExpression.cpp b/es2panda/ir/expressions/thisExpression.cpp index dde3633ac7..d465164715 100644 --- a/es2panda/ir/expressions/thisExpression.cpp +++ b/es2panda/ir/expressions/thisExpression.cpp @@ -15,11 +15,12 @@ #include "thisExpression.h" -#include #include #include -#include #include +#include +#include +#include namespace panda::es2panda::ir { @@ -42,8 +43,7 @@ void ThisExpression::Compile(compiler::PandaGen *pg) const } const ir::ScriptFunction *func = util::Helpers::GetContainingConstructor(this); - - if (func) { + if (func && util::Helpers::GetClassDefiniton(func)->Super()) { pg->ThrowIfSuperNotCorrectCall(this, 0); } } -- Gitee