Fix a bug in HHIR's emitParent

We actually grabbed the parent of the parent.  This means
things like parent::foo() were skipping the immediate parent.
Esse commit está contido em:
Jordan DeLong
2013-04-28 12:56:34 -07:00
commit de Sara Golemon
commit 8fb0544504
4 arquivos alterados com 39 adições e 6 exclusões
+4 -3
Ver Arquivo
@@ -4035,9 +4035,10 @@ void CodeGenerator::emitGetCtxFwdCallWithThis(PhysReg ctxReg,
}
/**
* This method is similar to emitGetCtxFwdCallWithThis above,
* but whether or not the callee is a static method is uknown at JIT time,
* and that is determined dynamically by looking up into the StaticMethodFCache.
* This method is similar to emitGetCtxFwdCallWithThis above, but
* whether or not the callee is a static method is unknown at JIT
* time, and that is determined dynamically by looking up into the
* StaticMethodFCache.
*/
void CodeGenerator::emitGetCtxFwdCallWithThisDyn(PhysReg destCtxReg,
PhysReg thisReg,
@@ -550,7 +550,7 @@ void HhbcTranslator::emitLateBoundCls() {
void HhbcTranslator::emitSelf() {
Class* clss = getCurClass();
if (clss == NULL) {
if (clss == nullptr) {
emitInterpOne(Type::Cls, 0);
} else {
push(m_tb->genDefConst(clss));
@@ -558,8 +558,8 @@ void HhbcTranslator::emitSelf() {
}
void HhbcTranslator::emitParent() {
const Class* clss = getCurClass()->parent();
if (clss == NULL || clss->parent() == NULL) {
auto const clss = getCurClass();
if (clss == nullptr || clss->parent() == nullptr) {
emitInterpOne(Type::Cls, 0);
} else {
push(m_tb->genDefConst(clss->parent()));
+31
Ver Arquivo
@@ -0,0 +1,31 @@
<?php
class B {
public static function bar() {
echo "B\n";
}
}
class D extends B {
public static function bar() {
echo "D\n";
}
}
trait Yeah {
public function foo() {
// Bug #2339698. Parent was skipping one.
parent::bar();
}
}
class C extends D {
use Yeah;
}
function foo() {
$k = new C();
$k->foo();
}
foo();
@@ -0,0 +1 @@
D