Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UnnecessaryInnerClass: fix false positives labeled expression to oute…
…r class (#4865) * UnnecessaryInnerClass: fix false positives labeled expression to outer class Fix an issue where inner classes which reference their outer class via a labeled expression would still be reported as unnecessary. This seems to be due to a missing visitExpressionWithLabel() check which resolves the label name: if the label is referencing a parent class, then the nested class must be `inner`. I wasn't able to find a way to resolve the labeled expression as a ClassId to match the existing class check from KtReferenceExpression, so I settled for using the class name instead, which is easy to obtain. This means there's a fair bit of duplication in overriden checkForOuterUsage() methods to check parent classes which could probably be removed, but I didn't see a particularly clean way to do so. * UnnecessaryInnerClass: add test for double-nested inner classes using labeled expressions
- Loading branch information
Showing
2 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters