Repository navigation
Call restricted usage extensions for members accessed on nullable types - #7008
Closed
ondrejmirtes wants to merge 1 commit into
Closed
ondrejmirtes wants to merge 1 commit into
ondrejmirtes wants to merge 1 commit into
Conversation
Restricted usage rules took class names from getObjectClassNames(), which returns nothing for unions with non-object members like Foo|null. Strip the non-object parts first so extensions are still called once per class. Amp-Thread-ID: https://ampcode.com/threads/T-01a1bc39-a252-73e6-a583-cfe70f1d1c88
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.
Restricted usage rules for methods, properties, class constants, their static and first-class-callable variants, and the deprecated
__toStringcast rule did not call extensions when the member was accessed on a type such asFoo|nullorFoo|false.The instance rules took class names from
getObjectClassNames(), which returns[]for a union with any non-object member. The static rules usedFoundTypeResult::getReferencedClasses(), which has the same issue whencheckNullablesis on. Only$foo?->doFoo()was reported, because the nullsafe call narrows$foofirst.The rules now intersect the type with
objectbefore collecting class names. Extensions are still called once per class, soFoo|Barkeeps reporting each class separately. Passing a mergedUnionTypeMethodReflectionfromScope::getMethodReflection()would hide e.g. a deprecated method that exists on only one member of the union.