本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.IsOpenTypePlaceholderType方法的典型用法代码示例。如果您正苦于以下问题:C# CType.IsOpenTypePlaceholderType方法的具体用法?C# CType.IsOpenTypePlaceholderType怎么用?C# CType.IsOpenTypePlaceholderType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.CType
的用法示例。
在下文中一共展示了CType.IsOpenTypePlaceholderType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckSingleConstraint
private static bool CheckSingleConstraint(CSemanticChecker checker, ErrorHandling errHandling, Symbol symErr, TypeParameterType var, CType arg, TypeArray typeArgsCls, TypeArray typeArgsMeth, CheckConstraintsFlags flags)
{
bool fReportErrors = 0 == (flags & CheckConstraintsFlags.NoErrors);
if (arg.IsOpenTypePlaceholderType())
{
return true;
}
if (arg.IsErrorType())
{
// Error should have been reported previously.
return false;
}
if (checker.CheckBogus(arg))
{
if (fReportErrors)
{
errHandling.ErrorRef(ErrorCode.ERR_BogusType, arg);
}
return false;
}
if (arg.IsPointerType() || arg.isSpecialByRefType())
{
if (fReportErrors)
{
errHandling.Error(ErrorCode.ERR_BadTypeArgument, arg);
}
return false;
}
if (arg.isStaticClass())
{
if (fReportErrors)
{
checker.ReportStaticClassError(null, arg, ErrorCode.ERR_GenericArgIsStaticClass);
}
return false;
}
bool fError = false;
if (var.HasRefConstraint() && !arg.IsRefType())
{
if (fReportErrors)
{
errHandling.ErrorRef(ErrorCode.ERR_RefConstraintNotSatisfied, symErr, new ErrArgNoRef(var), arg);
}
fError = true;
}
TypeArray bnds = checker.GetSymbolLoader().GetTypeManager().SubstTypeArray(var.GetBounds(), typeArgsCls, typeArgsMeth);
int itypeMin = 0;
if (var.HasValConstraint())
{
// If we have a type variable that is constrained to a value type, then we
// want to check if its a nullable type, so that we can report the
// constraint error below. In order to do this however, we need to check
// that either the type arg is not a value type, or it is a nullable type.
//
// To check whether or not its a nullable type, we need to get the resolved
// bound from the type argument and check against that.
bool bIsValueType = arg.IsValType();
bool bIsNullable = arg.IsNullableType();
if (bIsValueType && arg.IsTypeParameterType())
{
TypeArray pArgBnds = arg.AsTypeParameterType().GetBounds();
if (pArgBnds.size > 0)
{
bIsNullable = pArgBnds.Item(0).IsNullableType();
}
}
if (!bIsValueType || bIsNullable)
{
if (fReportErrors)
{
errHandling.ErrorRef(ErrorCode.ERR_ValConstraintNotSatisfied, symErr, new ErrArgNoRef(var), arg);
}
fError = true;
}
// Since FValCon() is set it is redundant to check System.ValueType as well.
if (bnds.size != 0 && bnds.Item(0).isPredefType(PredefinedType.PT_VALUE))
{
itypeMin = 1;
}
}
for (int j = itypeMin; j < bnds.size; j++)
{
CType typeBnd = bnds.Item(j);
//.........这里部分代码省略.........