@@ -456,15 +456,6 @@ public void visitExpressionStatement(ExpressionStatement node) {
456
456
}
457
457
return ;
458
458
}
459
- if ( exp instanceof MethodCallExpression mce ) {
460
- var source = mce .getObjectExpression ();
461
- var target = checkSetAssignment (mce );
462
- if ( target != null ) {
463
- visit (source );
464
- declareAssignedVariable (target );
465
- return ;
466
- }
467
- }
468
459
super .visitExpressionStatement (node );
469
460
}
470
461
@@ -562,21 +553,6 @@ private void checkExternalWriteInAsyncClosure(VariableExpression target, Variabl
562
553
addFutureWarning ("Mutating an external variable in an operator closure may lead to a race condition" , target , "External variable declared here" , (ASTNode ) variable );
563
554
}
564
555
565
- /**
566
- * Treat `set` operator as an assignment.
567
- */
568
- private VariableExpression checkSetAssignment (MethodCallExpression node ) {
569
- if ( !(currentDefinition instanceof WorkflowNode ) )
570
- return null ;
571
- var name = node .getMethodAsString ();
572
- if ( !"set" .equals (name ) )
573
- return null ;
574
- var code = asDslBlock (node , 1 );
575
- if ( code == null || code .getStatements ().size () != 1 )
576
- return null ;
577
- return asVarX (code .getStatements ().get (0 ));
578
- }
579
-
580
556
// expressions
581
557
582
558
private static final List <String > KEYWORDS = List .of (
@@ -588,6 +564,15 @@ private VariableExpression checkSetAssignment(MethodCallExpression node) {
588
564
589
565
@ Override
590
566
public void visitMethodCallExpression (MethodCallExpression node ) {
567
+ if ( !node .isImplicitThis () ) {
568
+ var source = node .getObjectExpression ();
569
+ var target = checkSetAssignment (node );
570
+ if ( target != null ) {
571
+ visit (source );
572
+ declareAssignedVariable (target );
573
+ return ;
574
+ }
575
+ }
591
576
if ( node .isImplicitThis () && node .getMethod () instanceof ConstantExpression ) {
592
577
var name = node .getMethodAsString ();
593
578
var variable = findVariableDeclaration (name , node );
@@ -599,6 +584,21 @@ public void visitMethodCallExpression(MethodCallExpression node) {
599
584
super .visitMethodCallExpression (node );
600
585
}
601
586
587
+ /**
588
+ * Treat `set` and `tap` operators as assignments.
589
+ */
590
+ private VariableExpression checkSetAssignment (MethodCallExpression node ) {
591
+ if ( !(currentDefinition instanceof WorkflowNode ) )
592
+ return null ;
593
+ var name = node .getMethodAsString ();
594
+ if ( !"set" .equals (name ) && !"tap" .equals (name ) )
595
+ return null ;
596
+ var code = asDslBlock (node , 1 );
597
+ if ( code == null || code .getStatements ().size () != 1 )
598
+ return null ;
599
+ return asVarX (code .getStatements ().get (0 ));
600
+ }
601
+
602
602
@ Override
603
603
public void visitDeclarationExpression (DeclarationExpression node ) {
604
604
visit (node .getRightExpression ());
0 commit comments