Handle interfaces consistently for IsTypeStruct and InstanceOf
commit61affb20440285f29df98f2810ec3885f0013db8
authorMichael O'Farrell <michaelofarrell@fb.com>
Wed, 24 Oct 2018 21:55:03 +0000 (24 14:55 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 24 Oct 2018 21:57:25 +0000 (24 14:57 -0700)
tree903ac0c0cb8138a09a933e8b1f68f5fd96f198a7
parent3c2d1a6f2d87d3516ae7db15f09dc8fa9b1a5142
Handle interfaces consistently for IsTypeStruct and InstanceOf

Summary:
Inconsistencies in how IsTypeStruct* and InstanceOf* handled
interfaces caused issues when IsTypeStruct* ops reduced to InstanceOf* ops.

Essentially the taken branch of InstanceOf IMyInterface would always propagate
IMyInterface as the type, while IsTypeStruct was always propagating the best
known type at the time.  These are likely going to be incompatible as
interfaces and objects that implement them are not required to be in the same
type hierarchy.

I attempted first to switch InstanceOf type propagation to use intersection_of,
but this causes other issues with interfaces.  intersection_of always returns
the non interface type.  This causes issues with something like this:
```
if ($t instanceOf IMyInterface)
```
If in an earlier analysis round we didn't have information about the type of $t
we would propagate IMyInterface, but in a later round we might learn that $t
is a MyClass object which might be incompatible.

This makes the handling of interfaces explicit, and consistend for the two.
It also fixes some mistakes in type refinements for IstTypeStruct.

Reviewed By: markw65

Differential Revision: D10557702

fbshipit-source-id: 9bc59639d258b207a2e813fb070004224a50b1c7
hphp/hhbbc/interp.cpp