Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8314275: Incorrect stepping in switch #17772

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1429,8 +1429,10 @@ private void handleSwitch(JCTree swtch, JCExpression selector, List<JCCase> case
}
}

// Emit line position for the end of the switch
code.statBegin(TreeInfo.endPos(swtch));
if (swtch instanceof JCSwitchExpression) {
// Emit line position for the end of a switch expression
code.statBegin(TreeInfo.endPos(swtch));
}
}
code.endScopes(limit);
}
Original file line number Diff line number Diff line change
@@ -46,19 +46,34 @@ public void test() throws Exception {

private static final TestCase[] TEST_CASE = new TestCase[] {
new TestCase("""
public class T8314275 { // 1
private static double multiply(Integer i) { // 2
double cr = 15; // 3
cr = switch (i) { // 4
case 1 -> cr * 1; // 5
case 2 -> cr * 2; // 6
default -> cr * 4; // 7
}; // 8
return cr; // 9
} // 10
} // 11
""",
List.of(1, 3, 4, 5, 6, 7, 8, 9),
"T8314275")
public class T8314275Expression { // 1
private static double multiply(Integer i) { // 2
double cr = 15; // 3
cr = switch (i) { // 4
case 1 -> cr * 1; // 5
case 2 -> cr * 2; // 6
default -> cr * 4; // 7
}; // 8
return cr; // 9
} //10
} //11
""",
List.of(1, 3, 4, 5, 6, 7, 8, 9),
"T8314275Expression"),
new TestCase("""
public class T8314275Statement { // 1
private static double multiply(Integer i) { // 2
double cr = 15; // 3
switch (i) { // 4
case 1: cr *= 1; break; // 5
case 2: cr *= 2; break; // 6
default: cr *= 4; // 7
}; // 8
return cr; // 9
} //10
} //11
""",
List.of(1, 3, 4, 5, 6, 7, 9),
"T8314275Statement")
};
}