Bug 523899

Summary: GMCS fails to resolve generic types when using Nullable enums - regression
Product: [Mono] Mono: Compilers Reporter: Thomas Philpot <tom.philpot>
Component: C#Assignee: Mono Bugs <mono-bugs>
Status: RESOLVED FIXED QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None    
Version: SVN   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X 10.5   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Thomas Philpot 2009-07-21 16:06:37 UTC
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1

using System;
using System.Collections.Generic;
 
namespace Test
{
   public enum Enum
   {
      One,
      Two
   }
 
   class CompilerTest
   {
 
      public static void Main(string[] s) {
         ThisDoesNotWork();
      }
 
      protected static int DoSomething<T>(string s, T t, ref T t2)
      {
         Console.WriteLine("s={0}", s);
         Console.WriteLine("t={0}", t.ToString());
         Console.WriteLine("t2={0}", t2.ToString());
 
         t2 = default(T);
 
         return 0;
      }
 
      // .NET 3.5 infers Enum? from T, Mono is confused
      public static void ThisDoesNotWork()
      {
         // Nullable does not work
         Enum? e = Enum.One;
         DoSomething("abc", Enum.Two, ref e);
      }
 
      public static void ThisWorksFine()
      {
         Enum e = Enum.Two;
         DoSomething("abc", Enum.Two, ref e);
         Console.WriteLine("e={0}", e.ToString());
      }
   }
}

Reproducible: Always

Steps to Reproduce:
1. Try to compile the above code with gmcs (r138189)

Actual Results:  
CompilerTest2.cs(35,10): error CS0411: The type arguments for method `Test.CompilerTest.DoSomething<T>(string, T, ref T)' cannot be inferred from the usage. Try specifying the type arguments explicitly


Expected Results:  
Should compile.

This can be worked around by explictly specifying <Enum?> as the type.
Comment 1 Marek Safar 2009-07-22 14:26:16 UTC
Fixed in trunk.
Comment 2 Marek Safar 2009-07-22 14:29:13 UTC
*** Bug 523967 has been marked as a duplicate of this bug. ***