internal static BoundBlock BindBlock(BlockSyntax node, DiagnosticBag diagnostics, Binder blockBinder) { Debug.Assert(blockBinder != null); var syntaxStatements = node.Statements; int nStatements = syntaxStatements.Count; ArrayBuilder<BoundStatement> boundStatements = ArrayBuilder<BoundStatement>.GetInstance(nStatements); for (int i = 0; i < nStatements; i++) { var boundStatement = blockBinder.BindStatement(syntaxStatements[i], diagnostics); boundStatements.Add(boundStatement); } if (blockBinder.IsDirectlyInIterator) { var method = blockBinder.ContainingMemberOrLambda as MethodSymbol; if ((object)method != null) { method.IteratorElementType = blockBinder.GetIteratorElementType(null, diagnostics); } else { Debug.Assert(!diagnostics.IsEmptyWithoutResolution); } } return new BoundBlock( node, blockBinder.GetDeclaredLocalsForScope(), blockBinder.GetDeclaredLocalFunctionsForScope(), boundStatements.ToImmutableAndFree()); }