Rework enable_strict_const_semantics to consider the hierarchy in aggregate
Summary:
Enable_strict_const_semantics is now an int flag instead of a bool, but a bool is still accepted by .hhconfig
- `1` and `true` are equivalent, and they cause class `B1` defined below to raise an error
- `2` now raises an error for the definition of `B2`.
Adds an error when there is an inheritance conflict, which was previously missing in the case where the child overrides the constant.
Previously,
```
trait T1 {
const int X = 4;
}
trait T2 {
const int X = 5;
}
class A {
use T1;
}
class B1 /* error here */ extends A {
use T2;
}
```
```
T1
\
A T2
\ /
B1
```
This is an error on B1, but if we declared X locally, the error would disappear
```
// no errors
class B2 extends A {
const int X = 6;
use T2;
}
```
Both cases are fatals under HHVM flag.
Also, this check fires for all kinds of constants (class, type, ctx) because it does not exlude the backing TypeStructure constants, unlike the `check_const` call.
Facebook
~5k errors in www https://www.internalfb.com/intern/everpaste/?color=0&handle=GK10pBDe_jFp6hgQAOEB0BcVaMk6bjEQAAAz
Reviewed By: CatherineGasnier
Differential Revision:
D35886138
fbshipit-source-id:
49d2c6dfc38abf08e0a6ba55d1bc27300ab76fd6