FIR2IR: Repeat the K1 behavior: SAM conversion with 'in' projection
It would be more consistently to prohibit the behavior from the unmuted test (see KT-52428), but it was decided to postpone the breaking change. Unfortunately, it didn't work to make a test where for computing star projections we would need to substitute other type parameters because effectively, it's not allowed to have SAM conversion when star projections/wildcard is based on a type parameter which bounds use other type parameters. ^KT-53552 In progress
This commit is contained in:
committed by
Space Team
parent
45eefab811
commit
05ca001310
@@ -1,8 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
|
||||
// IGNORE_BACKEND_K2: JVM_IR
|
||||
// FIR_STATUS: LambdaConversionException: Type mismatch for lambda argument 1: class java.lang.Object is not convertible to interface I1
|
||||
// JVM_IR it this case has an approximated type 'KFun<out Any>', which has a projected top-level argument.
|
||||
|
||||
fun <T> intersect(x: T, y: T): T = x
|
||||
|
||||
-4
@@ -1,7 +1,3 @@
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: "ClassCastException: String cannot be cast to StringBuilder".
|
||||
// FIR always takes the parameter type and erases type projections in it to obtain the SAM type. This is incorrect, see KT-51868 and KT-52428.
|
||||
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
Vendored
-4
@@ -1,7 +1,3 @@
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR
|
||||
// FIR status: the test passes but LambdaMetafactory is used, so bytecode text check fails.
|
||||
// In this case FIR behavior is fine but it works because of a hack in
|
||||
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 1 java/lang/invoke/LambdaMetafactory
|
||||
|
||||
// FILE: box.kt
|
||||
|
||||
fun box(): String {
|
||||
return Request.foo { x, y -> "OK" }
|
||||
}
|
||||
|
||||
// FILE: Request.java
|
||||
public class Request {
|
||||
public static String foo(Func<?, ?, ?> x) {
|
||||
return ((Func) x).bar(null, null).toString();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Func.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Func<T1 extends List<?>, T2 extends CharSequence, R> {
|
||||
R bar(T1 t1, T2 t2);
|
||||
}
|
||||
+3
-2
@@ -9,7 +9,8 @@ FILE fqName:<root> fileName:/box.kt
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (filter: @[FlexibleNullability] <root>.Condition<in @[FlexibleNullability] kotlin.String?>?) declared in <root>.J' type=<root>.J origin=null
|
||||
filter: TYPE_OP type=@[FlexibleNullability] <root>.Condition<@[FlexibleNullability] kotlin.String?>? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] <root>.Condition<@[FlexibleNullability] kotlin.String?>?
|
||||
GET_VAR 'filter: kotlin.Function1<kotlin.String, kotlin.Boolean>? declared in <root>.foo' type=kotlin.Function1<kotlin.String, kotlin.Boolean>? origin=null
|
||||
filter: TYPE_OP type=@[FlexibleNullability] <root>.Condition<kotlin.Any?>? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] <root>.Condition<kotlin.Any?>?
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.Function1<@[FlexibleNullability] kotlin.Any?, kotlin.Boolean>? origin=IMPLICIT_CAST typeOperand=@[FlexibleNullability] kotlin.Function1<@[FlexibleNullability] kotlin.Any?, kotlin.Boolean>?
|
||||
GET_VAR 'filter: kotlin.Function1<kotlin.String, kotlin.Boolean>? declared in <root>.foo' type=kotlin.Function1<kotlin.String, kotlin.Boolean>? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (filter: kotlin.Function1<kotlin.String, kotlin.Boolean>?): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
|
||||
Reference in New Issue
Block a user