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.IsDeconstruction());
                    DeclarationExpressionSyntax declaration = null;
                    ExpressionSyntax            expression  = null;
                    _nodeBinder.BindDeconstruction(assignment, assignment.Left, assignment.Right, diagnostics, ref declaration, ref expression);
                    break;

                case SyntaxKind.ForEachVariableStatement:
                    Debug.Assert(this.ScopeBinder.GetBinder((ForEachVariableStatementSyntax)_deconstruction) == _nodeBinder);
                    _nodeBinder.BindForEachDeconstruction(diagnostics, _nodeBinder);
                    break;

                default:
                    throw ExceptionUtilities.UnexpectedValue(_deconstruction.Kind());
                }

                Debug.Assert((object)this._type != null);
                return(this._type);
            }
示例#2
0
            protected override TypeWithAnnotations InferTypeOfVarVariable(
                BindingDiagnosticBag 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.IsDeconstruction());
                    DeclarationExpressionSyntax declaration = null;
                    ExpressionSyntax            expression  = null;
                    _nodeBinder.BindDeconstruction(
                        assignment,
                        assignment.Left,
                        assignment.Right,
                        diagnostics,
                        ref declaration,
                        ref expression
                        );
                    break;

                case SyntaxKind.ForEachVariableStatement:
                    Debug.Assert(
                        this.ScopeBinder.GetBinder(
                            (ForEachVariableStatementSyntax)_deconstruction
                            ) == _nodeBinder
                        );
                    _nodeBinder.BindForEachDeconstruction(diagnostics, _nodeBinder);
                    break;

                default:
                    return(TypeWithAnnotations.Create(_nodeBinder.CreateErrorType()));
                }

                return(_type.Value);
            }