@@ -1449,6 +1449,36 @@ public TupleExpr visit(ASTPathSequence pathSeqNode, Object data) throws VisitorE
14491449 subjVar = mapValueExprToVar (data );
14501450 }
14511451
1452+ List <ValueExpr > objectList = null ;
1453+ if (!(data instanceof PathSequenceContext )) {
1454+ ASTObjectList objectListNode = getObjectList (pathSeqNode );
1455+ if (objectListNode != null ) {
1456+ @ SuppressWarnings ("unchecked" )
1457+ List <ValueExpr > evaluatedObjectList = (List <ValueExpr >) objectListNode .jjtAccept (this , null );
1458+ objectList = evaluatedObjectList ;
1459+
1460+ if (objectList .size () > 1 ) {
1461+ TupleExpr result = null ;
1462+ for (ValueExpr objectItem : objectList ) {
1463+ PathSequenceContext objectContext = new PathSequenceContext ();
1464+ objectContext .scope = graphPattern .getStatementPatternScope ();
1465+ objectContext .contextVar = graphPattern .getContextVar ();
1466+ objectContext .startVar = subjVar ;
1467+ objectContext .endVar = mapValueExprToVar (objectItem );
1468+
1469+ TupleExpr pathExpr = (TupleExpr ) pathSeqNode .jjtAccept (this , objectContext );
1470+
1471+ if (result == null ) {
1472+ result = pathExpr ;
1473+ } else {
1474+ result = new Join (result , pathExpr );
1475+ }
1476+ }
1477+ return result ;
1478+ }
1479+ }
1480+ }
1481+
14521482 List <ASTPathElt > pathElements = pathSeqNode .getPathElements ();
14531483 int pathLength = pathElements .size ();
14541484
@@ -1470,10 +1500,15 @@ public TupleExpr visit(ASTPathSequence pathSeqNode, Object data) throws VisitorE
14701500
14711501 // We handle this here instead of higher up in the tree visitor because here we have
14721502 // a reference to the "temporary" endVar that needs to be replaced.
1473- @ SuppressWarnings ("unchecked" )
1474- List <ValueExpr > objectList = (List <ValueExpr >) getObjectList (pathSeqNode ).jjtAccept (this , null );
1503+ List <ValueExpr > finalObjectList = objectList ;
1504+ if (finalObjectList == null ) {
1505+ @ SuppressWarnings ("unchecked" )
1506+ List <ValueExpr > evaluatedObjectList = (List <ValueExpr >) getObjectList (pathSeqNode )
1507+ .jjtAccept (this , null );
1508+ finalObjectList = evaluatedObjectList ;
1509+ }
14751510
1476- for (ValueExpr objectItem : objectList ) {
1511+ for (ValueExpr objectItem : finalObjectList ) {
14771512 Var objectVar = mapValueExprToVar (objectItem );
14781513 Var replacement = objectVar ;
14791514 if (objectVar .equals (subjVar )) { // corner case for cyclic expressions, see SES-1685
0 commit comments