Return type accuracy and usage improvements #7891
Open
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.
Problem
Some Expressions/Classes are not taking full advantage of the multiple return types system. Others have return types that are incorrectly setup. Ensuring detailed return types is also important for features like local variable type hints.
Solution
I aim to integrate usage of
Expression#possibleReturnTypes
andExpression#canReturn
where possible. I've also cleaned up some classes that were in need of it (to improve their return type logic).A major change that I made is
Expression#canReturn
will always return true if one of the possible return types is Object. This appears to work without issue, but further testing is needed.There may be additional classes that need updated. I will continue searching for them. However, this is ready for an initial review.
Testing Completed
No additional tests have been added yet. Coverage of the modified syntaxes is present, though some additional tests might be possible to test the behavior.
Supporting Information
n/a
Completes: #5060 (needs testing)
Related: none