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
PropertyUsedBeforeDeclaration: fix false positive in nested/inner class #6139
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6139 +/- ##
=========================================
Coverage 84.94% 84.94%
- Complexity 4026 4027 +1
=========================================
Files 569 569
Lines 13498 13498
Branches 2381 2381
=========================================
Hits 11466 11466
Misses 869 869
Partials 1163 1163
|
fun `used before declaration in inner class`() { | ||
val code = """ | ||
class A { | ||
inner class B { | ||
val inner = outer | ||
} | ||
val outer = "value" | ||
} | ||
""".trimIndent() |
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.
Is it worth adding a similar test where the outer
is a top-level property, and it is used from a normal class? That sounds like a normal use case.
class C {
val inner = outer
}
val outer = "value"
in this case they're essentially not even nested, just sibling classes. Only Kotlin's syntax allows their declaration in one file.
Fixes #6125