本文整理汇总了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"));
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例7: FailInference
public BoundDeconstructValuePlaceholder FailInference(Binder binder)
{
return SetInferredType(binder.CreateErrorType(), success: false);
}
示例8: FailInference
public BoundLocal FailInference(Binder binder)
{
return this.SetInferredType(binder.CreateErrorType("var"), success: false);
}