Bug 323047 (MONO80358) - [GMCS] Compiler crashes with certain type of generic partial class
Summary: [GMCS] Compiler crashes with certain type of generic partial class
Status: RESOLVED FIXED
Alias: MONO80358
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Linux
: P3 - Medium : Major
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-26 01:49 UTC by Frederik Carlier
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 20:20:46 UTC


---- Reported by frederik.carlier@ugent.be 2006-12-25 18:49:33 MST ----

Description of Problem:

The compiler crashes when it encounters a special instance of a partial
class that takes a generic parameter.

This error occurs when the second part of the partial class uses a generic
Event Handler.

Steps to reproduce the problem:
1. Create a file gpartial.cs with the following contents:

## BEGIN OF FILE
using System;
using System.Windows.Forms;

namespace Test.Common
{
    partial class SectionControl<T>
    {

    }
}

namespace Test.Common
{
    public partial class SectionControl<T> : UserControl
    {
        public delegate void DrawItemEventHandler(object sender,
DrawItemEventArgs e, T item);
    }
}
## END OF FILE

Note that when swapping the two declarations, the error does not occur.

2. Compile using gmcs gpartial.cs


Actual Results:
## BEGIN OF OUTPUT
gpartial.cs(2,7): error CS0234: The type or namespace name `Windows' does
not exist in the namespace `System'. Are you missing an assembly reference?
gpartial.cs(2,1): error CS0246: The type or namespace name `Windows.Forms'
could not be found. Are you missing a using directive or an assembly reference?

Unhandled Exception: System.InvalidOperationException: Operation is not
valid due to the current state of the object
  at System.Type.GetGenericTypeDefinition () [0x00000] 
  at System.Reflection.Emit.TypeBuilder.GetGenericTypeDefinition () [0x00000] 
  at Mono.CSharp.TypeManager.IsEqual (System.Type a, System.Type b) [0x00000] 
  at Mono.CSharp.TypeManager.IsNestedChildOf (System.Type type, System.Type
parent) [0x00000] 
  at Mono.CSharp.SimpleName.IsNestedChild (System.Type t, System.Type
parent) [0x00000] 
  at Mono.CSharp.SimpleName.ResolveNested (IResolveContext ec, System.Type
t) [0x00000] 
  at Mono.CSharp.SimpleName.ResolveAsTypeStep (IResolveContext ec, Boolean
silent) [0x00000] 
  at Mono.CSharp.Expression.ResolveAsBaseTerminal (IResolveContext ec,
Boolean silent) [0x00000] 
  at Mono.CSharp.Expression.ResolveAsTypeTerminal (IResolveContext ec,
Boolean silent) [0x00000] 
  at Mono.CSharp.Delegate.DefineType () [0x00000] 
  at Mono.CSharp.TypeContainer.DefineNestedTypes () [0x00000] 
  at Mono.CSharp.TypeContainer.DefineType () [0x00000] 
  at Mono.CSharp.Class.DefineType () [0x00000] 
  at Mono.CSharp.RootContext.ResolveTree () [0x00000] 
  at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000] 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] 
## END OF OUTPUT

Expected Results:
No error to occur.

How often does this happen? 
Always.

Additional Information:
This example is based on code generated by Visual Studio that compiles file
under .NET.



---- Additional Comments From frederik.carlier@ugent.be 2006-12-25 19:08:52 MST ----

This actually blocks my migration to Mono.



---- Additional Comments From frederik.carlier@ugent.be 2006-12-26 08:51:24 MST ----

I just reproduced this bug on SuSe Linux 9.2:

frederik@inwdesk1:~/monobug> cat /etc/SuSE-release 
SuSE Linux 9.2 (i586)
VERSION = 9.2
frederik@inwdesk1:~/monobug> mono --version
Mono JIT compiler version 1.2.2.1, (C) 2002-2006 Novell, Inc and
Contributors. www.mono-project.com
        TLS:           normal
        GC:            Included Boehm (with typed GC)
        SIGSEGV:       normal
        Disabled:      none
frederik@inwdesk1:~/monobug> gmcs --version
Mono C# compiler version 1.2.2.1
frederik@inwdesk1:~/monobug> gmcs gpartial.cs 
gpartial.cs(2,14): error CS0234: The type or namespace name `Windows'
does not exist in the namespace `System'. Are you missing an assembly
reference?
gpartial.cs(2,1): error CS0246: The type or namespace name
`Windows.Forms' could not be found. Are you missing a using directive
or an assembly reference?

Unhandled Exception: System.InvalidOperationException: Operation is
not valid due to the current state of the object
  at System.Type.GetGenericTypeDefinition () [0x00000] 
  at System.Reflection.Emit.TypeBuilder.GetGenericTypeDefinition ()
[0x00000] 
  at Mono.CSharp.TypeManager.IsEqual (System.Type a, System.Type b)
[0x00000] 
  at Mono.CSharp.TypeManager.IsNestedChildOf (System.Type type,
System.Type parent) [0x00000] 
  at Mono.CSharp.SimpleName.IsNestedChild (System.Type t, System.Type
parent) [0x00000] 
  at Mono.CSharp.SimpleName.ResolveNested (IResolveContext ec,
System.Type t) [0x00000] 
  at Mono.CSharp.SimpleName.ResolveAsTypeStep (IResolveContext ec,
Boolean silent) [0x00000] 
  at Mono.CSharp.Expression.ResolveAsBaseTerminal (IResolveContext ec,
Boolean silent) [0x00000] 
  at Mono.CSharp.Expression.ResolveAsTypeTerminal (IResolveContext ec,
Boolean silent) [0x00000] 
  at Mono.CSharp.Delegate.DefineType () [0x00000] 
  at Mono.CSharp.TypeContainer.DefineNestedTypes () [0x00000] 
  at Mono.CSharp.TypeContainer.DefineType () [0x00000] 
  at Mono.CSharp.Class.DefineType () [0x00000] 
  at Mono.CSharp.RootContext.ResolveTree () [0x00000] 
  at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000] 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] 




---- Additional Comments From rharinath@novell.com 2007-01-27 12:19:41 MST ----

Should be fixed in SVN r71790.


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Ubuntu 6.10 with Feister packages for Mono</cf_op_sys_details>