Introduce "Assign to property" quick-fix #KT-17204 Fixed

This commit is contained in:
Toshiaki Kameyama
2017-10-02 12:36:22 +03:00
committed by Mikhail Glukhikh
parent 67a50e92d0
commit e92af08c98
20 changed files with 302 additions and 2 deletions
@@ -0,0 +1,9 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test {
var bar = 1
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,7 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test(var bar: Int) {
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,9 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test {
var foo = "1"
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,7 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test(var foo: String) {
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,8 @@
// "Assign to property" "true"
class Test {
val foo: Int
constructor(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,8 @@
// "Assign to property" "true"
class Test {
val foo: Int
constructor(foo: Int) {
this.foo = foo
}
}
+7
View File
@@ -0,0 +1,7 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test(foo: Int) {
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,11 @@
// "Assign to property" "true"
// WITH_RUNTIME
class Test {
var foo = 1
fun test(foo: Int) {
"".run {
<caret>foo = foo
}
}
}
@@ -0,0 +1,11 @@
// "Assign to property" "true"
// WITH_RUNTIME
class Test {
var foo = 1
fun test(foo: Int) {
"".run {
this@Test.foo = foo
}
}
}
@@ -0,0 +1,8 @@
// "Assign to property" "true"
class Test {
var foo = 1
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,8 @@
// "Assign to property" "true"
class Test {
var foo = 1
fun test(foo: Int) {
this.foo = foo
}
}
@@ -0,0 +1,8 @@
// "Assign to property" "true"
class Test {
var foo = 1
fun test(foo: String) {
<caret>foo = 2
}
}
@@ -0,0 +1,8 @@
// "Assign to property" "true"
class Test {
var foo = 1
fun test(foo: String) {
this.foo = 2
}
}
@@ -0,0 +1,6 @@
// "Assign to property" "true"
class Test(var foo: Int) {
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,6 @@
// "Assign to property" "true"
class Test(var foo: Int) {
fun test(foo: Int) {
this.foo = foo
}
}
@@ -0,0 +1,9 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test {
val foo = 1
fun test(foo: Int) {
<caret>foo = foo
}
}
@@ -0,0 +1,7 @@
// "Assign to property" "false"
// ERROR: Val cannot be reassigned
class Test(val foo: Int) {
fun test(foo: Int) {
<caret>foo = foo
}
}