FIR2IR: don't apply SAM conversion for type parameter based types
#KT-58893 Fixed #KT-58884 Fixed
This commit is contained in:
committed by
Space Team
parent
a832510487
commit
289dafa331
+47
@@ -0,0 +1,47 @@
|
||||
// ISSUE: KT-58893
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// IGNORE_INLINER: IR
|
||||
|
||||
// FILE: InOrder.java
|
||||
|
||||
public class InOrder {
|
||||
<T> T verify(T mock) {
|
||||
String s = mock.getClass().toString();
|
||||
if (!s.equals(TestKt.expected)) throw new IllegalStateException(s);
|
||||
return mock;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
inline fun <reified T : Any> mock(s: String = ""): T = MOCK as T
|
||||
|
||||
val MOCK = {}
|
||||
|
||||
inline fun inOrder(
|
||||
vararg mocks: Any,
|
||||
evaluation: InOrder.() -> Unit
|
||||
) {
|
||||
inOrder.evaluation()
|
||||
InOrder().evaluation()
|
||||
}
|
||||
|
||||
val inOrder = object : InOrder() {
|
||||
override fun <T : Any?> verify(mock: T): T {
|
||||
val s = mock!!.javaClass.toString()
|
||||
if (s != expected) throw IllegalStateException(s)
|
||||
return mock
|
||||
}
|
||||
}
|
||||
|
||||
lateinit var expected: String
|
||||
|
||||
fun box(): String {
|
||||
val mock = mock<() -> Unit>()
|
||||
expected = mock.javaClass.toString()
|
||||
inOrder(mock) {
|
||||
verify(mock)()
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
+1
-2
@@ -104,8 +104,7 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
|
||||
r: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable?
|
||||
CALL 'public open fun id <T> (x: @[FlexibleNullability] T of <root>.J.id?): @[FlexibleNullability] T of <root>.J.id? declared in <root>.J' type=@[FlexibleNullability] kotlin.Function0<kotlin.Unit>? origin=null
|
||||
<T>: @[FlexibleNullability] kotlin.Function0<kotlin.Unit>?
|
||||
x: TYPE_OP type=@[FlexibleNullability] kotlin.Function0<kotlin.Unit>? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] kotlin.Function0<kotlin.Unit>?
|
||||
GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ fun test7(a: Function1<Int, Int>) {
|
||||
}
|
||||
|
||||
fun test8(a: Function0<Unit>) {
|
||||
J().run1(r = id<@FlexibleNullability Function0<Unit>?>(x = a /*-> @FlexibleNullability Function0<Unit>? */) /*-> @FlexibleNullability Runnable? */)
|
||||
J().run1(r = id<@FlexibleNullability Function0<Unit>?>(x = a) /*-> @FlexibleNullability Runnable? */)
|
||||
}
|
||||
|
||||
fun test9() {
|
||||
|
||||
Reference in New Issue
Block a user