[NI] Add regression tests for builder inference
Actual fix is c02dd720
^KT-33542 Fixed
^KT-33544 Fixed
^KT-36446 Fixed
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// Issues: KT-33542, KT-33544
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
interface In<in E> {
|
||||
suspend fun send(element: E)
|
||||
}
|
||||
|
||||
class InImpl<E>(val block: suspend In<E>.() -> Unit) : In<E> {
|
||||
override suspend fun send(element: E) {}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
public fun <T> builder(@BuilderInference block: suspend In<T>.() -> Unit) {
|
||||
InImpl(block)
|
||||
}
|
||||
|
||||
fun test33542() {
|
||||
builder {
|
||||
send(run {
|
||||
15
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun test33544(){
|
||||
builder {
|
||||
send(run {
|
||||
let { 0 } ?: 1
|
||||
0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = "OK"
|
||||
@@ -0,0 +1,41 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
fun box(): String {
|
||||
definition<Transaction> {
|
||||
conversion<Unit> {
|
||||
val offset by argument<Int> {
|
||||
// UnsupportedOperationException: no descriptor for type constructor of IntegerLiteralType[Int,Long,Byte,Short]
|
||||
defaultInt(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
interface Transaction
|
||||
fun <Transaction> definition(configure: DefinitionBuilder<Transaction>.() -> Unit): Unit {}
|
||||
class ArgumentBuilder<Value> {
|
||||
fun defaultInt(default: Int): Unit {}
|
||||
}
|
||||
class ConversionBuilder<Value> {
|
||||
fun <ArgumentValue> argument(
|
||||
configure: ArgumentBuilder<ArgumentValue>.() -> Unit
|
||||
): ArgumentDefinition<ArgumentValue> = null as ArgumentDefinition<ArgumentValue>
|
||||
}
|
||||
class DefinitionBuilder<Transaction> {
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
fun <Value> conversion(@BuilderInference configure: ConversionBuilder<Value>.() -> Unit): Unit {}
|
||||
}
|
||||
interface ArgumentDefinition<Value> {
|
||||
operator fun provideDelegate(thisRef: Any?, property: KProperty<*>): ArgumentReference<Value>
|
||||
}
|
||||
interface ArgumentReference<out Value> {
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Value
|
||||
}
|
||||
Reference in New Issue
Block a user