diff --git a/mcs/mcs/import.cs b/mcs/mcs/import.cs index 744cbfff68d7d8d75b04635c8d56b1c7d6599157..5a06e8ff3c9a8c37cd3dc274378c13021e86d852 100644 --- a/mcs/mcs/import.cs +++ b/mcs/mcs/import.cs @@ -652,7 +652,25 @@ namespace Mono.CSharp import_cache.Add (type, spec); - if (kind == MemberKind.Interface) + // + // Two stage setup as the base type can be inflated declaring type + // + if (declaringType == null) + ImportTypeBase (spec, type); + + return spec; + } + + public void ImportTypeBase (Type type) + { + TypeSpec spec = import_cache[type]; + if (spec != null) + ImportTypeBase (spec, type); + } + + void ImportTypeBase (TypeSpec spec, Type type) + { + if (spec.Kind == MemberKind.Interface) spec.BaseType = TypeManager.object_type; else if (type.BaseType != null) spec.BaseType = CreateType (type.BaseType); @@ -663,8 +681,6 @@ namespace Mono.CSharp spec.AddInterface (CreateType (iface)); } } - - return spec; } TypeParameterSpec CreateTypeParameter (Type type, TypeSpec declaringType) @@ -1353,7 +1369,7 @@ namespace Mono.CSharp break; case MemberTypes.NestedType: - // Already done + meta_import.ImportTypeBase ((Type) member); continue; default: throw new NotImplementedException (member.ToString ()); diff --git a/mcs/tests/gtest-451-lib.cs b/mcs/tests/gtest-451-lib.cs new file mode 100644 index 0000000000000000000000000000000000000000..6eba31f02b049f675509955c74d1eb7c0c73f658 --- /dev/null +++ b/mcs/tests/gtest-451-lib.cs @@ -0,0 +1,20 @@ +// Compiler options: -t:library + +using System; + +public class A where T : new () +{ + public T Value = new T (); + + public class N1 : A + { + } + + public class N2 + { + public int Foo () + { + return 0; + } + } +} \ No newline at end of file diff --git a/mcs/tests/gtest-451.cs b/mcs/tests/gtest-451.cs new file mode 100644 index 0000000000000000000000000000000000000000..d993911281478c194ab57921e97eebc7b8af8d31 --- /dev/null +++ b/mcs/tests/gtest-451.cs @@ -0,0 +1,10 @@ +// Compiler options: -r:gtest-451-lib.dll + +public class Test +{ + public static int Main () + { + var a = new A.N1 (); + return a.Value.Foo (); + } +}