Skip to content
Merged
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

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
Reorder execution and expand comment
  • Loading branch information
Girgias committed Jul 5, 2021
commit 062d557dd42f5cac439b6c42f2369775c71cb963
21 changes: 10 additions & 11 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,11 @@ static inheritance_status zend_perform_covariant_type_check(
zend_type *single_type;
bool all_success = true;

/* For intersection types loop over the parent types first as a child
* can add them */
if (ZEND_TYPE_IS_INTERSECTION(fe_type)
|| (ZEND_TYPE_IS_INTERSECTION(proto_type) && !ZEND_TYPE_IS_UNION(fe_type))
) {
/* If the child type is an intersection type then we need to loop over
* the parents firstFor intersection types loop over the parent types first
* as the child can add types, however none of them can be a supertype of
* a parent type. */
if (ZEND_TYPE_IS_INTERSECTION(fe_type)) {
/* First try to check whether we can succeed without resolving anything */
ZEND_TYPE_FOREACH(proto_type, single_type) {
inheritance_status status;
Expand Down Expand Up @@ -657,13 +657,12 @@ static inheritance_status zend_perform_covariant_type_check(
all_success = false;
}
} ZEND_TYPE_FOREACH_END();
} else if (ZEND_TYPE_IS_INTERSECTION(proto_type) && ZEND_TYPE_IS_UNION(fe_type)) {
/* Here each member of the child union must be a subtype of the intersection */
} else if (ZEND_TYPE_IS_INTERSECTION(proto_type)) {
/* Here each member of the child union must be a subtype of the intersection
* Note: the union can be a single element */

/* First try to check whether we can succeed without resolving anything */
zend_type_list *child_union_types = ZEND_TYPE_LIST(fe_type);

ZEND_TYPE_LIST_FOREACH(child_union_types, single_type) {
ZEND_TYPE_FOREACH(fe_type, single_type) {
inheritance_status status;
zend_string *fe_class_name;
zend_class_entry *fe_ce = NULL;
Expand All @@ -689,7 +688,7 @@ static inheritance_status zend_perform_covariant_type_check(
if (status != INHERITANCE_SUCCESS) {
all_success = false;
}
} ZEND_TYPE_LIST_FOREACH_END();
} ZEND_TYPE_FOREACH_END();
}
/* Only union or single types both in parent and child */
else {
Expand Down