Skip to content

Conversation

@rmohan20
Copy link
Contributor

@rmohan20 rmohan20 commented Jun 2, 2023

  1. Handles method invocations from static blocks as permanent loop exclusions.
  2. Handles nested loops around method-calls inside for-each loop definition. These are now treated as overridable loop exclusions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most active part of the change is here.

}

@Test
public void testNestedLookupFromForEachValueWithEffectiveExclusion() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extended test case to make sure the exclusion works across many layers.

@rmohan20 rmohan20 changed the title FIX (GraphEngine): @W-13363157@ Handles loop exclusions more effectively FIX (GraphEngine): @W-13363157@: Handles loop exclusions more effectively Jun 2, 2023
* @param <T> Stack's generic
* @return last element added to the stack
*/
public static <T> Optional<T> peek(Stack<T> stack) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this here since the logic is needed on a couple of different Stacks and would be helpful to reuse in future as well.

// TODO: Edge case where a user also creates a method of the same name in their class.
// Ideally, we need to check if the method definition associated with this call has
// isSynthetic as true.
return methodName.startsWith(SYNTHETIC_STATIC_BLOCK_METHOD_BASE);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The edge case is pretty far off. We're not even doing a case-insensitive match.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A potential workaround could be using double-underscore in the name of the synthetic method, since real methods aren't allowed to do t hat.

return this._isInsideLoop(copyStack);
}

private Optional<? extends SFVertex> _isInsideLoop(Stack<? extends LoopBoundary> boundaryStack) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performs recursive calls until it finds the boundary that actually applies.

jfeingold35
jfeingold35 previously approved these changes Jun 2, 2023
// TODO: Edge case where a user also creates a method of the same name in their class.
// Ideally, we need to check if the method definition associated with this call has
// isSynthetic as true.
return methodName.startsWith(SYNTHETIC_STATIC_BLOCK_METHOD_BASE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A potential workaround could be using double-underscore in the name of the synthetic method, since real methods aren't allowed to do t hat.

Comment on lines 83 to 84
createPermanentLoopExclusionIfApplicable(vertex, loopBoundaryItem);
createOverridableLoopExclusionIfApplicable(vertex, loopBoundaryItem);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the same vertex could produce both a permanent and overridable exclusion? If so, could you please add a comment explaining how?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this up. Missed adding the explanation.

}

@Test
public void testLoopFromStaticBlock_nestedLoop() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this loop actually nested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a code merge issue. Good catch.

@jfeingold35 jfeingold35 dismissed their stale review June 2, 2023 18:05

Misclick.

@rmohan20 rmohan20 merged commit ce8880c into dev Jun 2, 2023
@stephen-carter-at-sf stephen-carter-at-sf deleted the rm/fixNestedLoopMMSLR branch May 17, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants