Permalink
Browse files

Fix AttrSystemInitialValue on overridden properties

Summary:
If its set on the parent prop, but not on the child, we need to
explicitly clear it on the child's property.

Reviewed By: ricklavoie

Differential Revision: D13084126

fbshipit-source-id: 3de06f6239f770efe60a3da582060c5fbab6d4dc
  • Loading branch information...
markw65 authored and hhvm-bot committed Nov 16, 2018
1 parent 4d57c97 commit c891e64b897f3d03d42e19da25708b46ba5b3e2d
@@ -2594,9 +2594,9 @@ void Class::setProperties() {
if (preProp->attrs() & AttrNoImplicitNullable) {
prop.attrs |= AttrNoImplicitNullable;
}
if (preProp->attrs() & AttrSystemInitialValue) {
prop.attrs |= AttrSystemInitialValue;
}
attrSetter(prop.attrs,
preProp->attrs() & AttrSystemInitialValue,
AttrSystemInitialValue);
if (preProp->attrs() & AttrInitialSatisfiesTC) {
prop.attrs |= AttrInitialSatisfiesTC;
}
@@ -2651,9 +2651,9 @@ void Class::setProperties() {
if (preProp->attrs() & AttrNoImplicitNullable) {
prop.attrs |= AttrNoImplicitNullable;
}
if (preProp->attrs() & AttrSystemInitialValue) {
prop.attrs |= AttrSystemInitialValue;
}
attrSetter(prop.attrs,
preProp->attrs() & AttrSystemInitialValue,
AttrSystemInitialValue);
if (preProp->attrs() & AttrInitialSatisfiesTC) {
prop.attrs |= AttrInitialSatisfiesTC;
}
@@ -0,0 +1,36 @@
<?hh
class Y {
const A = 'a';
}
class A {
public ImmMap $pub;
protected ImmMap $prot;
}
class X extends A {
public ImmMap $pub = ImmMap {
Y::A => 42,
};
protected ImmMap $prot = ImmMap {
Y::A => 24,
};
function getPub() { return $this->pub; }
function getProt() { return $this->prot; }
}
function test() {
return new X;
}
function main() {
for ($i = 1; $i < 100; $i++) {
test();
}
$x = test();
var_dump($x->getPub(), $x->getProt());
}
main();
@@ -0,0 +1,8 @@
object(HH\ImmMap)#202 (1) {
["a"]=>
int(42)
}
object(HH\ImmMap)#203 (1) {
["a"]=>
int(24)
}

0 comments on commit c891e64

Please sign in to comment.