[MemberNameEqualsClassName] Support factory exemption for generic classes#3595
Conversation
|
There may be a better way to do this, as I don't fully understand the kotlin compiler psi APIs, but this works for the test case included and falls back to the previous implementation for other cases. |
Codecov Report
@@ Coverage Diff @@
## main #3595 +/- ##
============================================
- Coverage 77.53% 77.53% -0.01%
- Complexity 2835 2837 +2
============================================
Files 464 464
Lines 8779 8783 +4
Branches 1720 1721 +1
============================================
+ Hits 6807 6810 +3
Misses 1046 1046
- Partials 926 927 +1
Continue to review full report at Codecov.
|
| val code = """ | ||
| data class GenericClass<T>(val wrapped: T) { | ||
| companion object { | ||
| fun <T> genericClass(wrapped: T): GenericClass<T> { |
There was a problem hiding this comment.
In this test is not clear if the problem was the generic in the class or the generic in the function. Could you simplify it? Or, if they are both, create two tests.
There was a problem hiding this comment.
Added a non-generic factory function to the test, does that help?
There was a problem hiding this comment.
Which is the problem exactly this code:
data class GenericClass(val wrapped: Any) {
companion object {
fun <T> genericClass(wrapped: T): GenericClass<T> {
return GenericClass(wrapped)
}
}
}or this:
data class GenericClass<T>(val wrapped: T) {
companion object {
fun genericClass(wrapped: Any): GenericClass<Any> {
return GenericClass(wrapped)
}
}
}There was a problem hiding this comment.
the top one is closer to real world usage, but i suppose the bottom one is the minimal example? both fail without the change and pass with it, fwiw.
Compare the referenced type name instead of the fully qualified generic type name when possible. Fixes detekt#3591
36bdf01 to
3017ef2
Compare
Compare the referenced type name instead of the fully
qualified generic type name when possible.
Fixes #3591