UnusedDetector: add missing RECORD label#8930
Conversation
lahodaj
left a comment
There was a problem hiding this comment.
Looks good. The only enhancement I could see is adding a test.
added tests
e6d7c57 to
ccfbd96
Compare
|
@jlahoda added tests for the hint. There is one curiosity though: initially I wanted to add test cases to the e.g: @Test
public void testNoUnusedPackagePrivateClass() throws Exception {
performTest(
"test/Test.java",
"""
package test;
class Test {
}
"""
);
}However, it would fail since returns package private top level classes/interfaces/records.. etc as unused. I debugged through it and it correctly marks the class declaration as used, but later sees an synthetic constructor and marks that as unused. I believe what is happening afterwards is that since synthetic items have no line numbers, it maps the unused line to the class declaration so that it looks as if it would think that the class should be marked as unused. (constructor name == class name too so the error line becomes indistinguishable) So why does the hint work? That is why the junit test works as expected for the hint, while the However, changing this is not required to resolve this issue and it would be unnecessarily risky for the release. We should probably fix this at some point though. I think this can get in as is (+ the added hint tests) |
|
FWIW, retroactivelly (sorry), still looks good. Thanks! |
|
@lahodaj yep, would be good to properly fix |
fixes #8928