FIR: Fix incorrectly serialized type
See the test added: there's a non-denotable T!! type inside flexible type that wasn't handled before. ConeKotlinType::contains handles flexible types content and some other cases Also, it has better asymptotics
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: CachedValuesManager.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
public class CachedValuesManager {
|
||||
public @NotNull <T> CachedValue<T> createCachedValue(final @NotNull CachedValueProvider<T> provider) {
|
||||
return new CachedValue<T>() {
|
||||
public T getValue() {
|
||||
return provider.compute().value;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: CachedValueProvider.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface CachedValueProvider<T> {
|
||||
@Nullable
|
||||
Result<T> compute();
|
||||
|
||||
class Result<T> {
|
||||
public final T value;
|
||||
public Result(@Nullable T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: CachedValue.java
|
||||
public interface CachedValue<T> {
|
||||
T getValue();
|
||||
}
|
||||
|
||||
// FILE: lib.kt
|
||||
|
||||
// Inferred as CachedValue<ft<T!!, T>>! and T!! should be approximated
|
||||
fun <T> cachedValue(manager: CachedValuesManager, createValue: () -> T) =
|
||||
manager.createCachedValue {
|
||||
CachedValueProvider.Result(
|
||||
createValue()
|
||||
)
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
val value = cachedValue(CachedValuesManager()) { Pair("O", "K") }.value
|
||||
|
||||
return value.first + value.second
|
||||
}
|
||||
Reference in New Issue
Block a user