Repository navigation
Resolve an unconstrained template argument from all its bounds - #7227
Merged
Merged
Conversation
A site with nothing inferred took its first covariant upper bound, so passing a fresh Box to a(Box<covariant int|string>) and then to b(Box<covariant int|bool>) inferred Box<int|string> and reported b(). Like JLS 18.4, lower bounds now come first, and failing them the argument is the intersection of every upper bound. Contradicting upper bounds keep the first one, so the conflicting call is still reported. Amp-Thread-ID: https://ampcode.com/threads/T-01a17eac-1199-74a6-b3f7-dfbd8a084465
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.
When nothing was inferred for a generic object's template,
TemplateArgumentSolvertook the first covariant upper bound it was sent to. The result depended on call order, and the later call got a falseargument.type:The solver now follows the order of JLS 18.4:
Box<covariant Countable>andBox<covariant Traversable>now giveBox<Countable&Traversable>instead of reporting the second call.never), the first one stands, so the conflicting call is still reported.Step 2 changes one existing expectation in
nsrt/template-argument-multiple-sites.php(invariantIntoCovariant). There$a->add(1)and$b->add(2)are lower bounds, andtakesBoxOfInt($z)is an upper bound.$ais nowColl<1|2>instead ofColl<int>. Without thetakesBoxOfInt()call it already wasColl<1|2>, so a later covariant consumer no longer widens it. It is also what a lone$box->add(1)gives (Box<1>).The solver is PHP-only (the turbo extension calls into it), so there is no C++ change.