Avoid inherited method clone when no generic slot changes#4
Merged
azjezz merged 1 commit intoMay 12, 2026
Conversation
Only clone arg_info for inherited generic methods once a class-scope substitution actually changes a parameter or return type. A method-level generic return such as Box<O> still has generic side-table data, but it does not require a class-scope substitution when inherited by Box<string>. Leaving the original arg_info in place avoids creating an unnecessary substituted clone.
33e6090
into
carthage-software:rfc/bound-erased-generic-types-history
18 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The failing CI job was
Zend/tests/generics/inheritance/method/inherited_method_with_named_with_args_return.phpt.That case has a method-level generic return
Box<O>. The method still has generic side-table data, but inheriting it intoStringBox extends Box<string>does not actually substitute any class-scope slot.zend_substitute_trait_method_arg_info()was still cloning the arg_info block eagerly, even when no parameter or return type changed. This keeps the original arg_info unless a substitution actually writes into the cloned block.Tests run:
make -j$(sysctl -n hw.ncpu) sapi/cli/php run-tests.php -q -d opcache.enable_cli=1 -d opcache.jit=function -d opcache.protect_memory=1 -d opcache.jit_buffer_size=64M Zend/tests/generics/inheritance/method/inherited_method_with_named_with_args_return.phpt sapi/cli/php run-tests.php -q -d opcache.enable_cli=1 -d opcache.jit=tracing -d opcache.protect_memory=1 -d opcache.jit_buffer_size=64M Zend/tests/generics/inheritance/method/inherited_method_with_named_with_args_return.phpt sapi/cli/php run-tests.php -q Zend/tests/generics/inheritance/method Zend/tests/generics/traits ext/reflection/tests/generics sapi/cli/php run-tests.php -q Zend/tests/generics ext/reflection/tests/generics