Bug 316512 (MONO69781) - [GMCS] InvalidOperationException when compiling generic class implementing interface
Summary: [GMCS] InvalidOperationException when compiling generic class implementing in...
Status: RESOLVED FIXED
Alias: MONO69781
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-22 00:42 UTC by Kamil Skalski
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:59:29 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".