提交 797897cd 编写于 作者: P Povilas Kanapickas

[aot] Fix AOT code generation for System.Linq.Sum (case 414374)

上级 574378b1
......@@ -1845,8 +1845,12 @@ namespace System.Linq
public static int Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, int> selector)
{
Check.SourceAndSelector (source, selector);
return Sum<TSource, int> (source, (a, b) => checked (a + selector (b)));
int total = 0;
foreach (var element in source)
total = checked (total + selector (element));
return total;
}
public static int? Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, int?> selector)
......@@ -1876,8 +1880,12 @@ namespace System.Linq
public static long Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, long> selector)
{
Check.SourceAndSelector (source, selector);
return Sum<TSource, long> (source, (a, b) => checked (a + selector (b)));
long total = 0;
foreach (var element in source)
total = checked (total + selector (element));
return total;
}
public static long? Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, long?> selector)
......@@ -1907,8 +1915,12 @@ namespace System.Linq
public static double Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, double> selector)
{
Check.SourceAndSelector (source, selector);
return Sum<TSource, double> (source, (a, b) => checked (a + selector (b)));
double total = 0;
foreach (var element in source)
total = checked (total + selector (element));
return total;
}
public static double? Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, double?> selector)
......@@ -1938,8 +1950,12 @@ namespace System.Linq
public static float Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, float> selector)
{
Check.SourceAndSelector (source, selector);
return Sum<TSource, float> (source, (a, b) => checked (a + selector (b)));
float total = 0;
foreach (var element in source)
total = checked (total + selector (element));
return total;
}
public static float? Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, float?> selector)
......@@ -1969,8 +1985,12 @@ namespace System.Linq
public static decimal Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, decimal> selector)
{
Check.SourceAndSelector (source, selector);
return Sum<TSource, decimal> (source, (a, b) => checked (a + selector (b)));
decimal total = 0;
foreach (var element in source)
total = checked (total + selector (element));
return total;
}
public static decimal? Sum<TSource> (this IEnumerable<TSource> source, Func<TSource, decimal?> selector)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册