}
}
+ public bool HasNamedTupleElement {
+ get {
+ return (state & StateFlags.HasNamedTupleElement) != 0;
+ }
+ }
+
//
// Returns a list of all interfaces including
// interfaces from base type or base interfaces
var imported = MemberDefinition as ImportedTypeDefinition;
if (imported != null && Kind != MemberKind.MissingType)
imported.DefineInterfaces (this);
-
}
return ifaces;
}
}
+ //
+ // Returns true for instances of any System.ValueTuple<......> type
+ //
+ public virtual bool IsTupleType {
+ get {
+ return (state & StateFlags.Tuple) != 0;
+ }
+ set {
+ state = value ? state | StateFlags.Tuple : state & ~StateFlags.Tuple;
+ }
+ }
+
// TODO: Should probably do
// IsGenericType -- recursive
// HasTypeParameter -- non-recursive
if (IsNested) {
s = DeclaringType.GetSignatureForError ();
} else if (MemberDefinition is AnonymousTypeClass) {
- return ((AnonymousTypeClass) MemberDefinition).GetSignatureForError ();
+ return ((AnonymousTypeClass)MemberDefinition).GetSignatureForError ();
+ } else if (IsTupleType) {
+ return FormatTupleSignature ();
} else {
s = MemberDefinition.Namespace;
}
return s + Name + GetTypeNameSignature ();
}
+ string FormatTupleSignature ()
+ {
+ var sb = new StringBuilder ();
+ sb.Append ("(");
+ for (int i = 0; i < TypeArguments.Length; ++i) {
+ if (i != 0)
+ sb.Append (", ");
+
+ sb.Append (TypeArguments[i].GetSignatureForError ());
+ }
+ sb.Append (")");
+
+ return sb.ToString ();
+ }
+
public string GetSignatureForErrorIncludingAssemblyName ()
{
var imported = MemberDefinition.DeclaringAssembly as ImportedAssemblyDefinition;
public static readonly InternalType Namespace = new InternalType ("<namespace>");
public static readonly InternalType ErrorType = new InternalType ("<error>");
public static readonly InternalType VarOutType = new InternalType ("var out");
+ public static readonly InternalType ThrowExpr = new InternalType ("throw expression");
readonly string name;
}
#endregion
+
+ public static bool HasNoType (TypeSpec type)
+ {
+ return type == AnonymousMethod || type == MethodGroup || type == NullLiteral || type == ThrowExpr;
+ }
}
//
public TypeSpec Element { get; private set; }
+ public override IList<TypeSpec> Interfaces {
+ set {
+ throw new NotSupportedException ();
+ }
+ }
+
bool ITypeDefinition.IsComImport {
get {
return false;
readonly int rank;
readonly ModuleContainer module;
- private ArrayContainer (ModuleContainer module, TypeSpec element, int rank)
+ ArrayContainer (ModuleContainer module, TypeSpec element, int rank)
: base (MemberKind.ArrayType, element, null)
{
this.module = module;
this.rank = rank;
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return BaseType.Interfaces;
+ }
+ }
+
public int Rank {
get {
return rank;
if (!module.ArrayTypesCache.TryGetValue (key, out ac)) {
ac = new ArrayContainer (module, element, rank);
ac.BaseType = module.Compiler.BuiltinTypes.Array;
- ac.Interfaces = ac.BaseType.Interfaces;
module.ArrayTypesCache.Add (key, ac);
}
}
}
+ [System.Diagnostics.DebuggerDisplay("{DisplayDebugInfo()}")]
class ReferenceContainer : ElementTypeSpec
{
- private ReferenceContainer (TypeSpec element)
- : base (MemberKind.Class, element, null) // TODO: Kind.Class is most likely wrong
+ ReferenceContainer (TypeSpec element)
+ : base (MemberKind.ByRef, element, null)
{
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return null;
+ }
+ }
+
+ string DisplayDebugInfo()
+ {
+ return "ref " + GetSignatureForError();
+ }
+
public override MetaType GetMetaInfo ()
{
if (info == null) {
return info;
}
+ public override string GetSignatureForError ()
+ {
+ return Element.GetSignatureForError ();
+ }
+
public static ReferenceContainer MakeType (ModuleContainer module, TypeSpec element)
{
+ if (element.Kind == MemberKind.ByRef)
+ throw new ArgumentException ();
+
ReferenceContainer pc;
if (!module.ReferenceTypesCache.TryGetValue (element, out pc)) {
pc = new ReferenceContainer (element);
state &= ~StateFlags.CLSCompliant_Undetected;
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return null;
+ }
+ }
+
public override MetaType GetMetaInfo ()
{
if (info == null) {