"Change to var": remove const modifier

#KT-35022 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-11-23 00:37:26 +09:00
parent 8c103629a6
commit f6059c3eb5
4 changed files with 24 additions and 0 deletions
@@ -56,6 +56,9 @@ class ChangeVariableMutabilityFix(
if (deleteInitializer) {
(element as? KtProperty)?.initializer = null
}
if (makeVar) {
(element as? KtModifierListOwner)?.removeModifier(KtTokens.CONST_KEYWORD)
}
}
companion object {
@@ -0,0 +1,8 @@
// "Change to var" "true"
object A {
const val A = 1
fun foo() {
<caret>A = 10
}
}
@@ -0,0 +1,8 @@
// "Change to var" "true"
object A {
var A = 1
fun foo() {
<caret>A = 10
}
}
@@ -14342,6 +14342,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
runTest("idea/testData/quickfix/variables/changeMutability/capturedValInitialization.kt");
}
@TestMetadata("const.kt")
public void testConst() throws Exception {
runTest("idea/testData/quickfix/variables/changeMutability/const.kt");
}
@TestMetadata("funParameter.kt")
public void testFunParameter() throws Exception {
runTest("idea/testData/quickfix/variables/changeMutability/funParameter.kt");