public override void VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) { var body = (CSharpSyntaxNode)node.Body ?? node.ExpressionBody; LocalFunctionSymbol match = null; // Don't use LookupLocalFunction because it recurses up the tree, as it // should be defined in the directly enclosing block (see note below) Binder possibleScopeBinder = _enclosing; while (possibleScopeBinder != null && !possibleScopeBinder.IsLocalFunctionsScopeBinder) { possibleScopeBinder = possibleScopeBinder.Next; } if (possibleScopeBinder != null) { foreach (var candidate in possibleScopeBinder.LocalFunctions) { if (candidate.Locations[0] == node.Identifier.GetLocation()) { match = candidate; } } } bool oldSawYield = _sawYield; _sawYield = false; if (match != null) { var oldMethod = _containingMemberOrLambda; _containingMemberOrLambda = match; Binder addToMap; if (match.IsGenericMethod) { addToMap = new WithMethodTypeParametersBinder(match, _enclosing); } else { addToMap = _enclosing; } AddToMap(node, addToMap); if (body != null) { Visit(body, new InMethodBinder(match, addToMap)); } _containingMemberOrLambda = oldMethod; } else { // The enclosing block should have found this node and created a LocalFunctionMethodSymbol // The code that does so is in LocalScopeBinder.BuildLocalFunctions if (body != null) { // do our best to attempt to bind Visit(body); } } if (_sawYield) { _methodsWithYields.Add(body); } _sawYield = oldSawYield; }
protected override LocalFunctionState CreateLocalFunctionState(LocalFunctionSymbol symbol) => CreateLocalFunctionState();
protected override LocalFunctionState CreateLocalFunctionState(LocalFunctionSymbol symbol) => new LocalFunctionState(UnreachableState());
protected abstract TLocalFunctionState CreateLocalFunctionState(LocalFunctionSymbol symbol);