Bug 316495 (MONO69727) - [GMCS]: gmcs generates null reference error with misplaced new() constraint
Summary: [GMCS]: gmcs generates null reference error with misplaced new() constraint
Status: RESOLVED FIXED
Alias: MONO69727
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Red Hat 9.0
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-20 01:37 UTC by Ben Martin
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:18 UTC


---- Reported by benmartin@fourthplanet.net 2004-11-19 18:37:38 MST ----

When compiling this code:

using System;

class A<T>
        where T: new(), IComparable
{
}

class B<U,V>
        where V: A<U>
{
}

class Driver
{
        public static void Main ()
        {
                A<int> a_int;
                B<int,A<int>> b_stuff;
        }
}


gmcs does this:

ALPHA SOFTWARE: Mono C# Compiler 1.1.2.0 for Generics
gmcs_error.cs(5) error CS0401: The new() constraint must be last.

Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
in <0x00085> Mono.CSharp.DeclSpace:CheckAccessLevel (System.Type)
in <0x00085> Mono.CSharp.Namespace:Lookup
(Mono.CSharp.DeclSpace,string,Mono.CSharp.Location)
in <0x001df> Mono.CSharp.NamespaceEntry:Lookup
(Mono.CSharp.DeclSpace,string,int,bool,Mono.CSharp.Location)
in <0x00038> Mono.CSharp.RootContext:NamespaceLookup
(Mono.CSharp.DeclSpace,string,int,Mono.CSharp.Location)
in <0x0013d> Mono.CSharp.RootContext:LookupType
(Mono.CSharp.DeclSpace,string,bool,int,Mono.CSharp.Location)
in <0x00018> Mono.CSharp.RootContext:LookupType
(Mono.CSharp.DeclSpace,string,bool,Mono.CSharp.Location)
in <0x001cf> Mono.CSharp.SimpleName:ResolveAsTypeStep (Mono.CSharp.EmitContext)
in <0x0001f> Mono.CSharp.Expression:ResolveAsTypeTerminal
(Mono.CSharp.EmitContext)
in <0x00203> Mono.CSharp.ConstructedType:ResolveConstructedType
(Mono.CSharp.EmitContext)
in <0x002f8> Mono.CSharp.Constraints:Resolve (Mono.CSharp.EmitContext)
in <0x00031> Mono.CSharp.TypeParameter:Resolve (Mono.CSharp.DeclSpace)
in <0x0056d> Mono.CSharp.TypeContainer:DefineType ()
in <0x003ea> Mono.CSharp.RootContext:ResolveTree ()
in <0x00c08> Mono.CSharp.Driver:MainDriver (string[])
in <0x0001f> Mono.CSharp.Driver:Main (string[])

(If the class B<U,V> is taken out the above code is handled without the
compiler crashing.)



---- Additional Comments From martin@ximian.com 2004-12-08 14:18:01 MST ----

Fixed.