Bug 392448 - gmcs issue with lambda expression passed as delegates
Summary: gmcs issue with lambda expression passed as delegates
Status: RESOLVED DUPLICATE of bug 378189
Alias: None
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: SVN
Hardware: Other Other
: P5 - None : Normal
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-20 09:12 UTC by Jean-Baptiste Evain
Modified: 2008-07-08 15:02 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 Jean-Baptiste Evain 2008-05-20 09:12:13 UTC
Repro:

--
using System;
using System.Collections;

class Test {
	public static IList Foo (Action<IList> action)
	{
		ArrayList l = new ArrayList ();
		action (l);
		return l;
	}

	public static IList Populator (IList list, IEnumerable items)
	{
		foreach (object item in items)
			list.Add (item);

		return list;
	}

	public static void Main (string [] args)
	{
		var list = Foo (l => Populator (l, args));

		foreach (object item in list)
			Console.WriteLine (item);
	}
}
--

Fails with:

[mono] ~/Desktop @ gmcs test.cs 
test.cs(22,28): error CS1502: The best overloaded method match for `Test.Foo(System.Action<System.Collections.IList>)' has some invalid arguments
test.cs(5,29): (Location of the symbol related to previous error)
test.cs(22,28): error CS1503: Argument 1: Cannot convert type `lambda expression' to `System.Action<System.Collections.IList>'
test.cs(24,17): error CS1579: foreach statement cannot operate on variables of type `object' because it does not contain a definition for `GetEnumerator' or is not accessible

That should compile and print to stdout all arguments passed to the executable.
Comment 1 Marek Safar 2008-07-08 15:02:40 UTC

*** This bug has been marked as a duplicate of bug 378189 ***