Skip to content

Commit

Permalink
+ fix position computation in dereferencingNullableExpression()
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-herrmann committed Jan 16, 2025
1 parent 7ddead3 commit a6171cb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11248,7 +11248,7 @@ public void dereferencingNullableExpression(long positions, LookupEnvironment en
char[][] nullableName = env.getNullableAnnotationName();
char[] nullableShort = nullableName[nullableName.length-1];
String[] arguments = { String.valueOf(nullableShort) };
this.handle(IProblem.DereferencingNullableExpression, arguments, arguments, (int)(positions>>>32), (int)(positions&0xFFFF));
this.handle(IProblem.DereferencingNullableExpression, arguments, arguments, (int)(positions>>>32), (int)(positions));
}
public void onlyReferenceTypesInIntersectionCast(TypeReference typeReference) {
this.handle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19455,4 +19455,31 @@ public enum MyEnum {
};
runner.runConformTest();
}
public void testTemp() {
StringBuilder padding = new StringBuilder();
// push the relevant source to a position beyond 0xFFFF to trigger bug in position computation
for (int i=0; i<1000; i++)
padding.append("// ============================== padding ================================\n");
runNegativeTestWithLibs(new String[]{
"X.java",
padding.toString() +
"""
import org.eclipse.jdt.annotation.*;
class X {
@Nullable String s;
String test() {
return this.s.toLowerCase();
}
}
"""
},
"""
----------
1. ERROR in X.java (at line 1005)
return this.s.toLowerCase();
^
Potential null pointer access: this expression has a '@Nullable' type
----------
""");
}
}

0 comments on commit a6171cb

Please sign in to comment.