Files
kotlin-fork/idea/testData/inspections/convertLambdaToReference/test.kt
T
Mikhail Glukhikh ec41289664 Convert lambda to reference: range reduced to a call itself #KT-13661 Fixed
(cherry picked from commit f7b5d34)
2016-09-01 14:44:00 +03:00

15 lines
530 B
Kotlin
Vendored

// Mostly tested as intention. Here we just test shouldSuggestToConvert()
// Should suggest to convert
class TheirWrapper(val x: Int)
val x = { y: Int -> TheirWrapper(y) }
// Should not suggest to convert (too long reference)
fun foo(arg: TheirWrapper, convert: (TheirWrapper) -> String) = convert(arg)
val y = foo(TheirWrapper(42)) { it.toString() }
// Also should suggest to convert, but only call should be highlighted
fun bar(arg: Int, convert: (Int) -> TheirWrapper) = convert(arg)
val z = bar(42) {
TheirWrapper(it)
}