From: Sebastien Pouliot Date: Sun, 17 Jul 2011 20:35:15 +0000 (-0400) Subject: Avoid using PredicateOf.Always since it does not work with full-aot. Fix bug ... X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=87f45773c0f18514941e9ea15eb6c98f4bc2ac2d;p=mono.git Avoid using PredicateOf.Always since it does not work with full-aot. Fix bug #682757... --- diff --git a/mcs/class/System.Core/System.Linq/Enumerable.cs b/mcs/class/System.Core/System.Linq/Enumerable.cs index 0f9b717b4af..0dcdb6d8191 100644 --- a/mcs/class/System.Core/System.Linq/Enumerable.cs +++ b/mcs/class/System.Core/System.Linq/Enumerable.cs @@ -45,9 +45,11 @@ namespace System.Linq Throw } +#if !FULL_AOT_RUNTIME static class PredicateOf { public static readonly Func Always = (t) => true; } +#endif static class Function { public static readonly Func Identity = (t) => t; @@ -849,7 +851,11 @@ namespace System.Linq { Check.Source (source); +#if !FULL_AOT_RUNTIME return source.First (PredicateOf.Always, Fallback.Default); +#else + return source.First (delegate { return true; }, Fallback.Default); +#endif } public static TSource FirstOrDefault (this IEnumerable source, Func predicate) @@ -1208,7 +1214,11 @@ namespace System.Linq if (list != null) return list [list.Count - 1]; +#if !FULL_AOT_RUNTIME return source.Last (PredicateOf.Always, Fallback.Throw); +#else + return source.Last (delegate { return true; }, Fallback.Throw); +#endif } public static TSource Last (this IEnumerable source, Func predicate) @@ -1230,7 +1240,11 @@ namespace System.Linq if (list != null) return list.Count > 0 ? list [list.Count - 1] : default (TSource); +#if !FULL_AOT_RUNTIME return source.Last (PredicateOf.Always, Fallback.Default); +#else + return source.Last (delegate { return true; }, Fallback.Default); +#endif } public static TSource LastOrDefault (this IEnumerable source, Func predicate) @@ -2343,7 +2357,11 @@ namespace System.Linq { Check.Source (source); +#if !FULL_AOT_RUNTIME return source.Single (PredicateOf.Always, Fallback.Throw); +#else + return source.Single (delegate { return true; }, Fallback.Throw); +#endif } public static TSource Single (this IEnumerable source, Func predicate) @@ -2361,7 +2379,11 @@ namespace System.Linq { Check.Source (source); +#if !FULL_AOT_RUNTIME return source.Single (PredicateOf.Always, Fallback.Default); +#else + return source.Single (delegate { return true; }, Fallback.Default); +#endif } public static TSource SingleOrDefault (this IEnumerable source, Func predicate)