From: Nikita Popov Date: Tue, 3 Nov 2020 14:29:18 +0000 (+0100) Subject: Fix use of type copy ctor when importing trait properties X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fd8e00f1a90acd5e23bfcb6f8b0217187bcfb1d;p=php Fix use of type copy ctor when importing trait properties We shouldn't call the copy constructor inside the original type, duh. --- diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index c3aad9f614..b0f4055be1 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -2049,8 +2049,9 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent Z_TRY_ADDREF_P(prop_value); doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL; - zend_type_copy_ctor(&property_info->type, /* persistent */ 0); - new_prop = zend_declare_typed_property(ce, prop_name, prop_value, flags, doc_comment, property_info->type); + zend_type type = property_info->type; + zend_type_copy_ctor(&type, /* persistent */ 0); + new_prop = zend_declare_typed_property(ce, prop_name, prop_value, flags, doc_comment, type); if (property_info->attributes) { new_prop->attributes = property_info->attributes; diff --git a/ext/opcache/tests/preload_ind.inc b/ext/opcache/tests/preload_ind.inc new file mode 100644 index 0000000000..f7f3f4f231 --- /dev/null +++ b/ext/opcache/tests/preload_ind.inc @@ -0,0 +1,2 @@ + +--FILE-- +OK +--EXPECTF-- +Warning: Can't preload class C with unresolved property types in %s on line %d +OK diff --git a/ext/opcache/tests/preload_ind2.inc b/ext/opcache/tests/preload_ind2.inc new file mode 100644 index 0000000000..93a741f95a --- /dev/null +++ b/ext/opcache/tests/preload_ind2.inc @@ -0,0 +1,9 @@ +