Don't try to infer postponed variables on lambdas without BuilderInference annotation

^KT-39618 Fixed
This commit is contained in:
Victor Petukhov
2020-07-14 17:18:13 +03:00
parent 9e737156dd
commit b0c96a61ec
10 changed files with 85 additions and 1 deletions
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
import kotlin.experimental.ExperimentalTypeInference
@UseExperimental(ExperimentalTypeInference::class)
fun <R> combined(
check: () -> Unit,
@BuilderInference block: TestInterface<R>.() -> Unit
): R = TODO()
interface TestInterface<R> {
fun emit(r: R)
}
fun test() {
val ret = combined({ }) {
<!INAPPLICABLE_CANDIDATE!>emit<!>(1)
}
}
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
import kotlin.experimental.ExperimentalTypeInference
@UseExperimental(ExperimentalTypeInference::class)
fun <R> combined(
check: () -> Unit,
@BuilderInference block: TestInterface<R>.() -> Unit
): R = TODO()
interface TestInterface<R> {
fun emit(r: R)
}
fun test() {
val ret = combined({ }) {
emit(1)
}
}
@@ -0,0 +1,11 @@
package
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R> combined(/*0*/ check: () -> kotlin.Unit, /*1*/ @kotlin.BuilderInference block: TestInterface<R>.() -> kotlin.Unit): R
public fun test(): kotlin.Unit
public interface TestInterface</*0*/ R> {
public abstract fun emit(/*0*/ r: R): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}