Files
kotlin-fork/compiler/testData/diagnostics/tests/delegatedProperty/inference/nestedPartiallyResolvedCalls.kt
T
Denis.Zharkov 555d8eeb25 K2: Fix false-positive DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE
For explanation, see nestedPartiallyResolvedCallsSimple.k

The problem was caused by "select" variable is being leaked to the
inference session of delegate while it should not happen because
it doesn't belong to the common system of `KotlinVal { ..` call,
as we complete it with fixing `E` variable during completion
for `A(select(null, fun(): Int { return 1 }))`.

The root of the problem is that we were adding all the partial
nested calls to the session, while in fact we only need there
the top-level one.

^KT-57543 Fixed
2023-04-28 16:20:06 +02:00

35 lines
769 B
Kotlin
Vendored

// FIR_IDENTICAL
// WITH_STDLIB
// ISSUE: KT-57543
// FILE: JavaClass.java
import kotlin.jvm.functions.Function0;
public class JavaClass {
public static class Val<T> {
private final Function0<T> initializer;
public Val(Function0<T> initializer) {
this.initializer = initializer;
}
public final T getValue(Object instance, Object metadata) {
return initializer.invoke();
}
}
public static <T> Val<T> lazySoft(Function0<T> initializer) {
return new Val<T>(initializer);
}
}
// FILE: main.kt
class A(
val c: Int? = 0,
myType: (() -> Int)? = null
) {
val arguments: A by JavaClass.lazySoft {
A(myType = if (false) null else fun(): Int { return c!! })
}
}