Skip to content

Commit c3486dd

Browse files
committed
Rename last associated macro stuff to generic
1 parent b773242 commit c3486dd

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

Zend/zend_compile.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ static zend_string *add_intersection_type(zend_string *str,
14371437
zend_string *zend_type_to_string_resolved(const zend_type type, zend_class_entry *scope) {
14381438
zend_string *str = NULL;
14391439

1440+
ZEND_ASSERT(!ZEND_TYPE_IS_GENERIC_PARAM_NAME(type) && "Generic type declarations do not exist yet");
14401441
/* Pure intersection type */
14411442
if (ZEND_TYPE_IS_INTERSECTION(type)) {
14421443
ZEND_ASSERT(!ZEND_TYPE_IS_UNION(type));
@@ -1457,8 +1458,6 @@ zend_string *zend_type_to_string_resolved(const zend_type type, zend_class_entry
14571458
str = add_type_string(str, resolved, /* is_intersection */ false);
14581459
zend_string_release(resolved);
14591460
} ZEND_TYPE_LIST_FOREACH_END();
1460-
} else if (ZEND_TYPE_IS_ASSOCIATED(type)) {
1461-
ZEND_ASSERT(false && "Generic type declarations do not exist yet");
14621461
} else if (ZEND_TYPE_HAS_NAME(type)) {
14631462
str = resolve_class_name(ZEND_TYPE_NAME(type), scope);
14641463
}
@@ -7220,7 +7219,7 @@ static zend_type zend_compile_typename_ex(
72207219
single_type = zend_compile_single_typename(type_ast);
72217220
uint32_t single_type_mask = ZEND_TYPE_PURE_MASK(single_type);
72227221

7223-
if (ZEND_TYPE_IS_ASSOCIATED(single_type)) {
7222+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(single_type)) {
72247223
zend_error_noreturn(E_COMPILE_ERROR, "Generic type cannot be part of a union type");
72257224
}
72267225
if (single_type_mask == MAY_BE_ANY) {
@@ -7305,7 +7304,7 @@ static zend_type zend_compile_typename_ex(
73057304
zend_ast *type_ast = list->child[i];
73067305
zend_type single_type = zend_compile_single_typename(type_ast);
73077306

7308-
if (ZEND_TYPE_IS_ASSOCIATED(single_type)) {
7307+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(single_type)) {
73097308
zend_error_noreturn(E_COMPILE_ERROR, "Generic type cannot be part of an intersection type");
73107309
}
73117310
/* An intersection of union types cannot exist so invalidate it
@@ -7374,10 +7373,10 @@ static zend_type zend_compile_typename_ex(
73747373
if ((type_mask & MAY_BE_NULL) && is_marked_nullable) {
73757374
zend_error_noreturn(E_COMPILE_ERROR, "null cannot be marked as nullable");
73767375
}
7377-
if (ZEND_TYPE_IS_ASSOCIATED(type) && is_marked_nullable) {
7376+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(type) && is_marked_nullable) {
73787377
zend_error_noreturn(E_COMPILE_ERROR, "Generic type cannot be part of a union type");
73797378
}
7380-
if (ZEND_TYPE_IS_ASSOCIATED(type) && force_allow_null) {
7379+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(type) && force_allow_null) {
73817380
zend_error_noreturn(E_COMPILE_ERROR, "Generic type cannot be part of a union type (implicitly nullable due to default null value)");
73827381
}
73837382

@@ -9173,7 +9172,7 @@ static void zend_compile_generic_params(zend_ast *params_ast)
91739172

91749173
if (param_ast->child[1]) {
91759174
constraint_type = zend_compile_typename(param_ast->child[1]);
9176-
if (ZEND_TYPE_IS_ASSOCIATED(constraint_type)) {
9175+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(constraint_type)) {
91779176
zend_error_noreturn(E_COMPILE_ERROR,
91789177
"Cannot use generic parameter %s to constrain generic parameter %s",
91799178
ZSTR_VAL(ZEND_TYPE_NAME(constraint_type)), ZSTR_VAL(name));

Zend/zend_inheritance.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -723,12 +723,12 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
723723
}
724724

725725
/* If we check for concrete return type */
726-
if (ZEND_TYPE_IS_ASSOCIATED(proto_type)) {
726+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(proto_type)) {
727727
return zend_is_type_subtype_of_generic_type(
728728
fe_scope, fe_type_ptr, proto_scope, proto_type_ptr);
729729
}
730730
/* If we check for concrete parameter type */
731-
if (ZEND_TYPE_IS_ASSOCIATED(fe_type)) {
731+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(fe_type)) {
732732
return zend_is_type_subtype_of_generic_type(
733733
proto_scope, proto_type_ptr, fe_scope, fe_type_ptr);
734734
}
@@ -2248,7 +2248,7 @@ ZEND_ATTRIBUTE_NONNULL static void bind_generic_types_for_inherited_interfaces(z
22482248
);
22492249
ZEND_HASH_FOREACH_KEY_PTR(interface_bound_types_for_inherited_iface, generic_param_index, generic_param_name, bound_type_ptr) {
22502250
zend_type bound_type = *bound_type_ptr;
2251-
if (ZEND_TYPE_IS_ASSOCIATED(bound_type)) {
2251+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(bound_type)) {
22522252
ZEND_ASSERT(ce_bound_types_for_direct_iface != NULL &&
22532253
"If a bound type is generic then we must have bound types for the current interface");
22542254
const zend_type *ce_bound_type_ptr = zend_hash_find_ptr(ce_bound_types_for_direct_iface, ZEND_TYPE_NAME(bound_type));
@@ -2347,7 +2347,7 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
23472347
ZEND_ASSERT(bound_type_ptr != NULL);
23482348

23492349
/* We are currently extending another interface */
2350-
if (ZEND_TYPE_IS_ASSOCIATED(*bound_type_ptr)) {
2350+
if (ZEND_TYPE_IS_GENERIC_PARAM_NAME(*bound_type_ptr)) {
23512351
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_INTERFACE);
23522352
ZEND_ASSERT(ce->num_generic_parameters > 0);
23532353
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(*bound_type_ptr));

Zend/zend_types.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ typedef struct {
149149
#define _ZEND_TYPE_EXTRA_FLAGS_SHIFT 26
150150
#define _ZEND_TYPE_MASK ((1u << 26) - 1)
151151
/* Only one of these bits may be set. */
152-
#define _ZEND_TYPE_ASSOCIATED_BIT (1u << 25)
152+
#define _ZEND_TYPE_GENERIC_PARAM_NAME_BIT (1u << 25)
153153
#define _ZEND_TYPE_NAME_BIT (1u << 24)
154154
// Used to signify that type.ptr is not a `zend_string*` but a `const char*`,
155155
#define _ZEND_TYPE_LITERAL_NAME_BIT (1u << 23)
@@ -185,7 +185,7 @@ typedef struct {
185185
#define ZEND_TYPE_HAS_LIST(t) \
186186
((((t).type_mask) & _ZEND_TYPE_LIST_BIT) != 0)
187187

188-
#define ZEND_TYPE_IS_ASSOCIATED(t) \
188+
#define ZEND_TYPE_IS_GENERIC_PARAM_NAME(t) \
189189
((((t).type_mask) & _ZEND_TYPE_ASSOCIATED_BIT) != 0)
190190

191191
#define ZEND_TYPE_IS_ITERABLE_FALLBACK(t) \

0 commit comments

Comments
 (0)