@@ -186,6 +186,19 @@ class PolymodInterpEx extends Interp
186
186
return v ;
187
187
}
188
188
}
189
+
190
+ @:privateAccess
191
+ {
192
+ if (_proxy != null )
193
+ {
194
+ var variable = _proxy .findVar (id );
195
+ if (variable .isfinal && _proxy ._interp .variables .exists (id ))
196
+ {
197
+ errorEx (EInvalidAccess (id ));
198
+ return null ;
199
+ }
200
+ }
201
+ }
189
202
case EField (e0 , id ):
190
203
// Make sure setting superclass fields works when using this.
191
204
// Also ensures property functions are accounted for.
@@ -213,6 +226,54 @@ class PolymodInterpEx extends Interp
213
226
return super .assign (e1 , e2 );
214
227
}
215
228
229
+ override function increment (e : Expr , prefix : Bool , delta : Int ): Dynamic
230
+ {
231
+ switch (Tools .expr (e ))
232
+ {
233
+ case EIdent (id ):
234
+ @:privateAccess
235
+ {
236
+ if (_proxy != null )
237
+ {
238
+ var variable = _proxy .findVar (id );
239
+ if (variable .isfinal && _proxy ._interp .variables .exists (id ))
240
+ {
241
+ errorEx (EInvalidAccess (id ));
242
+ return null ;
243
+ }
244
+ }
245
+ }
246
+ default :
247
+ }
248
+
249
+ return super .increment (e , prefix , delta );
250
+ }
251
+
252
+ override function evalAssignOp (op : String , fop : (Dynamic -> Dynamic )-> Dynamic , e1 : Expr , e2 : Expr ): Dynamic
253
+ {
254
+ switch (Tools .expr (e1 ))
255
+ {
256
+ case EIdent (id ):
257
+ var v = fop (expr (e1 ),expr (e2 ));
258
+
259
+ @:privateAccess
260
+ {
261
+ if (_proxy != null )
262
+ {
263
+ var variable = _proxy .findVar (id );
264
+ if (variable .isfinal && _proxy ._interp .variables .exists (id ))
265
+ {
266
+ errorEx (EInvalidAccess (id ));
267
+ return null ;
268
+ }
269
+ }
270
+ }
271
+ default :
272
+ }
273
+
274
+ return super .evalAssignOp (op , fop , e1 , e2 );
275
+ }
276
+
216
277
public override function expr (e : Expr ): Dynamic
217
278
{
218
279
// Override to provide some fixes, falling back to super.expr() when not needed.
@@ -231,6 +292,11 @@ class PolymodInterpEx extends Interp
231
292
var result = (e == null ) ? null : expr (e );
232
293
locals .set (n , {r : result });
233
294
return null ;
295
+ case EFinal (n , _ , e ): // Fix to ensure local variables are committed properly.
296
+ declared .push ({n : n , old : locals .get (n )});
297
+ var result = (e == null ) ? null : expr (e );
298
+ locals .set (n , {r : result , isfinal : true });
299
+ return null ;
234
300
case EFunction (params , fexpr , name , _ ): // Fix to ensure callback functions catch thrown errors.
235
301
var capturedLocals = duplicate (locals );
236
302
var me = this ;
0 commit comments