52
52
import static org .codehaus .groovy .ast .tools .GeneralUtils .binX ;
53
53
import static org .codehaus .groovy .ast .tools .GeneralUtils .callX ;
54
54
import static org .codehaus .groovy .ast .tools .GeneralUtils .castX ;
55
+ import static org .codehaus .groovy .ast .tools .GeneralUtils .classX ;
55
56
import static org .codehaus .groovy .ast .tools .GeneralUtils .isInstanceOfX ;
56
57
import static org .codehaus .groovy .ast .tools .GeneralUtils .propX ;
57
58
import static org .codehaus .groovy .ast .tools .GeneralUtils .ternaryX ;
@@ -217,7 +218,7 @@ private Expression transformBinaryExpression(final BinaryExpression exp, final C
217
218
super .transform (rightExpression )
218
219
);
219
220
mce .setImplicitThis (false );
220
- mce .setSourcePosition (exp );
221
+ mce .setSourcePosition (leftExpression instanceof PropertyExpression ? (( PropertyExpression ) leftExpression ). getProperty () : leftExpression );
221
222
markDynamicCall (mce , staticField , isStatic );
222
223
return mce ;
223
224
}
@@ -240,7 +241,7 @@ private Expression transformFieldReference(final Expression exp, final FieldNode
240
241
241
242
MethodCallExpression mce = callX (receiver , Traits .helperGetterName (fn ));
242
243
mce .setImplicitThis (false );
243
- mce .setSourcePosition (exp );
244
+ mce .setSourcePosition (exp instanceof PropertyExpression ? (( PropertyExpression ) exp ). getProperty () : exp );
244
245
markDynamicCall (mce , fn , isStatic );
245
246
return mce ;
246
247
}
@@ -288,9 +289,9 @@ private Expression transformSuperMethodCall(final MethodCallExpression call) {
288
289
Traits .getSuperTraitMethodName (traitClass , method ),
289
290
superCallArgs
290
291
);
291
- newCall .setSourcePosition (call );
292
- newCall .setSafe (call .isSafe ());
292
+ newCall .getMethod ().setSourcePosition (call .getMethod ());
293
293
newCall .setSpreadSafe (call .isSpreadSafe ());
294
+ newCall .setSafe (call .isSafe ());
294
295
newCall .setImplicitThis (false );
295
296
return newCall ;
296
297
}
@@ -304,9 +305,9 @@ private Expression transformMethodCallOnThis(final MethodCallExpression call) {
304
305
// GROOVY-7191, GROOVY-7213, GROOVY-7214, GROOVY-8282, GROOVY-8854, GROOVY-8859, et al.
305
306
for (MethodNode methodNode : traitClass .getDeclaredMethods (call .getMethodAsString ())) {
306
307
if (methodNode .isPrivate ()) {
307
- // this.m(x) --> this.m($self or $static$self or (Class) $self.getClass(), x)
308
+ // this.m(x) --> ( this or T$Trait$Helper) .m($self or $static$self or (Class) $self.getClass(), x)
308
309
Expression selfClassOrObject = methodNode .isStatic () && !ClassHelper .isClassType (weaved .getOriginType ()) ? castX (ClassHelper .CLASS_Type .getPlainNodeReference (), callX (weaved , "getClass" )) : weaved ;
309
- MethodCallExpression newCall = callX (thisExpr , method , createArgumentList (selfClassOrObject , arguments ));
310
+ MethodCallExpression newCall = callX (inClosure ? classX ( traitHelperClass ) : thisExpr , method , createArgumentList (selfClassOrObject , arguments ));
310
311
newCall .setGenericsTypes (call .getGenericsTypes ());
311
312
newCall .setImplicitThis (call .isImplicitThis ());
312
313
newCall .setSpreadSafe (call .isSpreadSafe ());
0 commit comments