protected override TypeSymbol InferTypeOfVarVariable(DiagnosticBag diagnostics) { // Try binding enclosing deconstruction-declaration (the top-level VariableDeclaration), this should force the inference. switch (_deconstruction.Kind()) { case SyntaxKind.DeconstructionDeclarationStatement: var localDecl = (DeconstructionDeclarationStatementSyntax)_deconstruction; _nodeBinder.BindDeconstructionDeclaration(localDecl, localDecl.Assignment.VariableComponent, localDecl.Assignment.Value, diagnostics); break; case SyntaxKind.ForStatement: var forStatement = (ForStatementSyntax)_deconstruction; Debug.Assert(this.ScopeBinder.GetBinder(forStatement) == _nodeBinder); _nodeBinder.BindDeconstructionDeclaration(forStatement, forStatement.Deconstruction.VariableComponent, forStatement.Deconstruction.Value, diagnostics); break; case SyntaxKind.ForEachComponentStatement: Debug.Assert(this.ScopeBinder.GetBinder((ForEachComponentStatementSyntax)_deconstruction) == _nodeBinder); _nodeBinder.BindForEachDeconstruction(diagnostics, _nodeBinder); break; default: throw ExceptionUtilities.UnexpectedValue(_deconstruction.Kind()); } TypeSymbol result = this._type; Debug.Assert((object)result != null); return(result); }
protected override TypeSymbol InferTypeOfVarVariable(DiagnosticBag diagnostics) { // Try binding enclosing deconstruction-declaration (the top-level VariableDeclaration), this should force the inference. switch (_deconstruction.Kind()) { case SyntaxKind.SimpleAssignmentExpression: var assignment = (AssignmentExpressionSyntax)_deconstruction; Debug.Assert(assignment.IsDeconstructionDeclaration()); _nodeBinder.BindDeconstructionDeclaration(assignment, assignment.Left, assignment.Right, diagnostics); break; case SyntaxKind.ForEachVariableStatement: Debug.Assert(this.ScopeBinder.GetBinder((ForEachVariableStatementSyntax)_deconstruction) == _nodeBinder); _nodeBinder.BindForEachDeconstruction(diagnostics, _nodeBinder); break; default: throw ExceptionUtilities.UnexpectedValue(_deconstruction.Kind()); } TypeSymbol result = this._type; Debug.Assert((object)result != null); return(result); }