[Mono-bugs] [Bug 69781][Wis] New - InvalidOperationException when compiling generic class implementing interface

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 21 Nov 2004 17:42:00 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by nazgul@omega.pl.

http://bugzilla.ximian.com/show_bug.cgi?id=69781

--- shadow/69781	2004-11-21 17:42:00.000000000 -0500
+++ shadow/69781.tmp.3182	2004-11-21 17:42:00.000000000 -0500
@@ -0,0 +1,109 @@
+Bug#: 69781
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: nazgul@omega.pl               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: InvalidOperationException when compiling generic class implementing interface
+
+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: