当前位置: 首页>>代码示例>>C#>>正文


C# Binder.CreateErrorType方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Binder.CreateErrorType方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.CreateErrorType方法的具体用法?C# Binder.CreateErrorType怎么用?C# Binder.CreateErrorType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Binder的用法示例。


在下文中一共展示了Binder.CreateErrorType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FailInference

 public BoundDiscardExpression FailInference(Binder binder, DiagnosticBag diagnosticsOpt)
 {
     if (diagnosticsOpt != null)
     {
         Binder.Error(diagnosticsOpt, ErrorCode.ERR_DiscardTypeInferenceFailed, this.Syntax);
     }
     return this.Update(binder.CreateErrorType("var"));
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:8,代码来源:BoundDiscardExpression.cs

示例2: SetInferredType

        private BoundExpression SetInferredType(TypeSymbol type, Binder binderOpt, DiagnosticBag diagnosticsOpt)
        {
            Debug.Assert(binderOpt != null || (object)type != null);
            Debug.Assert(this.Syntax.Kind() == SyntaxKind.DeclarationExpression);

            bool inferenceFailed = ((object)type == null);

            if (inferenceFailed)
            {
                type = binderOpt.CreateErrorType("var");
            }

            switch (this.VariableSymbol.Kind)
            {
                case SymbolKind.Local:
                    var localSymbol = (SourceLocalSymbol)this.VariableSymbol;

                    if (diagnosticsOpt != null)
                    {
                        if (inferenceFailed)
                        {
                            ReportInferenceFailure(diagnosticsOpt);
                        }
                        else if (localSymbol.ContainingSymbol.Kind == SymbolKind.Method &&
                                 ((MethodSymbol)localSymbol.ContainingSymbol).IsAsync &&
                                 type.IsRestrictedType())
                        {
                            var declaration = (DeclarationExpressionSyntax)this.Syntax;
                            Binder.Error(diagnosticsOpt, ErrorCode.ERR_BadSpecialByRefLocal, declaration.Type, type);
                        }
                    }

                    localSymbol.SetType(type);
                    return new BoundLocal(this.Syntax, localSymbol, constantValueOpt: null, type: type, hasErrors: this.HasErrors || inferenceFailed);

                case SymbolKind.Field:
                    var fieldSymbol = (GlobalExpressionVariable)this.VariableSymbol;
                    var inferenceDiagnostics = DiagnosticBag.GetInstance();

                    if (inferenceFailed)
                    {
                        ReportInferenceFailure(inferenceDiagnostics);
                    }

                    fieldSymbol.SetType(type, inferenceDiagnostics);
                    inferenceDiagnostics.Free();

                    return new BoundFieldAccess(this.Syntax,
                                                this.ReceiverOpt,
                                                fieldSymbol, null, LookupResultKind.Viable, type, 
                                                this.HasErrors || inferenceFailed);

                default:
                    throw ExceptionUtilities.Unreachable;
            }

        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:57,代码来源:OutVariablePendingInference.cs

示例3: FailInference

        public BoundDeclarationExpression FailInference(Binder binder, DiagnosticBag diagnosticsOpt)
        {
            if (diagnosticsOpt != null)
            {
                Binder.Error(diagnosticsOpt, ErrorCode.ERR_ImplicitlyTypedVariableWithNoInitializer, ((DeclarationExpressionSyntax)this.Syntax).Variable.Identifier);
            }

            return this.SetInferredType(binder.CreateErrorType("var"), success: false);
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:9,代码来源:UninitializedVarDeclarationExpression.cs

示例4: FailInference

        public BoundLocal FailInference(Binder binder, DiagnosticBag diagnosticsOpt)
        {
            if (diagnosticsOpt != null)
            {
                Binder.Error(diagnosticsOpt, ErrorCode.ERR_TypeInferenceFailedForImplicitlyTypedOutVariable, ((ArgumentSyntax)this.Syntax).Identifier);
            }

            return this.SetInferredType(binder.CreateErrorType("var"), success: false);
        }
开发者ID:vslsnap,项目名称:roslyn,代码行数:9,代码来源:OutVarLocalPendingInference.cs

示例5: FailInference

        public BoundLocal FailInference(Binder binder, DiagnosticBag diagnosticsOpt)
        {
            if (diagnosticsOpt != null)
            {
                var declaration = (DeclarationExpressionSyntax)this.Syntax;
                Binder.Error(diagnosticsOpt, ErrorCode.ERR_TypeInferenceFailedForImplicitlyTypedOutVariable, declaration.Identifier());
            }

            return this.SetInferredType(binder.CreateErrorType("var"), success: false);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:10,代码来源:OutVarLocalPendingInference.cs

示例6: SetInferredType

        public BoundExpression SetInferredType(TypeSymbol type, Binder binderOpt, DiagnosticBag diagnostics)
        {
            Debug.Assert(binderOpt != null || (object)type != null);
            Debug.Assert(this.Syntax.Kind() == SyntaxKind.SingleVariableDesignation);

            bool inferenceFailed = ((object)type == null);

            if (inferenceFailed)
            {
                type = binderOpt.CreateErrorType("var");
            }

            switch (this.VariableSymbol.Kind)
            {
                case SymbolKind.Local:
                    var local = (SourceLocalSymbol)this.VariableSymbol;
                    if (inferenceFailed)
                    {
                        ReportInferenceFailure(diagnostics);
                    }
                    else
                    {
                        Binder.CheckRestrictedTypeInAsync(local.ContainingSymbol, type, diagnostics, this.Syntax);
                    }

                    local.SetType(type);
                    return new BoundLocal(this.Syntax, local, isDeclaration: true, constantValueOpt: null, type: type, hasErrors: this.HasErrors || inferenceFailed);

                case SymbolKind.Field:
                    var field = (GlobalExpressionVariable)this.VariableSymbol;
                    var inferenceDiagnostics = DiagnosticBag.GetInstance();
                    if (inferenceFailed)
                    {
                        ReportInferenceFailure(inferenceDiagnostics);
                    }
                    field.SetType(type, inferenceDiagnostics);
                    inferenceDiagnostics.Free();
                    return new BoundFieldAccess(this.Syntax, this.ReceiverOpt, field, constantValueOpt: null, hasErrors: this.HasErrors || inferenceFailed);

                default:
                    throw ExceptionUtilities.Unreachable;
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:43,代码来源:DeconstructionVariablePendingInference.cs

示例7: FailInference

 public BoundDeconstructValuePlaceholder FailInference(Binder binder)
 {
     return SetInferredType(binder.CreateErrorType(), success: false);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:OutDeconstructVarPendingInference.cs

示例8: FailInference

 public BoundLocal FailInference(Binder binder)
 {
     return this.SetInferredType(binder.CreateErrorType("var"), success: false);
 }
开发者ID:tvsonar,项目名称:roslyn,代码行数:4,代码来源:DeconstructionLocalPendingInference.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Binder.CreateErrorType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。