Use existing error reporting.
[mono.git] / mcs / mcs / class.cs
index 64b6fa35934019b4ac14ad3ab8d64b5f8305c816..7ba618276e080f69d717f809d8263a55d939776f 100644 (file)
@@ -1063,6 +1063,10 @@ namespace Mono.CSharp {
 
                        if (iface_exprs != null) {
                                foreach (TypeExpr iface in iface_exprs) {
+                                       // Prevents a crash, the interface might not have been resolved: 442144
+                                       if (iface == null)
+                                               continue;
+                                       
                                        var iface_type = iface.Type;
 
                                        if (!spec.AddInterface (iface_type))
@@ -1353,6 +1357,9 @@ namespace Mono.CSharp {
 
                        if (iface_exprs != null) {
                                foreach (TypeExpr iface in iface_exprs) {
+                                       // the interface might not have been resolved, prevents a crash, see #442144
+                                       if (iface == null)
+                                               continue;
                                        var ptc = iface.Type.MemberDefinition as Interface;
                                        if (ptc != null && ptc.CheckRecursiveDefinition (this) != null)
                                                return iface.Type;
@@ -1430,8 +1437,15 @@ namespace Mono.CSharp {
                                        ct.CheckConstraints (this);
 
                                var baseContainer = base_type.Type.MemberDefinition as ClassOrStruct;
-                               if (baseContainer != null)
+                               if (baseContainer != null) {
                                        baseContainer.Define ();
+
+                                       //
+                                       // It can trigger define of this type (for generic types only)
+                                       //
+                                       if (HasMembersDefined)
+                                               return true;
+                               }
                        }
 
                        if (type_params != null) {
@@ -2531,13 +2545,13 @@ namespace Mono.CSharp {
                        if (fields == null)
                                return true;
 
-                       if (requires_delayed_unmanagedtype_check)
-                               return true;
-
                        if (has_unmanaged_check_done)
                                return is_unmanaged;
 
-                       has_unmanaged_check_done = true;
+                       if (requires_delayed_unmanagedtype_check)
+                               return true;
+
+                       requires_delayed_unmanagedtype_check = true;
 
                        foreach (FieldBase f in fields) {
                                if (f.IsStatic)
@@ -2547,19 +2561,18 @@ namespace Mono.CSharp {
                                // struct S { S* s; }
                                TypeSpec mt = f.MemberType;
                                if (mt == null) {
-                                       has_unmanaged_check_done = false;
-                                       requires_delayed_unmanagedtype_check = true;
                                        return true;
                                }
 
-                               // TODO: Remove when pointer types are under mcs control
                                while (mt.IsPointer)
                                        mt = TypeManager.GetElementType (mt);
 
                                if (mt.MemberDefinition == this) {
                                        for (var p = Parent; p != null; p = p.Parent) {
-                                               if (p.Kind == MemberKind.Class)
+                                               if (p.Kind == MemberKind.Class) {
+                                                       has_unmanaged_check_done = true;
                                                        return false;
+                                               }
                                        }
                                        continue;
                                }
@@ -2567,9 +2580,11 @@ namespace Mono.CSharp {
                                if (TypeManager.IsUnmanagedType (mt))
                                        continue;
 
+                               has_unmanaged_check_done = true;
                                return false;
                        }
 
+                       has_unmanaged_check_done = true;
                        is_unmanaged = true;
                        return true;
                }