Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Pure Intersection types #6799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
941d55c
Start implementing intersection types
Girgias Mar 14, 2021
f9c78be
Gross intersection type in parameter types syntax ambiguity workaround
iluuu1994 Mar 18, 2021
2d30485
Fix variance when child is union and parent is intersection
Girgias Apr 23, 2021
062d557
Reorder execution and expand comment
Girgias Apr 24, 2021
49f53a9
Collapse branches together
Girgias Apr 24, 2021
f98f402
Fix Reflection test after rebase (Fiber)
Girgias May 4, 2021
0824c47
Fix after review
Girgias May 18, 2021
af47afc
Alias T_AMPERSAND
Girgias May 29, 2021
9e9de43
Revert "Alias T_AMPERSAND"
Girgias Jun 1, 2021
05723db
Fix an additional variance bug
Girgias Jun 1, 2021
7c4f70c
Address review
Girgias Jun 1, 2021
93ca487
Allow self and parent to be part of an intersection type
Girgias Jun 1, 2021
cff68c9
Support static type in intersection
Girgias Jun 2, 2021
b541b24
Revert "Support static type in intersection"
Girgias Jun 2, 2021
020b586
Revert "Allow self and parent to be part of an intersection type"
Girgias Jun 2, 2021
b0c7519
Move common code into always inlined functions
Girgias Jun 9, 2021
8ca34b3
Comment nits
Girgias Jun 9, 2021
b7c322e
Apply nit to reflection test
Girgias Jun 9, 2021
1bf0dd7
Adjust dfa pass
Girgias Jun 18, 2021
ac74551
Drop unnecessary try/catch
Girgias Jun 18, 2021
a0a1d90
Refactor zend_resolve_ce()
Girgias Jun 18, 2021
a96e956
Refactor zend_check_type_slow()
Girgias Jun 18, 2021
e334504
Comment and reorder the parser hack
Girgias Jun 18, 2021
a02eb62
Refactor check for self/parent
Girgias Jun 18, 2021
9508af7
Export common type checking code for JIT
Girgias Jun 18, 2021
5ae1d2a
Fix parse error message for "&"
nikic Jun 30, 2021
3cbab3b
Merge zend_is_single_type_subtype_intersection() function
nikic Jun 30, 2021
a47b77a
Rebase fixup
nikic Jun 30, 2021
c8b965a
Unify early exit status handling, add comments
nikic Jun 30, 2021
2070319
Adjust misleading comment
nikic Jun 30, 2021
2c6d155
Add failing test
nikic Jun 30, 2021
681f1c4
Handle object/iterable, fixup rebase
nikic Jul 1, 2021
1446dec
Handle intersection in can_elide_return_type_check()
nikic Jul 1, 2021
6166ed0
Code cleanup
nikic Jul 1, 2021
a6d28dc
Return status like in branch above
Girgias Jul 5, 2021
129f1ad
Add a variance test
Girgias Jul 5, 2021
ea33768
Don't load classes of an intersection if parent has object
Girgias Jul 5, 2021
8873527
Revert "Don't load classes of an intersection if parent has object"
Girgias Jul 5, 2021
891c59b
Add comment
Girgias Jul 5, 2021
799b0cb
[skip-ci] Add UPGRADING entry and fix comments
Girgias Jul 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Don't load classes of an intersection if parent has object"
This reverts commit ea33768.
  • Loading branch information
Girgias committed Jul 5, 2021
commit 8873527c457821143f4bd835e4dfc23e76f25c38
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class Test2 extends Test {

?>
===DONE===
--EXPECT--
===DONE===
--EXPECTF--
Fatal error: Could not check compatibility between Test2::method(): X&Y and Test::method(): object, because class X is not available in %s on line %d
29 changes: 11 additions & 18 deletions 29 Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,31 +606,24 @@ static inheritance_status zend_perform_covariant_type_check(
bool have_unresolved = false;

if (ZEND_TYPE_IS_INTERSECTION(fe_type)) {
/* As an intersection type can only be composed of class types (checked at compile stage),
* it is trivially covariant to the object type.
* Handle this case separately to ensure it never requires class loading. */
if (proto_type_mask & MAY_BE_OBJECT) {
return INHERITANCE_SUCCESS;
}

// TODO: Make "iterable" an alias of "array|Traversable" instead,
// so this special cases will be handled automatically.
if (proto_type_mask & MAY_BE_ITERABLE) {
if (proto_type_mask & (MAY_BE_OBJECT|MAY_BE_ITERABLE)) {
bool any_class = (proto_type_mask & MAY_BE_OBJECT) != 0;
ZEND_TYPE_FOREACH(fe_type, single_type) {
zend_class_entry *fe_ce;
zend_string *fe_class_name = get_class_from_type(&fe_ce, fe_scope, *single_type);

ZEND_ASSERT(fe_class_name);
if (!fe_class_name) {
continue;
}
if (!fe_ce) {
fe_ce = lookup_class(fe_scope, fe_class_name);
}
if (!fe_ce) {
if (fe_ce) {
if (any_class || unlinked_instanceof(fe_ce, zend_ce_traversable)) {
track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS;
}
} else {
have_unresolved = true;
continue;
}
if (unlinked_instanceof(fe_ce, zend_ce_traversable)) {
track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS;
}
} ZEND_TYPE_FOREACH_END();
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.