Convert lambda to reference: range reduced to a call itself #KT-13661 Fixed
(cherry picked from commit f7b5d34)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a6e3aac7ca
commit
ec41289664
+8
@@ -7,4 +7,12 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with function reference</problem_class>
|
||||
<description>Convert lambda to reference</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>14</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with function reference</problem_class>
|
||||
<description>Convert lambda to reference</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -6,4 +6,10 @@ 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() }
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user