var imported = MemberDefinition as ImportedTypeDefinition;
if (imported != null && Kind != MemberKind.MissingType)
imported.DefineInterfaces (this);
-
}
return ifaces;
//
// Returns true for instances of IList<T>, IEnumerable<T>, ICollection<T>
//
- public virtual bool IsGenericIterateInterface {
+ public virtual bool IsArrayGenericInterface {
get {
return false;
}
}
}
+ public bool IsStructOrEnum {
+ get {
+ return (Kind & (MemberKind.Struct | MemberKind.Enum)) != 0;
+ }
+ }
+
public bool IsTypeBuilder {
get {
#if STATIC
if (Kind == MemberKind.Void)
return true;
+ if (Kind == MemberKind.TypeParameter)
+ return false;
+
if (IsNested && DeclaringType.IsGenericOrParentIsGeneric)
return false;
throw new InternalErrorException ("Modifying expanded interface list");
if (ifaces == null) {
- ifaces = new List<TypeSpec> () { iface };
+ ifaces = new List<TypeSpec> { iface };
return true;
}
//
// Text representation of type used by documentation writer
//
- public override string GetSignatureForDocumentation ()
+ public sealed override string GetSignatureForDocumentation ()
+ {
+ return GetSignatureForDocumentation (false);
+ }
+
+ public virtual string GetSignatureForDocumentation (bool explicitName)
{
StringBuilder sb = new StringBuilder ();
if (IsNested) {
- sb.Append (DeclaringType.GetSignatureForDocumentation ());
- } else {
- sb.Append (MemberDefinition.Namespace);
+ sb.Append (DeclaringType.GetSignatureForDocumentation (explicitName));
+ } else if (MemberDefinition.Namespace != null) {
+ sb.Append (explicitName ? MemberDefinition.Namespace.Replace ('.', '#') : MemberDefinition.Namespace);
}
if (sb.Length != 0)
- sb.Append (".");
+ sb.Append (explicitName ? "#" : ".");
sb.Append (Name);
if (Arity > 0) {
if (i > 0)
sb.Append (",");
- sb.Append (TypeArguments[i].GetSignatureForDocumentation ());
+ sb.Append (TypeArguments[i].GetSignatureForDocumentation (explicitName));
}
sb.Append ("}");
} else {
return sb.ToString ();
}
- public string GetExplicitNameSignatureForDocumentation ()
- {
- StringBuilder sb = new StringBuilder ();
- if (IsNested) {
- sb.Append (DeclaringType.GetExplicitNameSignatureForDocumentation ());
- } else if (MemberDefinition.Namespace != null) {
- sb.Append (MemberDefinition.Namespace.Replace ('.', '#'));
- }
-
- if (sb.Length != 0)
- sb.Append ("#");
-
- sb.Append (Name);
- if (Arity > 0) {
- sb.Append ("{");
- for (int i = 0; i < Arity; ++i) {
- if (i > 0)
- sb.Append (",");
-
- sb.Append (TypeArguments[i].GetExplicitNameSignatureForDocumentation ());
- }
- sb.Append ("}");
- }
-
- return sb.ToString ();
- }
-
public override string GetSignatureForError ()
{
string s;
public string GetSignatureForErrorIncludingAssemblyName ()
{
- return string.Format ("{0} [{1}]", GetSignatureForError (), MemberDefinition.DeclaringAssembly.FullName);
+ var imported = MemberDefinition.DeclaringAssembly as ImportedAssemblyDefinition;
+
+ var location = imported != null ?
+ System.IO.Path.GetFullPath (imported.Location) :
+ ((MemberCore)MemberDefinition).Location.NameFullPath;
+
+ return string.Format ("{0} [{1} -- {2}]", GetSignatureForError (),
+ MemberDefinition.DeclaringAssembly.FullName,
+ location);
}
protected virtual string GetTypeNameSignature ()
case MemberKind.Struct:
case MemberKind.Enum:
case MemberKind.Void:
+ case MemberKind.PointerType:
return false;
case MemberKind.InternalCompilerType:
//
}
}
+ public static bool IsNonNullableValueType (TypeSpec t)
+ {
+ switch (t.Kind) {
+ case MemberKind.TypeParameter:
+ return ((TypeParameterSpec) t).IsValueType;
+ case MemberKind.Struct:
+ return !t.IsNullableType;
+ case MemberKind.Enum:
+ return true;
+ default:
+ return false;
+ }
+ }
+
public static bool IsValueType (TypeSpec t)
{
switch (t.Kind) {
return this;
}
- public override List<TypeSpec> ResolveMissingDependencies ()
+ public override List<MissingTypeSpecReference> ResolveMissingDependencies (MemberSpec caller)
{
- List<TypeSpec> missing = null;
+ List<MissingTypeSpecReference> missing = null;
if (Kind == MemberKind.MissingType) {
- missing = new List<TypeSpec> ();
- missing.Add (this);
+ missing = new List<MissingTypeSpecReference> ();
+ missing.Add (new MissingTypeSpecReference (this, caller));
return missing;
}
foreach (var targ in TypeArguments) {
if (targ.Kind == MemberKind.MissingType) {
if (missing == null)
- missing = new List<TypeSpec> ();
+ missing = new List<MissingTypeSpecReference> ();
- missing.Add (targ);
+ missing.Add (new MissingTypeSpecReference (targ, caller));
}
}
foreach (var iface in Interfaces) {
if (iface.Kind == MemberKind.MissingType) {
if (missing == null)
- missing = new List<TypeSpec> ();
+ missing = new List<MissingTypeSpecReference> ();
- missing.Add (iface);
+ missing.Add (new MissingTypeSpecReference (iface, caller));
}
}
}
if (MemberDefinition.TypeParametersCount > 0) {
foreach (var tp in MemberDefinition.TypeParameters) {
- var tp_missing = tp.GetMissingDependencies ();
+ var tp_missing = tp.GetMissingDependencies (this);
if (tp_missing != null) {
if (missing == null)
- missing = new List<TypeSpec> ();
+ missing = new List<MissingTypeSpecReference> ();
missing.AddRange (tp_missing);
}
if (missing != null || BaseType == null)
return missing;
- return BaseType.ResolveMissingDependencies ();
+ return BaseType.ResolveMissingDependencies (this);
}
public void SetMetaInfo (MetaType info)
{
modifiers |= Modifiers.METHOD_EXTENSION;
}
+
+ public void UpdateInflatedInstancesBaseType ()
+ {
+ //
+ // When nested class has a partial part the situation where parent type
+ // is inflated before its base type is defined can occur. In such case
+ // all inflated (should be only 1) instansted need to be updated
+ //
+ // partial class A<T> {
+ // partial class B : A<int> { }
+ // }
+ //
+ // partial class A<T> : X {}
+ //
+ if (inflated_instances == null)
+ return;
+
+ foreach (var inflated in inflated_instances) {
+ //
+ // Don't need to inflate possible generic type because for now the method
+ // is always used from within the nested type
+ //
+ inflated.Value.BaseType = base_type;
+ }
+ }
}
//
return false;
}
+ if (a.IsNested && b.IsNested)
+ return IsEqual (a.DeclaringType, b.DeclaringType);
+
return true;
}
bool IsPartial { get; }
bool IsComImport { get; }
bool IsTypeForwarder { get; }
+ bool IsCyclicTypeForwarder { get; }
int TypeParametersCount { get; }
TypeParameterSpec[] TypeParameters { get; }
public static readonly InternalType FakeInternalType = new InternalType ("<fake$type>");
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");
readonly string name;
}
}
+ bool ITypeDefinition.IsCyclicTypeForwarder {
+ get {
+ return false;
+ }
+ }
+
public override string Name {
get {
return name;
public TypeSpec Element { get; private set; }
+ public override IList<TypeSpec> Interfaces {
+ set {
+ throw new NotSupportedException ();
+ }
+ }
+
bool ITypeDefinition.IsComImport {
get {
return false;
}
}
+ bool ITypeDefinition.IsCyclicTypeForwarder {
+ get {
+ return false;
+ }
+ }
+
public override string Name {
get {
throw new NotSupportedException ();
#endregion
+ public override void CheckObsoleteness (IMemberContext mc, Location loc)
+ {
+ Element.CheckObsoleteness (mc, loc);
+ }
+
public override ObsoleteAttribute GetAttributeObsolete ()
{
return Element.GetAttributeObsolete ();
return null;
}
- public override string GetSignatureForDocumentation ()
+ public override string GetSignatureForDocumentation (bool explicitName)
{
- return Element.GetSignatureForDocumentation () + GetPostfixSignature ();
+ return Element.GetSignatureForDocumentation (explicitName) + GetPostfixSignature ();
}
public override string GetSignatureForError ()
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;
return sb.ToString ();
}
- public override string GetSignatureForDocumentation ()
+ public override string GetSignatureForDocumentation (bool explicitName)
{
StringBuilder sb = new StringBuilder ();
- GetElementSignatureForDocumentation (sb);
+ GetElementSignatureForDocumentation (sb, explicitName);
return sb.ToString ();
}
- void GetElementSignatureForDocumentation (StringBuilder sb)
+ void GetElementSignatureForDocumentation (StringBuilder sb, bool explicitName)
{
var ac = Element as ArrayContainer;
if (ac == null)
- sb.Append (Element.GetSignatureForDocumentation ());
+ sb.Append (Element.GetSignatureForDocumentation (explicitName));
else
- ac.GetElementSignatureForDocumentation (sb);
+ ac.GetElementSignatureForDocumentation (sb, explicitName);
- sb.Append ("[");
- for (int i = 1; i < rank; i++) {
- if (i == 1)
- sb.Append ("0:");
+ if (explicitName) {
+ sb.Append (GetPostfixSignature (rank));
+ } else {
+ sb.Append ("[");
+ for (int i = 1; i < rank; i++) {
+ if (i == 1)
+ sb.Append ("0:");
- sb.Append (",0:");
+ sb.Append (",0:");
+ }
+ sb.Append ("]");
}
- sb.Append ("]");
}
public static ArrayContainer MakeType (ModuleContainer module, TypeSpec element)
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);
}
return ac;
}
+
+ public override List<MissingTypeSpecReference> ResolveMissingDependencies (MemberSpec caller)
+ {
+ return Element.ResolveMissingDependencies (caller);
+ }
}
class ReferenceContainer : ElementTypeSpec
{
- private ReferenceContainer (TypeSpec element)
+ ReferenceContainer (TypeSpec element)
: base (MemberKind.Class, element, null) // TODO: Kind.Class is most likely wrong
{
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return null;
+ }
+ }
+
public override MetaType GetMetaInfo ()
{
if (info == null) {
state &= ~StateFlags.CLSCompliant_Undetected;
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return null;
+ }
+ }
+
public override MetaType GetMetaInfo ()
{
if (info == null) {
return pc;
}
}
+
+ public class MissingTypeSpecReference
+ {
+ public MissingTypeSpecReference (TypeSpec type, MemberSpec caller)
+ {
+ Type = type;
+ Caller = caller;
+ }
+
+ public TypeSpec Type { get; private set; }
+ public MemberSpec Caller { get; private set; }
+ }
}