diff --git a/es2panda/compiler/function/functionBuilder.cpp b/es2panda/compiler/function/functionBuilder.cpp index 824e6a03857cd8cd350240653932a34ba4e8ae2c..10a02a800b3de747a0f3db49519113eb465049b4 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 dde3633ac7f53ec851c03c4085caa21caa4d6d18..d465164715962b7597d262358adad592702137b1 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); } }