Propagate inference session into declaration analyzers
It prevents missing inference session for local declaration (local functions, local classes or objects) ^KT-44801 Fixed
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
interface Callback {
|
||||
fun onSuccess()
|
||||
}
|
||||
|
||||
public interface SendChannelX<in E> {
|
||||
public fun close(cause: Throwable? = null): Boolean
|
||||
}
|
||||
|
||||
public interface ProducerScopeX<in E> {
|
||||
public val channel: SendChannelX<E>
|
||||
fun foo(x: E)
|
||||
}
|
||||
|
||||
public class FlowX<out T> {}
|
||||
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
public fun <T> callbackFlowX(@BuilderInference block: ProducerScopeX<T>.() -> Unit): FlowX<T> = FlowX()
|
||||
|
||||
fun foo(): FlowX<String> = callbackFlowX {
|
||||
object : Callback {
|
||||
override fun onSuccess() {
|
||||
channel.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE
|
||||
|
||||
interface Some {
|
||||
fun method(): Unit
|
||||
}
|
||||
|
||||
fun <S> elvis(nullable: S?, notNullable: S): S = TODO()
|
||||
|
||||
fun <R : Some> Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO()
|
||||
|
||||
fun test(derived: Some) {
|
||||
val expected: Some = derived.doWithPredicate { it.method() } ?: TODO()
|
||||
val expected2: Some = elvis(derived.doWithPredicate { it.<!UNRESOLVED_REFERENCE!>method<!>() }, TODO())
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE
|
||||
|
||||
interface Some {
|
||||
|
||||
Reference in New Issue
Block a user