Replace get() and set() to getValue() and setValue() (property delegates)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
fun set(key : String, value : String) {
|
||||
fun set(<!UNUSED_PARAMETER!>key<!> : String, <!UNUSED_PARAMETER!>value<!> : String) {
|
||||
val a : String? = ""
|
||||
when (a) {
|
||||
"" -> <!DEBUG_INFO_SMARTCAST!>a<!>.get(0)
|
||||
is String, is Any -> <!DEBUG_INFO_SMARTCAST!>a<!>.compareTo("")
|
||||
else -> a.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -5,27 +5,27 @@ package kt235
|
||||
fun main(args: Array<String>) {
|
||||
val array = MyArray()
|
||||
val <!UNUSED_VARIABLE!>f<!>: () -> String = {
|
||||
<!EXPECTED_TYPE_MISMATCH!>array[2] = 23<!> //error: Type mismatch: inferred type is Int (!!!) but String was expected
|
||||
<!EXPECTED_TYPE_MISMATCH!>array[2] = 23<!> //error: Type mismatch: inferred type is Int (!!!) but String was expected
|
||||
}
|
||||
val <!UNUSED_VARIABLE!>g<!>: () -> String = {
|
||||
var x = 1
|
||||
<!EXPECTED_TYPE_MISMATCH!>x += 2<!> //no error, but it should be here
|
||||
var x = 1
|
||||
<!EXPECTED_TYPE_MISMATCH!>x += 2<!> //no error, but it should be here
|
||||
}
|
||||
val <!UNUSED_VARIABLE!>h<!>: () -> String = {
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>x<!> = 1
|
||||
<!EXPECTED_TYPE_MISMATCH!><!UNUSED_VALUE!>x =<!> 2<!> //the same
|
||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>x<!> = 1
|
||||
<!EXPECTED_TYPE_MISMATCH!><!UNUSED_VALUE!>x =<!> 2<!> //the same
|
||||
}
|
||||
val array1 = MyArray1()
|
||||
val <!UNUSED_VARIABLE!>i<!>: () -> String = {
|
||||
<!EXPECTED_TYPE_MISMATCH!>array1[2] = 23<!>
|
||||
<!EXPECTED_TYPE_MISMATCH!>array1[2] = 23<!>
|
||||
}
|
||||
|
||||
val <!UNUSED_VARIABLE!>fi<!>: () -> String = {
|
||||
<!EXPECTED_TYPE_MISMATCH!>array[2] = 23<!>
|
||||
<!EXPECTED_TYPE_MISMATCH!>array[2] = 23<!>
|
||||
}
|
||||
val <!UNUSED_VARIABLE!>gi<!>: () -> String = {
|
||||
var x = 1
|
||||
<!EXPECTED_TYPE_MISMATCH!>x += 21<!>
|
||||
var x = 1
|
||||
<!EXPECTED_TYPE_MISMATCH!>x += 21<!>
|
||||
}
|
||||
|
||||
var m: MyNumber = MyNumber()
|
||||
@@ -35,13 +35,13 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
class MyArray() {
|
||||
operator fun get(i: Int): Int = 1
|
||||
operator fun set(i: Int, value: Int): Int = 1
|
||||
operator fun get(<!UNUSED_PARAMETER!>i<!>: Int): Int = 1
|
||||
operator fun set(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>value<!>: Int): Int = 1
|
||||
}
|
||||
|
||||
class MyArray1() {
|
||||
operator fun get(i: Int): Int = 1
|
||||
operator fun set(i: Int, value: Int) {}
|
||||
operator fun get(<!UNUSED_PARAMETER!>i<!>: Int): Int = 1
|
||||
operator fun set(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>value<!>: Int) {}
|
||||
}
|
||||
|
||||
class MyNumber() {
|
||||
|
||||
@@ -7,4 +7,4 @@ fun test() {
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
operator fun <K, V> MutableMap<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
|
||||
@@ -5,4 +5,4 @@ fun test() {
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
operator fun <K, V> Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
operator fun <K, V> Map<K, V>.set(<!UNUSED_PARAMETER!>key<!> : K, <!UNUSED_PARAMETER!>value<!> : V) {}//= this.put(key, value)
|
||||
Reference in New Issue
Block a user