[mcs] Make primary constructor body parsing more error resilient
[mono.git] / mcs / mcs / import.cs
index 81bfc16f07494468c25222c7731a2bb460778c43..b8c5832d21d8088f5e88c294d25cdf3a5449ea55 100644 (file)
@@ -346,6 +346,9 @@ namespace Mono.CSharp
                                        }
                                }
 
+                               if (spec == null)
+                                       return null;
+
                                ++dtype.Position;
                                tspec[index] = spec;
                        }
@@ -431,6 +434,8 @@ namespace Mono.CSharp
                                                else
                                                        mod |= Modifiers.VIRTUAL;
                                        }
+                               } else if (parameters.HasExtensionMethodType) {
+                                       mod |= Modifiers.METHOD_EXTENSION;
                                }
                        }
 
@@ -762,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);