Loading of nested type of missing type needs to create another missing type. Fixes...
authorMarek Safar <marek.safar@gmail.com>
Wed, 3 Jul 2013 15:38:13 +0000 (17:38 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 3 Jul 2013 15:39:50 +0000 (17:39 +0200)
mcs/errors/CS0012-21-lib.il [new file with mode: 0644]
mcs/errors/Makefile
mcs/errors/cs0012-21.cs [new file with mode: 0644]
mcs/mcs/import.cs

diff --git a/mcs/errors/CS0012-21-lib.il b/mcs/errors/CS0012-21-lib.il
new file mode 100644 (file)
index 0000000..b01f464
--- /dev/null
@@ -0,0 +1,31 @@
+.assembly extern mscorlib
+{
+}
+
+.assembly extern 'CS0012-lib-missing'
+{
+}
+
+.assembly 'CS0012-21-lib'
+{
+  .hash algorithm 0x00008004
+  .ver 0:0:0:0
+}
+
+.module 'CS0012-21-lib.dll'
+
+
+.class public auto ansi beforefieldinit B
+       extends class ['CS0012-lib-missing']X`1/Y/Z/W<int32>
+{
+  .method public hidebysig specialname rtspecialname 
+          instance void  .ctor() cil managed
+  {
+    // Code size       7 (0x7)
+    .maxstack  8
+    IL_0000:  ldarg.0
+    IL_0001:  call       instance void class ['CS0012-lib-missing']X`1/Y/Z/W<int32>::.ctor()
+    IL_0006:  ret
+  }
+
+}
index fccf2d93aa3d1102d3899a2e6e020c1c72acf50e..756d130359a64a00c933e61a0301bee7edac65d2 100644 (file)
@@ -21,7 +21,7 @@ DISTFILES = \
        $(wildcard dlls/second/*.cs)
 
 TEST_SUPPORT_FILES = \
-       CS0012-lib.dll CS0012-2-lib.dll CS0012-3-lib.dll CS0012-4-lib.dll CS0012-5-lib.dll CS0012-6-lib.dll CS0012-9-lib.dll CS0012-10-lib.dll CS0012-11-lib.dll CS0012-12-lib.dll CS0012-13-lib.dll CS0012-14-lib.dll CS0012-15-lib.dll CS0012-16-lib.dll CS0012-17-lib.dll CS0012-18-lib.dll CS0029-26-lib.dll \
+       CS0012-lib.dll CS0012-2-lib.dll CS0012-3-lib.dll CS0012-4-lib.dll CS0012-5-lib.dll CS0012-6-lib.dll CS0012-9-lib.dll CS0012-10-lib.dll CS0012-11-lib.dll CS0012-12-lib.dll CS0012-13-lib.dll CS0012-14-lib.dll CS0012-15-lib.dll CS0012-16-lib.dll CS0012-17-lib.dll CS0012-18-lib.dll CS0012-21-lib.dll CS0029-26-lib.dll \
        CS0103-2-lib.dll CS0118-2-lib.dll CS0122-8-lib.dll CS0122-10-lib.dll CS0122-14-lib.dll CS0122-15-lib.dll CS0122-19-lib.dll CS0122-35-lib.dll CS0122-36-lib.dll CS0143-lib.dll CS0144-3-lib.dll CS0165-19-lib.dll \
        CS0205-3-lib.dll CS0229-3-lib.dll CS0229-4-lib.dll CS0266-25-lib.dll \
        CS0315-2-lib.dll \
diff --git a/mcs/errors/cs0012-21.cs b/mcs/errors/cs0012-21.cs
new file mode 100644 (file)
index 0000000..f313e2a
--- /dev/null
@@ -0,0 +1,11 @@
+// CS0012: The type `X`1.Y.Z.W' is defined in an assembly that is not referenced. Consider adding a reference to assembly `CS0012-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
+// Line: 9
+// Compiler options: -r:CS0012-21-lib.dll
+
+public class C
+{
+       public static void Main ()
+       {
+               new B ();
+       }
+}
\ No newline at end of file
index 35d32c1d11643fd948721584b4d95282174cf297..3576f28a7b72c92d5a159fdb0cf163ed0e719a68 100644 (file)
@@ -774,24 +774,34 @@ namespace Mono.CSharp
 
                                        for (int i = nested_hierarchy.Count; i != 0; --i) {
                                                var t = nested_hierarchy [i - 1];
-                                               spec = MemberCache.FindNestedType (spec, t.Name, t.Arity);
+                                               if (t.Kind == MemberKind.MissingType)
+                                                       spec = t;
+                                               else
+                                                       spec = MemberCache.FindNestedType (spec, t.Name, t.Arity);
+
                                                if (t.Arity > 0) {
                                                        spec = spec.MakeGenericType (module, targs.Skip (targs_pos).Take (spec.Arity).ToArray ());
                                                        targs_pos += t.Arity;
                                                }
                                        }
 
-                                       string name = type.Name;
-                                       int index = name.IndexOf ('`');
-                                       if (index > 0)
-                                               name = name.Substring (0, index);
+                                       if (spec.Kind == MemberKind.MissingType) {
+                                               spec = new TypeSpec (MemberKind.MissingType, spec, new ImportedTypeDefinition (type_def, this), type_def, Modifiers.PUBLIC);
+                                               spec.MemberCache = MemberCache.Empty;
+                                       } else {
+                                               if ((type_def.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && IgnorePrivateMembers)
+                                                       return null;
+
+                                               string name = type.Name;
+                                               int index = name.IndexOf ('`');
+                                               if (index > 0)
+                                                       name = name.Substring (0, index);
 
-                                       spec = MemberCache.FindNestedType (spec, name, targs.Length - targs_pos);
-                                       if (spec == null)
-                                               return null;
+                                               spec = MemberCache.FindNestedType (spec, name, targs.Length - targs_pos);
 
-                                       if (spec.Arity > 0) {
-                                               spec = spec.MakeGenericType (module, targs.Skip (targs_pos).ToArray ());
+                                               if (spec.Arity > 0) {
+                                                       spec = spec.MakeGenericType (module, targs.Skip (targs_pos).ToArray ());
+                                               }
                                        }
                                }