-
-
Notifications
You must be signed in to change notification settings - Fork 393
Return type accuracy and usage improvements #7891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
APickledWalrus
wants to merge
8
commits into
dev/feature
Choose a base branch
from
feature/better-return-type-usage
base: dev/feature
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+353
−189
Conversation
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
APickledWalrus
commented
May 23, 2025
This was referenced May 23, 2025
sovdeeth
approved these changes
May 28, 2025
sovdeeth
approved these changes
Jun 2, 2025
Merged
1 task
erenkarakal
approved these changes
Jun 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
An issue that needs to be fixed. Alternatively, a PR fixing an issue.
enhancement
Feature request, an issue about something that could be improved, or a PR improving something.
feature-ready
A PR/issue that has been approved, tested and can be merged/closed in the next feature version.
needs testing
Needs testing to determine current status or issue validity, or for WIP feature pulls.
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.ExprTernary and ExprDefaultValue have been rewritten and their generics removed. I do not believe these are necessary anymore. The generic ConvertedExpression implementation is capable of ensuring type safety.
Testing Completed
There is existing coverage of most of the modified syntax. I have added tests for ExprTernary and ExprDefaultValue since they were rewritten and previously did not have any tests.
Supporting Information
n/a
Completes: Fixes #5060
Related: none