LeakingThisInspection: fix false positives for enum class

#KT-25905 Fixed
This commit is contained in:
Dmitry Gridin
2019-06-18 19:10:03 +07:00
parent efd004c997
commit d9808b70b6
7 changed files with 132 additions and 16 deletions
@@ -0,0 +1,14 @@
// PROBLEM: Calling non-final function toString in constructor
// FIX: none
enum class Fo(val b: Int) {
ONE(5) {
override val x = b
override fun toString(): String {
return x.toString()
}
};
abstract val x: Int
val dos = <caret>toString()
}
@@ -0,0 +1,11 @@
// PROBLEM: none
// FIX: none
enum class Fo(val b: Int) {
ONE(5) {
override val x = b
};
abstract val x: Int
val dos = <caret>toString()
}
@@ -0,0 +1,13 @@
// PROBLEM: Accessing non-final property x in constructor
// FIX: none
enum class Foo : Bar {
ONE {
override val x = 1
};
val double = x<caret>
}
interface Bar {
val x: Int
}
@@ -0,0 +1,11 @@
// PROBLEM: none
// FIX: none
enum class Foo : Bar {
ONE;
val double = x<caret>
}
interface Bar {
val x: Int get() = 42
}
@@ -0,0 +1,14 @@
// PROBLEM: none
// FIX: none
enum class Foo : Bar {
ONE {
override fun x() = 1
};
val double = <caret>x(2)
}
interface Bar {
fun x(): Int = 42
fun x(i: Int): Int = 24
}