[Mono-bugs] [Bug 607702] New: Select<> requires explicit type arguments by MCS - CSC does not.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu May 20 17:26:15 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=607702

http://bugzilla.novell.com/show_bug.cgi?id=607702#c0


           Summary: Select<> requires explicit type arguments by MCS - CSC
                    does not.
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.6.x
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ohh at scisoft.dk
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.2.3)
Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729; .NET4.0E)

When doing a Link.Select<> over a type that inherits from from IEnumerable<T>,
MCS fails with an error telling me to give explicit type parameters to Select.
CSC does not require the explicit type parameters but can infer them.

Try to compile the example as described below. It works without change on CSC
(only tested with VS.NET 2010). It can be made to work by either chainging the
type constraint or giving explicit type parameters, as described in the example
below.

Reproducible: Always

Steps to Reproduce:
-bash-4.0$ cat test.cs
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    public interface IMyEnum<T> : IEnumerable<T>
    {
    }

        public class MainClass {
                public static void Main ()
                {
                }
        }

    public class Generic<LT, CT>
        where CT: IMyEnum<LT>

        // It works if this constraint is used instead.
        //where CT: IEnumerable<LT>
    {
            public static void DoTest(CT testEnum)
            {
                var selected = testEnum.Select(C => false);

                // It also works if the type parameters are explicit:
                // var selected = testEnum.Select<LT, bool> (C => false);
            }
    }
}

-bash-4.0$ mcs test.cs

Actual Results:  
test.cs(24,41): error CS0411: The type arguments for method
`System.Linq.Enumerable.Select<TSource,TResult>(this
System.Collections.Generic.IEnumerable<TSource>,
System.Func<TSource,int,TResult>)' cannot be inferred from the usage. Try
specifying the type arguments explicitly
Compilation failed: 1 error(s), 0 warnings


Expected Results:  
I expected the problem to compile (perhaps with a warning saying that
"selected" is unused).

-- 
Configure bugmail: http://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