Merge pull request #3626 from lateralusX/jlorenss/win-api-family-support-eglib
[mono.git] / mcs / class / corlib / System.Reflection.Emit / ModuleBuilder.cs
index d6c39114f16ef3da670dd957008a1c592b08af79..8d485153e38157f892cea66037eb53e78e76057a 100644 (file)
@@ -348,9 +348,6 @@ namespace System.Reflection.Emit {
                        return null;
                }
 
-               [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private static extern Type create_modified_type (TypeBuilder tb, string modifiers);
-
                private TypeBuilder GetMaybeNested (TypeBuilder t, IEnumerable<TypeName> nested) {
                        TypeBuilder result = t;
 
@@ -392,8 +389,27 @@ namespace System.Reflection.Emit {
                        if ((result == null) && throwOnError)
                                throw new TypeLoadException (className);
                        if (result != null && (ts.HasModifiers || ts.IsByRef)) {
-                               string modifiers = ts.ModifierString ();
-                               Type mt = create_modified_type (result, modifiers);
+                               Type mt = result;
+                               if (result is TypeBuilder) {
+                                       var tb = result as TypeBuilder;
+                                       if (tb.is_created)
+                                               mt = tb.CreateType ();
+                               }
+                               foreach (var mod in ts.Modifiers) {
+                                       if (mod is PointerSpec)
+                                               mt = mt.MakePointerType ();
+                                       else if (mod is ArraySpec) {
+                                               var spec = mod as ArraySpec;
+                                               if (spec.IsBound)
+                                                       return null;
+                                               if (spec.Rank == 1)
+                                                       mt = mt.MakeArrayType ();
+                                               else
+                                                       mt = mt.MakeArrayType (spec.Rank);
+                                       }
+                               }
+                               if (ts.IsByRef)
+                                       mt = mt.MakeByRefType ();
                                result = mt as TypeBuilder;
                                if (result == null)
                                        return mt;