@@ -48,12 +48,12 @@ public with sharing class CollectionFunctions {
48
48
}
49
49
}
50
50
51
- private static Environment getEnvironmentFromObject (Object currentVal ) {
51
+ private static Environment getEnvironmentFromObject (Environment parentEnvironment , Object currentVal ) {
52
52
Environment env ;
53
53
if (currentVal instanceof SObject ) {
54
- env = new Environment ((SObject ) currentVal );
54
+ env = new Environment (parentEnvironment , (SObject ) currentVal );
55
55
} else {
56
- env = new Environment ();
56
+ env = new Environment (parentEnvironment );
57
57
}
58
58
return env ;
59
59
}
@@ -118,7 +118,7 @@ public with sharing class CollectionFunctions {
118
118
List <Object > result = new List <Object >();
119
119
for (Integer i = 0 ; i < childrenAsList .size (); i ++ ) {
120
120
Object child = childrenAsList .get (i );
121
- Environment env = getEnvironmentFromObject (child );
121
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), child );
122
122
env .define (' $current' , child );
123
123
env .define (' $index' , i );
124
124
env .define (' $total' , childrenAsList .size ());
@@ -170,7 +170,7 @@ public with sharing class CollectionFunctions {
170
170
List <Object > result = new List <Object >();
171
171
for (Integer i = 0 ; i < childrenAsList .size (); i ++ ) {
172
172
Object child = childrenAsList .get (i );
173
- Environment env = getEnvironmentFromObject (child );
173
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), child );
174
174
175
175
env .define (' $current' , child );
176
176
env .define (' $index' , i );
@@ -774,7 +774,7 @@ public with sharing class CollectionFunctions {
774
774
// The result of the expression will be the new value.
775
775
Object accumulator = initialValue ;
776
776
for (Object currentVal : listVal ) {
777
- Environment env = getEnvironmentFromObject (currentVal );
777
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
778
778
env .define (' $current' , currentVal );
779
779
env .define (' $accumulator' , accumulator );
780
780
Interpreter interpreter = new Interpreter (env );
@@ -902,7 +902,7 @@ public with sharing class CollectionFunctions {
902
902
// Loop through each element in the list, evaluating the
903
903
// expression with the current value (as $current) being looped.
904
904
for (Object currentVal : listVal ) {
905
- Environment env = getEnvironmentFromObject (currentVal );
905
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
906
906
env .define (' $current' , currentVal );
907
907
Interpreter interpreter = new Interpreter (env );
908
908
Object result = interpreter .interpret (expr );
@@ -999,7 +999,7 @@ public with sharing class CollectionFunctions {
999
999
// Loop through each element in the list, evaluating the
1000
1000
// expression with the current value (as $current) being looped.
1001
1001
for (Object currentVal : listVal ) {
1002
- Environment env = getEnvironmentFromObject (currentVal );
1002
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1003
1003
env .define (' $current' , currentVal );
1004
1004
Interpreter interpreter = new Interpreter (env );
1005
1005
Object result = interpreter .interpret (expr );
@@ -1059,7 +1059,7 @@ public with sharing class CollectionFunctions {
1059
1059
// expression with the current value (as $current) being looped.
1060
1060
List <Object > result = new List <Object >();
1061
1061
for (Object currentVal : listVal ) {
1062
- Environment env = getEnvironmentFromObject (currentVal );
1062
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1063
1063
env .define (' $current' , currentVal );
1064
1064
Interpreter interpreter = new Interpreter (env );
1065
1065
Object evaluated = interpreter .interpret (expr );
@@ -1118,7 +1118,7 @@ public with sharing class CollectionFunctions {
1118
1118
// Loop through each element in the list, evaluating the
1119
1119
// expression with the current value (as $current) being looped.
1120
1120
for (Object currentVal : listVal ) {
1121
- Environment env = getEnvironmentFromObject (currentVal );
1121
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1122
1122
env .define (' $current' , currentVal );
1123
1123
Interpreter interpreter = new Interpreter (env );
1124
1124
Object result = interpreter .interpret (expr );
@@ -1254,7 +1254,7 @@ public with sharing class CollectionFunctions {
1254
1254
// expression with the current value (as $current) being looped.
1255
1255
for (Integer i = listVal .size () - 1 ; i >= 0 ; i -- ) {
1256
1256
Object currentVal = listVal .get (i );
1257
- Environment env = getEnvironmentFromObject (currentVal );
1257
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1258
1258
env .define (' $current' , currentVal );
1259
1259
Interpreter interpreter = new Interpreter (env );
1260
1260
Object result = interpreter .interpret (expr );
@@ -1361,7 +1361,7 @@ public with sharing class CollectionFunctions {
1361
1361
List <Object > listVal = (List <Object >) listObj ;
1362
1362
for (Integer i = 0 ; i < listVal .size (); i ++ ) {
1363
1363
Object currentVal = listVal .get (i );
1364
- Environment env = getEnvironmentFromObject (currentVal );
1364
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1365
1365
env .define (' $current' , currentVal );
1366
1366
Interpreter interpreter = new Interpreter (env );
1367
1367
Object result = interpreter .interpret (expr );
@@ -1475,7 +1475,7 @@ public with sharing class CollectionFunctions {
1475
1475
List <Object > listVal = (List <Object >) listObj ;
1476
1476
for (Integer i = 0 ; i < listVal .size (); i ++ ) {
1477
1477
Object currentVal = listVal .get (i );
1478
- Environment env = getEnvironmentFromObject (currentVal );
1478
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1479
1479
env .define (' $current' , currentVal );
1480
1480
Interpreter interpreter = new Interpreter (env );
1481
1481
Object result = interpreter .interpret (expr );
@@ -1629,7 +1629,7 @@ public with sharing class CollectionFunctions {
1629
1629
Object acc = null ;
1630
1630
for (Integer i = 0 ; i < values .size (); i ++ ) {
1631
1631
Object current = values .get (i );
1632
- Environment env = getEnvironmentFromObject (current );
1632
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), current );
1633
1633
1634
1634
env .define (' $current' , current );
1635
1635
env .define (' $key' , key );
@@ -1676,7 +1676,7 @@ public with sharing class CollectionFunctions {
1676
1676
Expr expr = arguments .get (1 );
1677
1677
Map <Object , Object > result = new Map <Object , Object >();
1678
1678
for (Object currentVal : listVal ) {
1679
- Environment env = getEnvironmentFromObject (currentVal );
1679
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1680
1680
env .define (' $current' , currentVal );
1681
1681
Interpreter interpreter = new Interpreter (env );
1682
1682
Object key = interpreter .interpret (expr );
@@ -1719,7 +1719,7 @@ public with sharing class CollectionFunctions {
1719
1719
Expr expr = arguments .get (1 );
1720
1720
Map <Object , List <Object >> result = new Map <Object , List <Object >>();
1721
1721
for (Object currentVal : listVal ) {
1722
- Environment env = getEnvironmentFromObject (currentVal );
1722
+ Environment env = getEnvironmentFromObject (this . interpreter . getEnvironment (), currentVal );
1723
1723
env .define (' $current' , currentVal );
1724
1724
Interpreter interpreter = new Interpreter (env );
1725
1725
Object key = interpreter .interpret (expr );
0 commit comments