-
Notifications
You must be signed in to change notification settings - Fork 134
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
Fix LoggerEnclosingClass
edge cases for type parameters and anonymous classes
#1171
Conversation
Generate changelog in
|
private static Symbol.ClassSymbol enclosingConcreteClass(Symbol.ClassSymbol input) { | ||
Symbol.ClassSymbol current = input; | ||
while (current != null && current.isAnonymous()) { | ||
current = ASTHelpers.enclosingClass(current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't encountered this in the wild (it's an odd thing to do) but fixed it while I'm here.
@@ -83,8 +83,16 @@ public Description matchVariable(VariableTree tree, VisitorState state) { | |||
return buildDescription(classArgument) | |||
.addFix(fix.replace( | |||
classArgument, | |||
SuggestedFixes.prettyType(state, fix, enclosingClassSymbol.type) + ".class") | |||
enclosingClassSymbol.name + ".class") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple name is sufficient here because the code we're updating is nested within the type -- the previous approach using prettyType wasn't necessary and included type parameters.
dozer? |
Released 2.49.1 |
Before this PR
Possible to suggest
LoggerFactory.getLogger(Bar<T>.class)
instead ofLoggerFactory.getLogger(Bar.class)
.Also possible to fail when loggers are defined as fields of anonymous classes.
After this PR
==COMMIT_MSG==
Fix
LoggerEnclosingClass
edge cases for type parameters and anonymous classes==COMMIT_MSG==