Do not drop use of SAM-constructor when it's required for labeled return
This commit is contained in:
@@ -2,11 +2,21 @@ package redundantSamConstructor
|
||||
|
||||
import a.*
|
||||
|
||||
fun testNonApplicableAmbiguity() {
|
||||
fun testNonApplicableAmbiguity(p: Int) {
|
||||
GenericClassCantBeReplaced.staticFun1(JFunction0 { "" })
|
||||
GenericClassCantBeReplaced.staticFun2(JFunction0 { "" }, JFunction0 { "" })
|
||||
|
||||
val klass = GenericClassCantBeReplaced()
|
||||
klass.memberFun1(JFunction0 { "" })
|
||||
klass.memberFun2(JFunction0 { "" }, JFunction0 { "" })
|
||||
|
||||
MyJavaClass.staticFun1(Runnable {
|
||||
if (p > 0) return@Runnable
|
||||
print(1)
|
||||
})
|
||||
|
||||
MyJavaClass.staticFun2(Runnable { }, Runnable {
|
||||
if (p > 0) return@Runnable
|
||||
print(1)
|
||||
})
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
fun bar(p: Int) {
|
||||
SwingUtilities.invokeLater(<caret>object: Runnable {
|
||||
override fun run() {
|
||||
if (p < 0) return
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
})
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
fun bar(p: Int) {
|
||||
SwingUtilities.invokeLater(Runnable {
|
||||
if (p < 0) return@Runnable
|
||||
throw UnsupportedOperationException()
|
||||
})
|
||||
}
|
||||
@@ -133,4 +133,13 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>SamAdapterNeededBecauseOfLabeledReturn.kt</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="SamAdapterNeededBecauseOfLabeledReturn.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert object literal to lambda</problem_class>
|
||||
<description>Convert to lambda</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Reference in New Issue
Block a user