Fix AttrNoOverride* on classes
commitb652d7a4c52e38694d95dca3d857779288ee471f
authorMark Williams <mwilliams@fb.com>
Tue, 25 Jun 2019 14:30:27 +0000 (25 07:30 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Tue, 25 Jun 2019 14:39:06 +0000 (25 07:39 -0700)
tree54c48a0dfcae1550afcb488ad1058510250b005b
parente1b0743e55c93a68db0d3cd83c8c80dceea0139e
Fix AttrNoOverride* on classes

Summary:
We weren't checking for uniqueness before setting the magic method
no-override flags, which could in theory result in setting them
incorrectly.

eg if there's a single class B which extends A, with two definitions
of A, and a class C which defines a magic getter, and extends B, but
which is incompatible with one of the As, we'll incorrectly set the
no-override bit on B because *one* possible instantiation of B can't
have a magic getter.

I couldn't come up with code that behaves incorrectly, but

  <?hh
  class A {};
  class B extends A {};
  class C extends B {
    const FOO = 42;
    public function __get($n) { echo "getting $n\n"; return 42; }
  }
  function f(B $b) {
    return $b->foo;
  }
  <<__EntryPoint>>
  function main() {
    if (false) {
      include "bug.inc";
    }
    var_dump(f(new C));
  }

with bug.inc:

  <?hh
  class A {
    const type FOO = int;
  };

Gets the wrong flags on B without this diff.

Reviewed By: ricklavoie, alexeyt

Differential Revision: D15966816

fbshipit-source-id: 4b4a94e7a5107213377849d9e8ae5d9d1f32105e
hphp/hhbbc/index.cpp