Skip to content

Commit c793de9

Browse files
archiecobbslahodaj
andcommitted
8350212: Track source end positions of declarations that support @SuppressWarnings
Co-authored-by: Jan Lahoda <[email protected]> Reviewed-by: mcimadamore
1 parent 15178aa commit c793de9

File tree

11 files changed

+252
-160
lines changed

11 files changed

+252
-160
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3697,7 +3697,7 @@ private void visitIterableForeachLoop(JCEnhancedForLoop tree) {
36973697
vardefinit).setType(tree.var.type);
36983698
indexDef.sym = tree.var.sym;
36993699
JCBlock body = make.Block(0, List.of(indexDef, tree.body));
3700-
body.endpos = TreeInfo.endPos(tree.body);
3700+
body.bracePos = TreeInfo.endPos(tree.body);
37013701
result = translate(make.
37023702
ForLoop(List.of(init),
37033703
cond,
@@ -4158,7 +4158,7 @@ else if (oneCase == nullCase) {
41584158
stmtList.append(switch2);
41594159

41604160
JCBlock res = make.Block(0L, stmtList.toList());
4161-
res.endpos = TreeInfo.endPos(tree);
4161+
res.bracePos = TreeInfo.endPos(tree);
41624162
return res;
41634163
} else {
41644164
JCSwitchExpression switch2 = make.SwitchExpression(make.Ident(dollar_tmp), lb.toList());

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ else if ((block.flags & SYNTHETIC) == 0)
500500
c.members().enter(clinit);
501501
List<JCStatement> clinitStats = clinitCode.toList();
502502
JCBlock block = make.at(clinitStats.head.pos()).Block(0, clinitStats);
503-
block.endpos = TreeInfo.endPos(clinitStats.last());
503+
block.bracePos = TreeInfo.endPos(clinitStats.last());
504504
methodDefs.append(make.MethodDef(clinit, block));
505505

506506
if (!clinitTAs.isEmpty())
@@ -553,8 +553,8 @@ void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode, List<TypeCompo
553553
// Find the super() invocation and append the given initializer code.
554554
TreeInfo.mapSuperCalls(md.body, supercall -> make.Block(0, initCode.prepend(supercall)));
555555

556-
if (md.body.endpos == Position.NOPOS)
557-
md.body.endpos = TreeInfo.endPos(md.body.stats.last());
556+
if (md.body.bracePos == Position.NOPOS)
557+
md.body.bracePos = TreeInfo.endPos(md.body.stats.last());
558558

559559
md.sym.appendUniqueTypeAttributes(initTAs);
560560
}
@@ -1121,7 +1121,7 @@ private void internalVisitBlock(JCBlock tree) {
11211121
genStats(tree.stats, localEnv);
11221122
// End the scope of all block-local variables in variable info.
11231123
if (!env.tree.hasTag(METHODDEF)) {
1124-
code.statBegin(tree.endpos);
1124+
code.statBegin(tree.bracePos);
11251125
code.endScopes(limit);
11261126
code.pendingStatPos = Position.NOPOS;
11271127
}

0 commit comments

Comments
 (0)