What exactly is a “Special Class”?

From the Roslyn source code, it looks like a list of hardcoded types in isValidConstraintType:

switch (type.SpecialType)
{
    case SpecialType.System_Object:
    case SpecialType.System_ValueType:
    case SpecialType.System_Enum:
    case SpecialType.System_Delegate:
    case SpecialType.System_MulticastDelegate:
    case SpecialType.System_Array:
        // "Constraint cannot be special class '{0}'"
        Error(diagnostics, ErrorCode.ERR_SpecialTypeAsBound, syntax, type);
        return false;
}
  • isValidConstraintType in GitHub (updated with new types)
  • IsValidConstraintType is Roslyn Source Browser
  • I’ve found it using a GitHub search: “A constraint cannot be special class”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)