• A
    Implement definite assignment changes for local functions (#13234) · 04753508
    Andy Gocke 提交于
    This PR implements the design changes for flow analysis in local
    functions, specifically the decision to allow local functions to be
    declared anywhere in the method and only have captured usages considered
    at the local function use site, rather than the declaration site.
    
    The key points of the algorithm are as follows:
    
        1. Visit local functions recursively:
            a. For each new read/write of a captured variable in the local
               function, record it. If the local function has already been used,
               mark the `stateChangedAfterUse` to `true`, indicating that we
               need to visit another pass.
            b. When a local function is used, play back the recorded
               read/writes if the variable is not still captured. Mark the local
               function as used.
        2. Process remaining statements in the parent method, performing
            (1.b) when necessary.
        3. If `stateAfterChanged` has been set to true, visit the entire method
           again (and go to 1).
    
    Fixes #10391.
    04753508
LambdaRewriter.LocalFunctionReferenceRewriter.cs 6.1 KB