Replace get() and set() to getValue() and setValue() (property delegates)
This commit is contained in:
Vendored
+2
-2
@@ -19,8 +19,8 @@ fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
|
||||
|
||||
//Arrays copy example
|
||||
class Array<T>(val length : Int, val t : T) {
|
||||
fun get(index : Int) : T { return t }
|
||||
fun set(index : Int, value : T) { /* ... */ }
|
||||
fun get(<warning>index</warning> : Int) : T { return t }
|
||||
fun set(<warning>index</warning> : Int, <warning>value</warning> : T) { /* ... */ }
|
||||
}
|
||||
|
||||
fun copy1(<warning>from</warning> : Array<Any>, <warning>to</warning> : Array<Any>) {}
|
||||
|
||||
@@ -5,7 +5,7 @@ class T1(<warning>t</warning>: Int): T
|
||||
|
||||
|
||||
class Delegate(<warning>d</warning>: Int) {
|
||||
fun get(k: Any, m: PropertyMetadata) {}
|
||||
fun getValue(k: Any, m: PropertyMetadata) {}
|
||||
}
|
||||
|
||||
class A(y: Int, t: Int, d: Int): T <info>by</info> T1(t) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun set(key : String, value : String) {
|
||||
fun set(<warning>key</warning> : String, <warning>value</warning> : String) {
|
||||
val a : String? = ""
|
||||
when (a) {
|
||||
"" -> a.get(0)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package to
|
||||
|
||||
import a.A
|
||||
import a.get
|
||||
import a.set
|
||||
import a.getValue
|
||||
import a.setValue
|
||||
|
||||
class B {
|
||||
var v by A()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
a.A
|
||||
a.get
|
||||
a.set
|
||||
a.getValue
|
||||
a.setValue
|
||||
+2
-2
@@ -3,11 +3,11 @@ package a
|
||||
|
||||
interface T
|
||||
|
||||
fun T.get(thisRef: B, desc: PropertyMetadata): Int {
|
||||
fun T.getValue(thisRef: B, desc: PropertyMetadata): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
fun T.set(thisRef: B, desc: PropertyMetadata, value: Int) {
|
||||
fun T.setValue(thisRef: B, desc: PropertyMetadata, value: Int) {
|
||||
}
|
||||
|
||||
class A(): T
|
||||
|
||||
@@ -5,7 +5,7 @@ fun foo() {
|
||||
val a by Delegate()
|
||||
|
||||
class Delegate {
|
||||
fun get(t: Any?, p: PropertyMetadata) = 1
|
||||
fun getValue(t: Any?, p: PropertyMetadata) = 1
|
||||
}
|
||||
|
||||
// EXISTS: a.get(Any?\, PropertyMetadata)
|
||||
// EXISTS: a.getValue(Any?\, PropertyMetadata)
|
||||
@@ -18,11 +18,11 @@ class A {
|
||||
}
|
||||
|
||||
class MyDelegate {
|
||||
fun get(t: Any?, p: PropertyMetadata): Int = 1
|
||||
fun getValue(t: Any?, p: PropertyMetadata): Int = 1
|
||||
}
|
||||
|
||||
class MyDelegateThrowsException {
|
||||
fun get(t: Any?, p: PropertyMetadata): Int = throw IllegalStateException()
|
||||
fun getValue(t: Any?, p: PropertyMetadata): Int = throw IllegalStateException()
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
|
||||
@@ -17,7 +17,7 @@ class A {
|
||||
}
|
||||
|
||||
class MyDelegate {
|
||||
fun get(t: Any?, p: PropertyMetadata): Int = 1
|
||||
fun getValue(t: Any?, p: PropertyMetadata): Int = 1
|
||||
}
|
||||
|
||||
// RENDER_DELEGATED_PROPERTIES: false
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ val Int.testExtVal: Int get() = 1
|
||||
val testDelVal by Delegate()
|
||||
|
||||
class Delegate {
|
||||
fun get(a: Any?, b: PropertyMetadata) = 1
|
||||
fun getValue(a: Any?, b: PropertyMetadata) = 1
|
||||
}
|
||||
|
||||
// EXPRESSION: TestClass().testFun()
|
||||
|
||||
Vendored
+2
-2
@@ -14,11 +14,11 @@ class A {
|
||||
}
|
||||
|
||||
class MyDelegate {
|
||||
fun get(t: Any?, p: PropertyMetadata): Int = 1
|
||||
fun getValue(t: Any?, p: PropertyMetadata): Int = 1
|
||||
}
|
||||
|
||||
class MyDelegateThrowsException {
|
||||
fun get(t: Any?, p: PropertyMetadata): Int = throw IllegalStateException()
|
||||
fun getValue(t: Any?, p: PropertyMetadata): Int = throw IllegalStateException()
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
+1
-1
@@ -13,7 +13,7 @@ class A {
|
||||
}
|
||||
|
||||
class MyDelegate {
|
||||
fun get(t: Any?, p: PropertyMetadata): Int = 1
|
||||
fun getValue(t: Any?, p: PropertyMetadata): Int = 1
|
||||
}
|
||||
|
||||
// RENDER_DELEGATED_PROPERTIES: false
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// OPTIONS: usages
|
||||
|
||||
class Delegate() {
|
||||
fun <caret>get(thisRef: Any?, propertyMetadata: PropertyMetadata): String = ":)"
|
||||
fun <caret>getValue(thisRef: Any?, propertyMetadata: PropertyMetadata): String = ":)"
|
||||
}
|
||||
|
||||
val p: String by Delegate()
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// OPTIONS: usages
|
||||
|
||||
class Delegate() {
|
||||
fun get(thisRef: Any?, propertyMetadata: PropertyMetadata): String = ":)"
|
||||
fun set(thisRef: Any?, propertyMetadata: PropertyMetadata, value: String) {
|
||||
fun getValue(thisRef: Any?, propertyMetadata: PropertyMetadata): String = ":)"
|
||||
fun setValue(thisRef: Any?, propertyMetadata: PropertyMetadata, value: String) {
|
||||
}
|
||||
|
||||
fun <caret>propertyDelegated(propertyMetadata: PropertyMetadata) {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// OPTIONS: usages
|
||||
|
||||
class Delegate() {
|
||||
fun get(thisRef: Any?, propertyMetadata: PropertyMetadata): String = ":)"
|
||||
fun <caret>set(thisRef: Any?, propertyMetadata: PropertyMetadata, value: String) {
|
||||
fun getValue(thisRef: Any?, propertyMetadata: PropertyMetadata): String = ":)"
|
||||
fun <caret>setValue(thisRef: Any?, propertyMetadata: PropertyMetadata, value: String) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class MyProperty {
|
||||
fun get(thisRef: Any?, desc: PropertyMetadata) = ":)"
|
||||
fun getValue(thisRef: Any?, desc: PropertyMetadata) = ":)"
|
||||
}
|
||||
|
||||
val Any.ext by MyProperty()
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
class SomeProp() {
|
||||
fun get(t: Any, metadata: PropertyMetadataImpl) = 42
|
||||
fun getValue(t: Any, metadata: PropertyMetadataImpl) = 42
|
||||
}
|
||||
|
||||
class Some<caret>() {
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// "Create class 'Foo'" "true"
|
||||
// ERROR: <html>Class 'Foo' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> <b>fun</b> get(thisRef: A<T>, property: kotlin.PropertyMetadata): B <i>defined in</i> kotlin.properties.ReadOnlyProperty</html>
|
||||
|
||||
open class B
|
||||
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
// "Create class 'Foo'" "true"
|
||||
// ERROR: <html>Class 'Foo' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> <b>fun</b> get(thisRef: A<T>, property: kotlin.PropertyMetadata): B <i>defined in</i> kotlin.properties.ReadOnlyProperty</html>
|
||||
|
||||
open class B
|
||||
|
||||
|
||||
+13
@@ -1,3 +1,5 @@
|
||||
import kotlin.Deprecated;
|
||||
import kotlin.PropertyMetadata;
|
||||
import kotlin.properties.ReadOnlyProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -6,5 +8,16 @@ class J {
|
||||
public static class Foo<T> implements ReadOnlyProperty<A<T>, B> {
|
||||
public Foo(T t, @NotNull String s) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public B get(@NotNull A<T> thisRef, @NotNull PropertyMetadata property) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public B getValue(@NotNull A<T> thisRef, @NotNull PropertyMetadata property) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Create member function 'get'" "true"
|
||||
// "Create member function 'getValue'" "true"
|
||||
class F {
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// "Create member function 'get'" "true"
|
||||
// "Create member function 'getValue'" "true"
|
||||
class F {
|
||||
fun get(x: X, propertyMetadata: PropertyMetadata): Int {
|
||||
fun getValue(x: X, propertyMetadata: PropertyMetadata): Int {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Create member function 'get', function 'set'" "true"
|
||||
// "Create member function 'getValue', function 'set'" "true"
|
||||
class F {
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
// "Create member function 'get', function 'set'" "true"
|
||||
// "Create member function 'getValue', function 'setValue'" "true"
|
||||
class F {
|
||||
fun get(x: X, propertyMetadata: PropertyMetadata): Int {
|
||||
fun getValue(x: X, propertyMetadata: PropertyMetadata): Int {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
fun set(x: X, propertyMetadata: PropertyMetadata, i: Int) {
|
||||
fun setValue(x: X, propertyMetadata: PropertyMetadata, i: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// "Create member function 'get'" "true"
|
||||
// "Create member function 'getValue'" "true"
|
||||
class F {
|
||||
fun set(x: X, propertyMetadata: PropertyMetadata, i: Int) { }
|
||||
fun setValue(x: X, propertyMetadata: PropertyMetadata, i: Int) { }
|
||||
}
|
||||
|
||||
class X {
|
||||
|
||||
Vendored
+3
-3
@@ -1,8 +1,8 @@
|
||||
// "Create member function 'get'" "true"
|
||||
// "Create member function 'getValue'" "true"
|
||||
class F {
|
||||
fun set(x: X, propertyMetadata: PropertyMetadata, i: Int) { }
|
||||
fun setValue(x: X, propertyMetadata: PropertyMetadata, i: Int) { }
|
||||
|
||||
fun get(x: X, propertyMetadata: PropertyMetadata): Int {
|
||||
fun getValue(x: X, propertyMetadata: PropertyMetadata): Int {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// "Create member function 'set'" "true"
|
||||
// "Create member function 'setValue'" "true"
|
||||
class F {
|
||||
fun get(x: X, propertyMetadata: PropertyMetadata): Int = 1
|
||||
fun getValue(x: X, propertyMetadata: PropertyMetadata): Int = 1
|
||||
}
|
||||
|
||||
class X {
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Create member function 'set'" "true"
|
||||
// "Create member function 'setValue'" "true"
|
||||
class F {
|
||||
fun get(x: X, propertyMetadata: PropertyMetadata): Int = 1
|
||||
|
||||
|
||||
+2
-2
@@ -9,5 +9,5 @@ class B {
|
||||
}
|
||||
|
||||
// MULTIRESOLVE
|
||||
// REF: (for T in dependency).get(R,kotlin.PropertyMetadata)
|
||||
// REF: (for T in dependency).set(R,kotlin.PropertyMetadata,kotlin.Int)
|
||||
// REF: (for T in dependency).getValue(R,kotlin.PropertyMetadata)
|
||||
// REF: (for T in dependency).setValue(R,kotlin.PropertyMetadata,kotlin.Int)
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package dependency
|
||||
|
||||
public fun <T, R> T.get(thisRef: R, desc: PropertyMetadata): Int {
|
||||
public fun <T, R> T.getValue(thisRef: R, desc: PropertyMetadata): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
public fun <T, R> T.set(thisRef: R, desc: PropertyMetadata, value: Int) {
|
||||
public fun <T, R> T.setValue(thisRef: R, desc: PropertyMetadata, value: Int) {
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ val x: Int <caret>by Foo()
|
||||
|
||||
class Foo
|
||||
|
||||
fun Foo.get(_this: Any?, p: Any?): Int = 1
|
||||
fun Foo.getValue(_this: Any?, p: Any?): Int = 1
|
||||
|
||||
// REF: (for Foo in <root>).get(Any?,Any?)
|
||||
// REF: (for Foo in <root>).getValue(Any?,Any?)
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
val x: Int <caret>by Foo()
|
||||
|
||||
class Foo {
|
||||
fun get(_this: Any?, p: Any?): Int = 1
|
||||
fun getValue(_this: Any?, p: Any?): Int = 1
|
||||
}
|
||||
|
||||
// REF: (in Foo).get(Any?,Any?)
|
||||
// REF: (in Foo).getValue(Any?,Any?)
|
||||
|
||||
|
||||
Vendored
+6
-6
@@ -1,20 +1,20 @@
|
||||
var x : Int <caret>by Baz()
|
||||
|
||||
interface Foo {
|
||||
fun get(p1: Any?, p2: Any?): Int = 1
|
||||
fun getValue(p1: Any?, p2: Any?): Int = 1
|
||||
}
|
||||
|
||||
interface Bar {
|
||||
fun get(p1: Any?, p2: Any?): Int
|
||||
fun getValue(p1: Any?, p2: Any?): Int
|
||||
}
|
||||
|
||||
interface Zoo {
|
||||
fun set(p1: Any?, p2: Any?, p3: Any?)
|
||||
fun setValue(p1: Any?, p2: Any?, p3: Any?)
|
||||
}
|
||||
|
||||
class Baz: Foo, Bar, Zoo
|
||||
|
||||
// MULTIRESOLVE
|
||||
// REF: (in Bar).get(Any?,Any?)
|
||||
// REF: (in Foo).get(Any?,Any?)
|
||||
// REF: (in Zoo).set(Any?,Any?,Any?)
|
||||
// REF: (in Bar).getValue(Any?,Any?)
|
||||
// REF: (in Foo).getValue(Any?,Any?)
|
||||
// REF: (in Zoo).setValue(Any?,Any?,Any?)
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
var x : Int <caret>by Baz()
|
||||
|
||||
interface Foo {
|
||||
fun get(p1: Any?, p2: Any?): Int = 1
|
||||
fun getValue(p1: Any?, p2: Any?): Int = 1
|
||||
}
|
||||
|
||||
class Baz: Foo
|
||||
|
||||
// REF: (in Foo).get(Any?,Any?)
|
||||
// REF: (in Foo).getValue(Any?,Any?)
|
||||
+4
-4
@@ -2,12 +2,12 @@ var x: Int <caret>by Foo()
|
||||
|
||||
class Foo
|
||||
|
||||
fun Foo.get(_this: Any?, p: Any?): Int = 1
|
||||
fun Foo.set(_this: Any?, p: Any?, val: Any?) {}
|
||||
fun Foo.getValue(_this: Any?, p: Any?): Int = 1
|
||||
fun Foo.setValue(_this: Any?, p: Any?, val: Any?) {}
|
||||
fun Foo.propertyDelegated(p: Any?) {}
|
||||
|
||||
// MULTIRESOLVE
|
||||
// REF: (for Foo in <root>).get(Any?,Any?)
|
||||
// REF: (for Foo in <root>).set(Any?,Any?,Any?)
|
||||
// REF: (for Foo in <root>).getValue(Any?,Any?)
|
||||
// REF: (for Foo in <root>).setValue(Any?,Any?,Any?)
|
||||
// REF: (for Foo in <root>).propertyDelegated(Any?)
|
||||
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
var x: Int <caret>by Foo()
|
||||
|
||||
class Foo {
|
||||
fun get(_this: Any?, p: Any?): Int = 1
|
||||
fun set(_this: Any?, p: Any?, val: Any?) {}
|
||||
fun getValue(_this: Any?, p: Any?): Int = 1
|
||||
fun setValue(_this: Any?, p: Any?, val: Any?) {}
|
||||
fun propertyDelegated(p: Any?)
|
||||
}
|
||||
|
||||
// MULTIRESOLVE
|
||||
// REF: (in Foo).get(Any?,Any?)
|
||||
// REF: (in Foo).set(Any?,Any?,Any?)
|
||||
// REF: (in Foo).getValue(Any?,Any?)
|
||||
// REF: (in Foo).setValue(Any?,Any?,Any?)
|
||||
// REF: (in Foo).propertyDelegated(Any?)
|
||||
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@ import kotlin.properties.Delegates
|
||||
|
||||
val x: Int <caret>by Delegates.lazy {1}
|
||||
|
||||
// REF: (in kotlin.properties.ReadOnlyProperty).get(R,kotlin.PropertyMetadata)
|
||||
// REF: (in kotlin.properties.ReadOnlyProperty).getValue(R,kotlin.PropertyMetadata)
|
||||
+2
-2
@@ -3,5 +3,5 @@ import kotlin.properties.Delegates
|
||||
var x: Int <caret>by Delegates.notNull()
|
||||
|
||||
// MULTIRESOLVE
|
||||
// REF: (in kotlin.properties.ReadWriteProperty).get(R,kotlin.PropertyMetadata)
|
||||
// REF: (in kotlin.properties.ReadWriteProperty).set(R,kotlin.PropertyMetadata,T)
|
||||
// REF: (in kotlin.properties.ReadWriteProperty).getValue(R,kotlin.PropertyMetadata)
|
||||
// REF: (in kotlin.properties.ReadWriteProperty).setValue(R,kotlin.PropertyMetadata,T)
|
||||
Reference in New Issue
Block a user