[Mono-bugs] [Bug 476811] New: [Regression] Type inference fails on generic methods when passing default(SomeType) or (SomeType)null if "SomeType" is a referenceType

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Feb 17 18:56:01 EST 2009


           Summary: [Regression] Type inference fails on generic methods
                    when passing default(SomeType) or (SomeType)null if
                    "SomeType" is a referenceType
    Classification: Mono
           Product: Mono: Compilers
           Version: SVN
          Platform: Macintosh
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: dmitchell at logos.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us)
AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1

Here's some code:


using System;

namespace MonoBug
    public static class Stuff
        public static GenericStuff<T1, T2> CreateThing<T1, T2>(T1 firstValue,
T2 secondValue)
            return new GenericStuff<T1, T2>(firstValue, secondValue);

    public class GenericStuff<T1, T2>
        public readonly T1 FirstValue;
        public readonly T2 SecondValue;

        public GenericStuff(T1 firstValue, T2 secondValue)
            FirstValue = firstValue;
            SecondValue = secondValue;

    public static class Program
        public static void Main(string[] arguments)
            var thing = Stuff.CreateThing(default(string), "abc");


This code would compile/run under Mono 2.2, but it does not compile under Mono

Reproducible: Always

Steps to Reproduce:
1. Put the code included above into a file
2. Attempt to compile with a copy of gmcs.exe compiled from svn
Actual Results:  
The compiler reports error CS0411 for the call to CreateThings

Expected Results:  
The compiler should compile the program.

Instead of "default(string)", you can also try one of these:

- (string)null -- doesn't compile
- default(int) -- compiles
- default(int?) -- compiles
- (int?)null -- compiles

Declaring a new variable of a reference type, setting it to null, and passing
it into CreateThings also works as expected.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list