diff options
author | Alexander Kyte <alexmkyte@gmail.com> | 2017-04-18 20:01:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 20:01:27 +0300 |
commit | b4df5611cb843dee33e9dcfacaa68ea3b42a799e (patch) | |
tree | 4c59da2d8721093555d06e03fdf0de755628fbbb /mcs | |
parent | 20e00bd15b52e9cf5b7fdd07b39be81d093978dc (diff) | |
parent | a8dfce54660780a583baf1eca4968eb1712102ce (diff) |
Merge pull request #4712 from alexanderkyte/master-circular-fix
[runtime] Fix circular types in SRE
Diffstat (limited to 'mcs')
3 files changed, 37 insertions, 0 deletions
diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs index b055797bd86..c000b1eadc1 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs @@ -62,6 +62,7 @@ namespace System.Reflection.Emit { private FieldBuilder[] global_fields; bool is_main; private MonoResource[] resources; + private IntPtr unparented_classes; #endregion #pragma warning restore 169, 414 diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs index 30ae09cdf16..b1cc9727d5a 100644 --- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs @@ -79,6 +79,7 @@ namespace System.Reflection.Emit private GenericTypeParameterBuilder[] generic_params; private RefEmitPermissionSet[] permissions; private TypeInfo created; + private int state; #endregion #pragma warning restore 169 diff --git a/mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs b/mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs index 94cfff6e2fd..f66c6c1ee4b 100644 --- a/mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs +++ b/mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs @@ -11189,6 +11189,41 @@ namespace MonoTests.System.Reflection.Emit Assert.IsNotNull (ins4); } + [Test] + public void CircularReferences () { + // A: C<D<A>> + var a_type = module.DefineType( + "A", + TypeAttributes.Class, + typeof(object)); + + var cba = a_type.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes); + cba.GetILGenerator ().Emit (OpCodes.Ret); + + var c_type = module.DefineType( + "B", + TypeAttributes.Class, + typeof(object)); + var cbb = c_type.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes); + cbb.GetILGenerator ().Emit (OpCodes.Ret); + c_type.DefineGenericParameters ("d_a_param"); + + var d_type = module.DefineType( + "D", + TypeAttributes.Class, + typeof(object)); + var cbd = d_type.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes); + cbd.GetILGenerator ().Emit (OpCodes.Ret); + d_type.DefineGenericParameters ("a_param"); + + + var d_instantiated = c_type.MakeGenericType (d_type.MakeGenericType (a_type)); + a_type.SetParent (d_instantiated); + a_type.CreateType (); + + Assert.IsNotNull (a_type); + } + // #22059 [Test] [ExpectedException (typeof (TypeLoadException))] |