Convert reference to lambda intention introduced #KT-13393 Fixed
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertReferenceToLambdaIntention
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
val x = 1
|
||||
// Not supported yet
|
||||
val y = <caret>x::hashCode
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Person(val name: String)
|
||||
|
||||
val x = listOf("Jack", "Tom").map(<caret>::Person)
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Person(val name: String)
|
||||
|
||||
val x = listOf("Jack", "Tom").map { Person(it) }
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val x = listOf("123", "4567").map(<caret>String::toInt)
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val x = listOf("123", "4567").map { it.toInt() }
|
||||
@@ -0,0 +1,3 @@
|
||||
val Any.name: String get() = toString()
|
||||
|
||||
val converted = <caret>Any::name
|
||||
@@ -0,0 +1,3 @@
|
||||
val Any.name: String get() = toString()
|
||||
|
||||
val converted = { any: Any -> any.name }
|
||||
@@ -0,0 +1,13 @@
|
||||
class Foo {
|
||||
class Bar {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun use() {
|
||||
val f: (Foo.Bar) -> Unit = <caret>Foo.Bar::foo
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class Foo {
|
||||
class Bar {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
fun use() {
|
||||
val f: (Foo.Bar) -> Unit = { bar: Foo.Bar -> bar.foo() }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Owner {
|
||||
inner class Inner
|
||||
|
||||
val x = <caret>Owner::Inner
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Owner {
|
||||
inner class Inner
|
||||
|
||||
val x = { owner: Owner -> owner.Inner() }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val x = listOf("123", "4567").map(<caret>String::length)
|
||||
@@ -0,0 +1,3 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val x = listOf("123", "4567").map { it.length }
|
||||
@@ -0,0 +1,3 @@
|
||||
class Person(val name: String)
|
||||
|
||||
val reader = <caret>Person::name
|
||||
@@ -0,0 +1,3 @@
|
||||
class Person(val name: String)
|
||||
|
||||
val reader = { person: Person -> person.name }
|
||||
@@ -0,0 +1,3 @@
|
||||
fun Int?.foo() = this?.hashCode() ?: 0
|
||||
|
||||
val x = <caret>Int?::foo
|
||||
@@ -0,0 +1,3 @@
|
||||
fun Int?.foo() = this?.hashCode() ?: 0
|
||||
|
||||
val x = { i: Int? -> i.foo() }
|
||||
@@ -0,0 +1,3 @@
|
||||
fun Int.foo(x: Int) = this - x
|
||||
|
||||
val x = <caret>Int::foo
|
||||
@@ -0,0 +1,3 @@
|
||||
fun Int.foo(x: Int) = this - x
|
||||
|
||||
val x = { i: Int, x: Int -> i.foo(x) }
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(y: Int) = y
|
||||
|
||||
val x = <caret>::foo
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(y: Int) = y
|
||||
|
||||
val x = { y: Int -> foo(y) }
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(x: Int, y: Int, z: Int) = x - y / z
|
||||
|
||||
val x = <caret>::foo
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(x: Int, y: Int, z: Int) = x - y / z
|
||||
|
||||
val x = { x: Int, y: Int, z: Int -> foo(x, y, z) }
|
||||
@@ -0,0 +1 @@
|
||||
val x = <caret>Int::toString
|
||||
@@ -0,0 +1 @@
|
||||
val x = { i: Int -> i.toString() }
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Wrapper<T>(private val x: T) {
|
||||
fun unwrap() = x
|
||||
}
|
||||
|
||||
val unwrapped = listOf(Wrapper(1), Wrapper("B")).map(<caret>Wrapper<out Any>::unwrap)
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Wrapper<T>(private val x: T) {
|
||||
fun unwrap() = x
|
||||
}
|
||||
|
||||
val unwrapped = listOf(Wrapper(1), Wrapper("B")).map { it.unwrap() }
|
||||
Reference in New Issue
Block a user