diff options
author | Marek Safar <marek.safar@gmail.com> | 2013-03-15 18:25:25 +0400 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2013-03-15 18:28:49 +0400 |
commit | 663861741f78f9f0c3ace703ce0201122a60b92f (patch) | |
tree | c95f9daf9689d77c3a6736659e0d6edcffd09fe9 /mcs/tests/gtest-lambda-31.cs | |
parent | f2f0ea3f3b5b612e742a02d150e64abff83fd5be (diff) |
Implement optimization where lambdas can be replaced by direct method-group they are wrapping. Fixes #10663
Diffstat (limited to 'mcs/tests/gtest-lambda-31.cs')
-rw-r--r-- | mcs/tests/gtest-lambda-31.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/mcs/tests/gtest-lambda-31.cs b/mcs/tests/gtest-lambda-31.cs new file mode 100644 index 00000000000..8836a96e00b --- /dev/null +++ b/mcs/tests/gtest-lambda-31.cs @@ -0,0 +1,42 @@ +// Compiler options: -optimize + +// Check lambdas to method group optimization, no lambdas should be created for any code int this test + +using System; +using System.Collections; +using System.Linq; + +class Test +{ + static int Prop { + get { + return 4; + } + } + + public static int Main () + { + var parsed = from t in new[] { "2" } select int.Parse (t); + if (parsed.First () != 2) + return 1; + + var s = new string[] { "x", "a" }; + Array.Sort (s, (a, b) => String.Compare (a, b)); + if (s[0] != "a") + return 10; + + if (s[1] != "x") + return 11; + + Func<int> i = () => Prop; + if (i () != 4) + return 20; + + var em = new IEnumerable[] { new int[] { 1 } }.Select (l => l.Cast<int> ()).First ().First (); + if (em != 1) + return 30; + + Console.WriteLine ("ok"); + return 0; + } +}
\ No newline at end of file |