Simplify deferred function, class, and accessor checking #6083
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.
We defer checking of function, class, and accessor bodies that are contained in expressions in order to avoid type checking circularities. For example:
Here, performing a full type check of the body of the function expression whilst in the process of determining the type of foo would cause foo to be given type any because of the recursive reference. Delaying the type check of the body ensures foo has been assigned a type.
We previously performed an AST walk to find the deferred function, class, and accessor bodies. The walker was a rather brittle piece of logic with lots of cases to reason about (and possibly forget). This PR replaces the logic with a simple list of deferred nodes to be checked later. This removes a bunch of code and improves checker performance by 5% or so (with the Monaco project) due to the elimination of the extra AST walk.
The baseline changes are caused by the fact that we now never check the expression in an out-of-place return statement (as intended). We previously sometimes checked it (specifically in cases when the return statement contained a deferred function, class, or accessor body).