Commit 1d9d645
Enforce package rules on ::class expressions for strict-isolation packages
Summary:
# Context
`Foo::class` expressions do not produce package-boundary errors: under the
`package_allow_classconst_violations` migration carve-out they are downgraded to a
classptr lint (`ClassPtrLinterOnly`) so intern/prod separation V1 can roll out
without breaking `::class` callers. For a package that opts into strict isolation
(`enable_strict_isolation = true`), a `::class` reference from a package that does
not include it should be a hard violation, not just a lint.
# Solution
In the `class_expr` mode selector (the single site that classifies class-id
references), when the reference is a `::class` (`is_classptr`) and the target
class's package has strict isolation enabled, the boundary reason is upgraded from
`ClassPtrLinterOnly` to a hard `Yes Class` error (reusing cross-package error code
4472). The strict-isolation lookup happens only on the `::class` branch, so the
common class-reference path is unaffected. Non-strict targets keep the existing
classptr lint behavior.
# Tests
New verify tests under `test/package/strict_isolation/`: a `::class` reference to a
strict-isolation class from another package is a violation; the same reference
from within its own package is allowed.
Reviewed By: madgen
Differential Revision: D112642501
fbshipit-source-id: eccd94e20cc9358c14bb8256e6d068896e869a181 parent acdcb7f commit 1d9d645
5 files changed
Lines changed: 74 additions & 1 deletion
File tree
- hphp/hack
- src/typing
- test/package/strict_isolation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11965 | 11965 | | |
11966 | 11966 | | |
11967 | 11967 | | |
11968 | | - | |
| 11968 | + | |
| 11969 | + | |
| 11970 | + | |
| 11971 | + | |
| 11972 | + | |
| 11973 | + | |
| 11974 | + | |
| 11975 | + | |
| 11976 | + | |
| 11977 | + | |
| 11978 | + | |
11969 | 11979 | | |
11970 | 11980 | | |
11971 | 11981 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments