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

Sign up
Appearance settings

Commit 2e48282

Browse files
committed
W.I.P. variance checks for associated types
1 parent 766bdfc commit 2e48282

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎Zend/zend_inheritance.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,22 @@ static inheritance_status zend_is_intersection_subtype_of_type(
675675
return early_exit_status == INHERITANCE_ERROR ? INHERITANCE_SUCCESS : INHERITANCE_ERROR;
676676
}
677677

678+
static inheritance_status zend_is_type_subtype_of_associated_type(
679+
zend_class_entry *concrete_scope,
680+
const zend_type *concrete_type_ptr,
681+
const zend_type *associated_type_ptr,
682+
HashTable *associated_types
683+
) {
684+
const zend_type associated_type = *associated_type_ptr;
685+
const zend_type concrete_type = *concrete_type_ptr;
686+
687+
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(associated_type));
688+
689+
zend_string *associated_type_name = ZEND_TYPE_NAME(associated_type);
690+
691+
return INHERITANCE_ERROR;
692+
}
693+
678694
ZEND_API inheritance_status zend_perform_covariant_type_check(
679695
zend_class_entry *fe_scope, const zend_type *fe_type_ptr,
680696
zend_class_entry *proto_scope, const zend_type *proto_type_ptr)
@@ -690,6 +706,11 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
690706
return INHERITANCE_SUCCESS;
691707
}
692708

709+
if (ZEND_TYPE_IS_ASSOCIATED(proto_type)) {
710+
return zend_is_type_subtype_of_associated_type(
711+
fe_scope, fe_type_ptr, proto_type_ptr, proto_scope->associated_types);
712+
}
713+
693714
/* Builtin types may be removed, but not added */
694715
uint32_t fe_type_mask = ZEND_TYPE_PURE_MASK(fe_type);
695716
uint32_t proto_type_mask = ZEND_TYPE_PURE_MASK(proto_type);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /