Create from Usage: Implement "Create function" on callable references
#KT-10283 Fixed
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun <T, U> T.map(f: T.() -> U) = f()
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
consume(1.map(::<caret>foo))
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun <T, U> T.map(f: T.() -> U) = f()
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
fun foo(i: Int): String {
|
||||
<selection>throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.</selection>
|
||||
}
|
||||
consume(1.map(::foo))
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create extension function 'foo'" "true"
|
||||
fun <T, U> T.map(f: T.() -> U) = f()
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
consume(1.map(Int::<caret>foo))
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Create extension function 'foo'" "true"
|
||||
fun <T, U> T.map(f: T.() -> U) = f()
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
consume(1.map(Int::foo))
|
||||
}
|
||||
|
||||
fun Int.foo(): String {
|
||||
<selection>throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.</selection>
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun <T, U> T.map(f: (T) -> U) = f(this)
|
||||
|
||||
fun test() {
|
||||
1.map(::<caret>foo)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun <T, U> T.map(f: (T) -> U) = f(this)
|
||||
|
||||
fun test() {
|
||||
fun foo(i: Int): Any {
|
||||
<selection>throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.</selection>
|
||||
}
|
||||
1.map(::foo)
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// "Create function 'foo'" "false"
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Rename reference
|
||||
// ERROR: Unresolved reference: foo
|
||||
fun bar(n: Int) = "$n"
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
consume(bar(::<caret>foo))
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun <T, U> T.map(f: (T) -> U) = f(this)
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
consume(1.map(::<caret>foo))
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Create function 'foo'" "true"
|
||||
fun <T, U> T.map(f: (T) -> U) = f(this)
|
||||
|
||||
fun consume(s: String) {}
|
||||
|
||||
fun test() {
|
||||
fun foo(i: Int): String {
|
||||
<selection>throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.</selection>
|
||||
}
|
||||
consume(1.map(::foo))
|
||||
}
|
||||
Reference in New Issue
Block a user