From d900315aeba415231ca22566f2c9628f4afdc2e6 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 7 Oct 2010 15:26:00 +0100 Subject: [PATCH] [644507] Don't use nested type cache until declaring type is setup. --- mcs/mcs/import.cs | 24 ++++++++++++++++++++---- mcs/tests/gtest-451-lib.cs | 20 ++++++++++++++++++++ mcs/tests/gtest-451.cs | 10 ++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 mcs/tests/gtest-451-lib.cs create mode 100644 mcs/tests/gtest-451.cs diff --git a/mcs/mcs/import.cs b/mcs/mcs/import.cs index 744cbfff68d..5a06e8ff3c9 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 00000000000..6eba31f02b0 --- /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 00000000000..d9939112814 --- /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 (); + } +} -- GitLab