"Change to var": remove const modifier
#KT-35022 Fixed
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user