K2: apply SAM if argument has postponed lambdas #KT-53966 Fixed
This commit is contained in:
committed by
Space Team
parent
5a9e8b3c0a
commit
898a9a0f2c
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
// FILE: C.java
|
||||
|
||||
public interface C { void on(String s); }
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A { void add(C c) {} }
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class B : A() {
|
||||
fun test(x: Any?) {
|
||||
add(foo { <!ARGUMENT_TYPE_MISMATCH!>{ _ : String -> Unit }<!> })
|
||||
add(x?.let { <!ARGUMENT_TYPE_MISMATCH!>{ _ : String -> Unit }<!> })
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> foo(f: () -> T): T = f()
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: C.java
|
||||
|
||||
public interface C { void on(String s); }
|
||||
|
||||
+34
-2
@@ -1,10 +1,42 @@
|
||||
fun main() {
|
||||
fun main(arg: Nothing?) {
|
||||
val flag = true
|
||||
consumeTicker(
|
||||
if (flag) null else <!ARGUMENT_TYPE_MISMATCH!>{ num -> num.<!UNRESOLVED_REFERENCE!>dec<!>() }<!>
|
||||
if (flag) null else { num -> num.dec() }
|
||||
)
|
||||
consumeTicker(
|
||||
select({ num -> num.dec() }, null)
|
||||
)
|
||||
consumeTicker(
|
||||
try { { num -> num.dec() } } catch (e: Exception) { null }
|
||||
)
|
||||
consumeTicker(
|
||||
arg ?: { num -> num.dec() }
|
||||
)
|
||||
consumeTicker(
|
||||
if (!flag) ::tick else null
|
||||
)
|
||||
consumeTicker(
|
||||
select(::tick, null)
|
||||
)
|
||||
consumeTicker(
|
||||
select(if (flag) null else ::tick, null)
|
||||
)
|
||||
consumeTicker(
|
||||
// In fact ::tick is not used here
|
||||
try { null } finally { ::tick }
|
||||
)
|
||||
consumeTicker(
|
||||
try { null } catch (e: Exception) { null } catch (e: Throwable) { ::tick }
|
||||
)
|
||||
consumeTicker(
|
||||
arg ?: ::tick
|
||||
)
|
||||
}
|
||||
|
||||
fun tick(num: Int) {}
|
||||
|
||||
fun <T> select(a: T, b: T): T = a
|
||||
|
||||
fun consumeTicker(ticker: Ticker?) {
|
||||
|
||||
}
|
||||
|
||||
+33
-1
@@ -1,10 +1,42 @@
|
||||
fun main() {
|
||||
fun main(arg: Nothing?) {
|
||||
val flag = true
|
||||
consumeTicker(
|
||||
if (flag) null else { num -> num.dec() }
|
||||
)
|
||||
consumeTicker(
|
||||
select({ num -> num.dec() }, null)
|
||||
)
|
||||
consumeTicker(
|
||||
try { { num -> num.dec() } } catch (e: Exception) { null }
|
||||
)
|
||||
consumeTicker(
|
||||
<!DEBUG_INFO_CONSTANT!>arg<!> ?: { num -> num.dec() }
|
||||
)
|
||||
consumeTicker(
|
||||
if (!flag) ::tick else null
|
||||
)
|
||||
consumeTicker(
|
||||
select(::tick, null)
|
||||
)
|
||||
consumeTicker(
|
||||
select(if (flag) null else ::tick, null)
|
||||
)
|
||||
consumeTicker(
|
||||
// In fact ::tick is not used here
|
||||
try { null } finally { ::tick }
|
||||
)
|
||||
consumeTicker(
|
||||
try { null } catch (e: Exception) { null } catch (e: Throwable) { ::tick }
|
||||
)
|
||||
consumeTicker(
|
||||
<!DEBUG_INFO_CONSTANT!>arg<!> ?: ::tick
|
||||
)
|
||||
}
|
||||
|
||||
fun tick(num: Int) {}
|
||||
|
||||
fun <T> select(a: T, b: T): T = a
|
||||
|
||||
fun consumeTicker(ticker: Ticker?) {
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,7 +1,9 @@
|
||||
package
|
||||
|
||||
public fun consumeTicker(/*0*/ ticker: Ticker?): kotlin.Unit
|
||||
public fun main(): kotlin.Unit
|
||||
public fun main(/*0*/ arg: kotlin.Nothing?): kotlin.Unit
|
||||
public fun </*0*/ T> select(/*0*/ a: T, /*1*/ b: T): T
|
||||
public fun tick(/*0*/ num: kotlin.Int): kotlin.Unit
|
||||
|
||||
public fun interface Ticker {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@@ -9,3 +11,4 @@ public fun interface Ticker {
|
||||
public abstract fun tick(/*0*/ num: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: Ticker.java
|
||||
|
||||
public interface Ticker {
|
||||
String tick(String s);
|
||||
}
|
||||
|
||||
// FILE: Tickers.java
|
||||
|
||||
public class Tickers {
|
||||
public static void consumeTicker(Ticker ticker) {}
|
||||
}
|
||||
|
||||
// FILE: Selectors.java
|
||||
|
||||
public class Selectors {
|
||||
public static <T> T select(T a, T b) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main(flag: Boolean) {
|
||||
Tickers.consumeTicker(if (flag) null else { s -> s + s })
|
||||
|
||||
Tickers.consumeTicker(Selectors.select({ s -> s + s }, null))
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public fun main(/*0*/ flag: kotlin.Boolean): kotlin.Unit
|
||||
|
||||
public open class Selectors {
|
||||
public constructor Selectors()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun </*0*/ T : kotlin.Any!> select(/*0*/ a: T!, /*1*/ b: T!): T!
|
||||
}
|
||||
|
||||
public interface Ticker {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun tick(/*0*/ s: kotlin.String!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Tickers {
|
||||
public constructor Tickers()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun consumeTicker(/*0*/ ticker: Ticker!): kotlin.Unit
|
||||
}
|
||||
Reference in New Issue
Block a user