Intentions: Convert function type receiver to parameter
#KT-14246 Fixed
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertFunctionTypeReceiverToParameterIntention
|
||||
@@ -0,0 +1,22 @@
|
||||
fun foo(f: <caret>Int.(Boolean) -> String) {
|
||||
1.f(false)
|
||||
bar(f)
|
||||
}
|
||||
|
||||
fun bar(f: (Int, Boolean) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int, Boolean) -> String = { i, b -> "$i $b"}
|
||||
|
||||
fun baz(f: (Int, Boolean) -> String) {
|
||||
fun g(i: Int, b: Boolean) = ""
|
||||
|
||||
foo(f)
|
||||
|
||||
foo(::g)
|
||||
|
||||
foo(lambda())
|
||||
|
||||
foo { b -> "${this + 1} $b" }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
fun foo(f: <caret>(Int, Boolean) -> String) {
|
||||
f(1, false)
|
||||
bar(f)
|
||||
}
|
||||
|
||||
fun bar(f: (Int, Boolean) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int, Boolean) -> String = { i, b -> "$i $b"}
|
||||
|
||||
fun baz(f: (Int, Boolean) -> String) {
|
||||
fun g(i: Int, b: Boolean) = ""
|
||||
|
||||
foo(f)
|
||||
|
||||
foo(::g)
|
||||
|
||||
foo(lambda())
|
||||
|
||||
foo { i, b -> "${i + 1} $b" }
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(f: Int.(Boolean) -> String): Int.(<caret>Boolean) -> String = f
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(f: Int.(<caret>Boolean) -> String) {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(f: <caret>Int.(() -> Unit) -> String) {
|
||||
1.f {}
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(f: <caret>(Int, () -> Unit) -> String) {
|
||||
f(1) {}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
fun foo(f: <caret>Int.() -> String) {
|
||||
1.f()
|
||||
bar(f)
|
||||
}
|
||||
|
||||
fun bar(f: (Int) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int) -> String = { i -> "$i"}
|
||||
|
||||
fun baz(f: (Int) -> String) {
|
||||
fun g(i: Int) = ""
|
||||
|
||||
foo(f)
|
||||
|
||||
foo(::g)
|
||||
|
||||
foo(lambda())
|
||||
|
||||
foo { "${this + 1}" }
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
fun foo(f: <caret>(Int) -> String) {
|
||||
f(1)
|
||||
bar(f)
|
||||
}
|
||||
|
||||
fun bar(f: (Int) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int) -> String = { i -> "$i"}
|
||||
|
||||
fun baz(f: (Int) -> String) {
|
||||
fun g(i: Int) = ""
|
||||
|
||||
foo(f)
|
||||
|
||||
foo(::g)
|
||||
|
||||
foo(lambda())
|
||||
|
||||
foo { i -> "${i + 1}" }
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
open class Foo(f: <caret>Int.(Boolean) -> String) {
|
||||
constructor(a: Int, f: (Int, Boolean) -> String) : this(f)
|
||||
constructor(a: Int) : this(::g)
|
||||
constructor(a: Int, b: Int) : this(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : this({ b -> "${this + 1} $b" })
|
||||
|
||||
init {
|
||||
1.f(false)
|
||||
bar(f)
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(f: (Int, Boolean) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int, Boolean) -> String = { i, b -> "$i $b"}
|
||||
|
||||
fun g(i: Int, b: Boolean) = ""
|
||||
|
||||
fun baz(f: (Int, Boolean) -> String) {
|
||||
Foo(f)
|
||||
|
||||
Foo(::g)
|
||||
|
||||
Foo(lambda())
|
||||
|
||||
Foo { b -> "${this + 1} $b" }
|
||||
}
|
||||
|
||||
class Baz1(f: (Int, Boolean) -> String) : Foo(f)
|
||||
class Baz2 : Foo(::g)
|
||||
class Baz3 : Foo(lambda())
|
||||
class Baz4 : Foo({ b -> "${this + 1} $b" })
|
||||
|
||||
class Baz5 : Foo {
|
||||
constructor(f: (Int, Boolean) -> String) : super(f)
|
||||
constructor(a: Int) : super(::g)
|
||||
constructor(a: Int, b: Int) : super(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : super({ b -> "${this + 1} $b" })
|
||||
}
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
open class Foo(f: <caret>(Int, Boolean) -> String) {
|
||||
constructor(a: Int, f: (Int, Boolean) -> String) : this(f)
|
||||
constructor(a: Int) : this(::g)
|
||||
constructor(a: Int, b: Int) : this(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : this({ i, b -> "${i + 1} $b" })
|
||||
|
||||
init {
|
||||
f(1, false)
|
||||
bar(f)
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(f: (Int, Boolean) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int, Boolean) -> String = { i, b -> "$i $b"}
|
||||
|
||||
fun g(i: Int, b: Boolean) = ""
|
||||
|
||||
fun baz(f: (Int, Boolean) -> String) {
|
||||
Foo(f)
|
||||
|
||||
Foo(::g)
|
||||
|
||||
Foo(lambda())
|
||||
|
||||
Foo { i, b -> "${i + 1} $b" }
|
||||
}
|
||||
|
||||
class Baz1(f: (Int, Boolean) -> String) : Foo(f)
|
||||
class Baz2 : Foo(::g)
|
||||
class Baz3 : Foo(lambda())
|
||||
class Baz4 : Foo({ i, b -> "${i + 1} $b" })
|
||||
|
||||
class Baz5 : Foo {
|
||||
constructor(f: (Int, Boolean) -> String) : super(f)
|
||||
constructor(a: Int) : super(::g)
|
||||
constructor(a: Int, b: Int) : super(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : super({ i, b -> "${i + 1} $b" })
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
open class Foo {
|
||||
constructor(f: <caret>Int.(Boolean) -> String) {
|
||||
1.f(false)
|
||||
bar(f)
|
||||
}
|
||||
|
||||
constructor(a: Int, f: (Int, Boolean) -> String) : this(f)
|
||||
constructor(a: Int) : this(::g)
|
||||
constructor(a: Int, b: Int) : this(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : this({ b -> "${this + 1} $b" })
|
||||
}
|
||||
|
||||
fun bar(f: (Int, Boolean) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int, Boolean) -> String = { i, b -> "$i $b"}
|
||||
|
||||
fun g(i: Int, b: Boolean) = ""
|
||||
|
||||
fun baz(f: (Int, Boolean) -> String) {
|
||||
Foo(f)
|
||||
|
||||
Foo(::g)
|
||||
|
||||
Foo(lambda())
|
||||
|
||||
Foo { b -> "${this + 1} $b" }
|
||||
}
|
||||
|
||||
class Baz1(f: (Int, Boolean) -> String) : Foo(f)
|
||||
class Baz2 : Foo(::g)
|
||||
class Baz3 : Foo(lambda())
|
||||
class Baz4 : Foo({ b -> "${this + 1} $b" })
|
||||
|
||||
class Baz5 : Foo {
|
||||
constructor(f: (Int, Boolean) -> String) : super(f)
|
||||
constructor(a: Int) : super(::g)
|
||||
constructor(a: Int, b: Int) : super(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : super({ b -> "${this + 1} $b" })
|
||||
}
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
open class Foo {
|
||||
constructor(f: <caret>(Int, Boolean) -> String) {
|
||||
f(1, false)
|
||||
bar(f)
|
||||
}
|
||||
|
||||
constructor(a: Int, f: (Int, Boolean) -> String) : this(f)
|
||||
constructor(a: Int) : this(::g)
|
||||
constructor(a: Int, b: Int) : this(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : this({ i, b -> "${i + 1} $b" })
|
||||
}
|
||||
|
||||
fun bar(f: (Int, Boolean) -> String) {
|
||||
|
||||
}
|
||||
|
||||
fun lambda(): (Int, Boolean) -> String = { i, b -> "$i $b"}
|
||||
|
||||
fun g(i: Int, b: Boolean) = ""
|
||||
|
||||
fun baz(f: (Int, Boolean) -> String) {
|
||||
Foo(f)
|
||||
|
||||
Foo(::g)
|
||||
|
||||
Foo(lambda())
|
||||
|
||||
Foo { i, b -> "${i + 1} $b" }
|
||||
}
|
||||
|
||||
class Baz1(f: (Int, Boolean) -> String) : Foo(f)
|
||||
class Baz2 : Foo(::g)
|
||||
class Baz3 : Foo(lambda())
|
||||
class Baz4 : Foo({ i, b -> "${i + 1} $b" })
|
||||
|
||||
class Baz5 : Foo {
|
||||
constructor(f: (Int, Boolean) -> String) : super(f)
|
||||
constructor(a: Int) : super(::g)
|
||||
constructor(a: Int, b: Int) : super(lambda())
|
||||
constructor(a: Int, b: Int, c: Int) : super({ i, b -> "${i + 1} $b" })
|
||||
}
|
||||
Reference in New Issue
Block a user