Commit 206760e
Remove class-loading check for overriding type constants
Summary:
This fatals, but hh is fine with it
```
interface I1 {
abstract const type T = nothing;
}
interface I2 extends I1 {
const type T = mixed;
}
```
I went digging and discovered that HHVM doesn't understand that the type const in I1 is abstract. In fact the abstract keyword doesn't result in any emission differences.
This is the rust structure:
```
pub struct HhasTypeConstant {
pub name: String,
pub initializer: Option<TypedValue>,
}
```
It's just "Is there a value? no -> abstract, else -> non-abstract"
Then in the class loading code we have this:
```
// Forbid redefining constants from interfaces, but not superclasses.
// Constants from interfaces implemented by superclasses can be
// overridden.
```
This is super weird IMO. At the very least we need to not fatal on this case (it has direct applications for coeffects). In the best case, we'd probably have HHVM understand the notion of abstract w/ default.
As I see it there are basically 2 options:
1. delete the check (for type constants). It seems weird enough as it is that it's the only restrictions on redefinitions. Then again, that results in HHVM not having any confirmation that the hierarchy is reasonable, but we don't enforce them anyway, so that might be OK?
2. do a bunch of work to redo how HHVM sees type constants and potentially add more checks.
I'm going to do the first here as a short term solution and then we can discuss the latter in more detail.
Reviewed By: paulbiss
Differential Revision: D26076753
fbshipit-source-id: 6aedfc10d4ab31fc61782adbadd09203aa8b9cc81 parent 534d890 commit 206760e
4 files changed
Lines changed: 16 additions & 8 deletions
File tree
- hphp
- hhbbc
- runtime/vm
- test/slow/class_type_constant
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1544 | 1544 | | |
1545 | 1545 | | |
1546 | 1546 | | |
1547 | | - | |
| 1547 | + | |
1548 | 1548 | | |
1549 | 1549 | | |
1550 | 1550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2299 | 2299 | | |
2300 | 2300 | | |
2301 | 2301 | | |
2302 | | - | |
2303 | | - | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
2304 | 2306 | | |
2305 | 2307 | | |
2306 | | - | |
2307 | | - | |
2308 | | - | |
| 2308 | + | |
| 2309 | + | |
2309 | 2310 | | |
2310 | | - | |
2311 | 2311 | | |
2312 | 2312 | | |
2313 | 2313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
| 19 | + | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments