[mcs] Make primary constructor body parsing more error resilient
[mono.git] / mcs / mcs / import.cs
index 212acee844f9367e71624472f905495465e96c97..b8c5832d21d8088f5e88c294d25cdf3a5449ea55 100644 (file)
@@ -190,6 +190,12 @@ namespace Mono.CSharp
 
                        try {
                                field_type = ImportType (fi.FieldType, new DynamicTypeReader (fi));
+
+                               //
+                               // Private field has private type which is not fixed buffer
+                               //
+                               if (field_type == null)
+                                       return null;
                        } catch (Exception e) {
                                // TODO: I should construct fake TypeSpec based on TypeRef signature
                                // but there is no way to do it with System.Reflection
@@ -340,6 +346,9 @@ namespace Mono.CSharp
                                        }
                                }
 
+                               if (spec == null)
+                                       return null;
+
                                ++dtype.Position;
                                tspec[index] = spec;
                        }
@@ -425,6 +434,8 @@ namespace Mono.CSharp
                                                else
                                                        mod |= Modifiers.VIRTUAL;
                                        }
+                               } else if (parameters.HasExtensionMethodType) {
+                                       mod |= Modifiers.METHOD_EXTENSION;
                                }
                        }
 
@@ -756,6 +767,8 @@ namespace Mono.CSharp
                                        return spec;
 
                                var targs = CreateGenericArguments (0, type.GetGenericArguments (), dtype);
+                               if (targs == null)
+                                       return null;
                                if (declaringType == null) {
                                        // Simple case, no nesting
                                        spec = CreateType (type_def, null, new DynamicTypeReader (), canImportBaseType);