File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/libraries/System.Linq/src/System/Linq Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,19 @@ public static IEnumerable<TResult> Select<TSource, TResult>(
25
25
26
26
if ( source is Iterator < TSource > iterator )
27
27
{
28
- return iterator . Select ( selector ) ;
28
+ // With native AOT, calling into the `Select` generic virtual method results in NxM
29
+ // expansion of native code. If the option is enabled, we don't call the generic virtual
30
+ // for value types. We don't do the same for reference types because reference type
31
+ // expansion can happen lazily at runtime and the AOT compiler does postpone it (we
32
+ // don't need more code, just more data structures describing the new types).
33
+ if ( IsSizeOptimized && typeof ( TResult ) . IsValueType )
34
+ {
35
+ return new IEnumerableSelectIterator < TSource , TResult > ( iterator , selector ) ;
36
+ }
37
+ else
38
+ {
39
+ return iterator . Select ( selector ) ;
40
+ }
29
41
}
30
42
31
43
if ( source is IList < TSource > ilist )
You can’t perform that action at this time.
0 commit comments