Bugzilla – Bug 316512
[GMCS] InvalidOperationException when compiling generic class implementing interface
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by nazgul@omega.pl 2004-11-21 17:42:00 MST ---- Description of Problem: I've tried running the example from http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=ee76a341-b5f2-4b45-a6f8-a0c3dc669a52. It compiles in 1.0.4, but fails at runtime. On current svn gmcs throws an exception Steps to reproduce the problem: 1. gmcs Program.cs using System; namespace Slow { public interface ITest { void DoNothing<T>() where T : class; } public class Test : ITest { public void DoNothing<T>() where T : class { T x = null; } } class Program { static void Main(string[] args) { const int iterations = 100000; Test test = new Test(); Console.Write("Calling Test.DoNothing<Program>() on an object reference... "); DateTime start = DateTime.Now; for (int i = 0; i < iterations; ++i) { test.DoNothing<Program>(); } DateTime end = DateTime.Now; TimeSpan duration = end - start; Console.WriteLine("Took " + duration.TotalMilliseconds + " ms."); ITest testInterface = test; Console.Write("Calling Test.DoNothing<Program>() on an interface reference... "); start = DateTime.Now; for (int i = 0; i < iterations; ++i) { testInterface.DoNothing<Program>(); } end = DateTime.Now; duration = end - start; Console.WriteLine("Took " + duration.TotalMilliseconds + " ms."); Console.ReadLine(); } } } Actual Results: ALPHA SOFTWARE: Mono C# Compiler 1.1.2.0 for Generics Unhandled Exception: System.InvalidOperationException: Operation is not valid due to the current state of the object in <0x0006f> Mono.CSharp.TypeManager:GetTypeArguments (System.Type) in <0x0004f> InflatedConstraints:.ctor (Mono.CSharp.GenericConstraints,System.Type) in <0x0014d> Mono.CSharp.TypeParameter:DefineType (Mono.CSharp.EmitContext,System.Reflection.Emit.MethodBuilder,System.Reflection.MethodInfo,bool) in <0x0004e> Mono.CSharp.GenericMethod:DefineType (Mono.CSharp.EmitContext,System.Reflection.Emit.MethodBuilder,System.Reflection.MethodInfo,bool) in <0x0059f> Mono.CSharp.MethodData:Define (Mono.CSharp.TypeContainer) in <0x00150> Mono.CSharp.Method:Define () Expected Results: Clear run with indications of timing (wonder if it has also 1000x slowdown, like in .NET 2.0 How often does this happen? always Additional Information: ---- Additional Comments From martin@ximian.com 2004-12-04 17:32:30 MST ---- Fixed in SVN. Unknown operating system unknown. Setting to default OS "Other".