05ca001310
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
44 lines
919 B
Kotlin
Vendored
44 lines
919 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// JVM_TARGET: 1.8
|
|
// WITH_STDLIB
|
|
|
|
// CHECK_BYTECODE_TEXT
|
|
// JVM_IR_TEMPLATES
|
|
// 0 java/lang/invoke/LambdaMetafactory
|
|
|
|
// FILE: box.kt
|
|
|
|
fun box(): String {
|
|
var result = "Fail"
|
|
val r = Request { obj: CharSequence ->
|
|
result = obj as String
|
|
}
|
|
r.deliver("OK")
|
|
return result
|
|
}
|
|
|
|
// FILE: Request.java
|
|
|
|
public class Request {
|
|
private final Consumer<? super StringBuilder> consumer;
|
|
|
|
public Request(Consumer<? super StringBuilder> consumer) {
|
|
this.consumer = consumer;
|
|
}
|
|
|
|
public void deliver(Object response) {
|
|
deliverResponse(consumer, response);
|
|
}
|
|
|
|
public <K extends CharSequence> void deliverResponse(final Consumer<K> consumer, Object rawResponse) {
|
|
K response = (K) rawResponse;
|
|
consumer.accept(response);
|
|
}
|
|
}
|
|
|
|
// FILE: Consumer.java
|
|
|
|
public interface Consumer<T extends CharSequence> {
|
|
void accept(T t);
|
|
}
|