Introduce inspection to detect vals might be marked as const

So #KT-20644 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-12-07 17:36:13 +03:00
parent 4ec20ad595
commit 70b7e5eb68
20 changed files with 222 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.MayBeConstantInspection
@@ -0,0 +1,9 @@
// WITH_RUNTIME
const val y = 0
class Your {
companion object {
@JvmField val <caret>z = y + 3
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
const val y = 0
class Your {
companion object {
const val z = y + 3
}
}
@@ -0,0 +1,5 @@
class Your {
companion object {
val <caret>IMPORTANT = 2 * 2
}
}
@@ -0,0 +1,5 @@
class Your {
companion object {
const val IMPORTANT = 2 * 2
}
}
+4
View File
@@ -0,0 +1,4 @@
// PROBLEM: none
// WITH_RUNTIME
const val <caret>x = 13
@@ -0,0 +1,3 @@
// PROBLEM: none
val <caret>withGetter get() = 42
@@ -0,0 +1,6 @@
// PROBLEM: none
// WITH_RUNTIME
class My {
@JvmField val <caret>x = 13
}
@@ -0,0 +1,6 @@
// PROBLEM: none
// WITH_RUNTIME
annotation class A
@A val <caret>x = 55
@@ -0,0 +1,5 @@
// WITH_RUNTIME
object O {
@JvmField val <caret>s = "He" + "llo"
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
object O {
const val s = "He" + "llo"
}
@@ -0,0 +1,3 @@
// WITH_RUNTIME
@JvmField val <caret>x = 1
@@ -0,0 +1,3 @@
// WITH_RUNTIME
const val x = 1
@@ -0,0 +1 @@
val <caret>x = 1
@@ -0,0 +1 @@
const val x = 1
+3
View File
@@ -0,0 +1,3 @@
// PROBLEM: none
var <caret>n = 1