@@ -601,17 +601,12 @@ public object[] GetArrayOfConstantsAndNestedLambdas()
601
601
for ( var i = 0 ; i < nestedLambdas . Length ; i ++ )
602
602
{
603
603
var nestedLambda = nestedLambdas [ i ] ;
604
- if ( nestedLambda . ClosureInfo . NonPassedParameters . Length == 0 )
604
+ if ( nestedLambda . ClosureInfo . NonPassedParameters . Length == 0 ||
605
+ nestedLambda . ClosureInfo . ContainsConstantsOrNestedLambdas ( ) == false )
605
606
nestedLambdaItems [ i ] = nestedLambda . Lambda ;
606
607
else
607
- {
608
- var nestedConstantsAndNestedLambdas = nestedLambda . ClosureInfo . GetArrayOfConstantsAndNestedLambdas ( ) ;
609
- if ( nestedConstantsAndNestedLambdas != null )
610
- nestedLambdaItems [ i ] = new NestedLambdaWithConstantsAndNestedLambdas ( nestedLambda . Lambda ,
611
- nestedConstantsAndNestedLambdas ) ;
612
- else
613
- nestedLambdaItems [ i ] = nestedLambda . Lambda ;
614
- }
608
+ nestedLambdaItems [ i ] = new NestedLambdaWithConstantsAndNestedLambdas (
609
+ nestedLambda . Lambda , nestedLambda . ClosureInfo . GetArrayOfConstantsAndNestedLambdas ( ) ) ;
615
610
}
616
611
617
612
return nestedLambdaItems ;
@@ -643,17 +638,12 @@ public object[] GetArrayOfConstantsAndNestedLambdas()
643
638
for ( var i = 0 ; i < nestedLambdas . Length ; i ++ )
644
639
{
645
640
var nestedLambda = nestedLambdas [ i ] ;
646
- if ( nestedLambda . ClosureInfo . NonPassedParameters . Length == 0 )
641
+ if ( nestedLambda . ClosureInfo . NonPassedParameters . Length == 0 ||
642
+ nestedLambda . ClosureInfo . ContainsConstantsOrNestedLambdas ( ) == false )
647
643
closureItems [ constCount + i ] = nestedLambda . Lambda ;
648
644
else
649
- {
650
- var nestedConstantsAndNestedLambdas = nestedLambda . ClosureInfo . GetArrayOfConstantsAndNestedLambdas ( ) ;
651
- if ( nestedConstantsAndNestedLambdas != null )
652
- closureItems [ constCount + i ] = new NestedLambdaWithConstantsAndNestedLambdas (
653
- nestedLambda . Lambda , nestedConstantsAndNestedLambdas ) ;
654
- else
655
- closureItems [ constCount + i ] = nestedLambda . Lambda ;
656
- }
645
+ closureItems [ constCount + i ] = new NestedLambdaWithConstantsAndNestedLambdas (
646
+ nestedLambda . Lambda , nestedLambda . ClosureInfo . GetArrayOfConstantsAndNestedLambdas ( ) ) ;
657
647
}
658
648
659
649
return closureItems ;
@@ -1365,7 +1355,8 @@ private static bool TryCompileNestedLambda(ref ClosureInfo outerClosureInfo, int
1365
1355
1366
1356
var il = method . GetILGenerator ( ) ;
1367
1357
1368
- if ( ( nestedClosureInfo . Status & ClosureStatus . HasClosure ) != 0 && nestedClosureInfo . ContainsConstantsOrNestedLambdas ( ) )
1358
+ if ( ( nestedClosureInfo . Status & ClosureStatus . HasClosure ) != 0 &&
1359
+ nestedClosureInfo . ContainsConstantsOrNestedLambdas ( ) )
1369
1360
EmittingVisitor . EmitLoadConstantsAndNestedLambdasIntoVars ( il , ref nestedClosureInfo ) ;
1370
1361
1371
1362
var parentFlags = nestedReturnType == typeof ( void ) ? ParentFlags . IgnoreResult : ParentFlags . Empty ;
0 commit comments