Files
kotlin-fork/compiler/testData/diagnostics/tests/builderInference/issues/kt53422a.fir.kt
T
2024-01-11 10:32:12 +00:00

35 lines
1.0 KiB
Kotlin
Vendored

// ISSUE: KT-53422
// CHECK_TYPE_WITH_EXACT
fun test() {
val buildee = buildFromValue(
innerBuild { setInnerTypeVariable(TargetType()) },
{ <!BUILDER_INFERENCE_STUB_RECEIVER!>it<!>.placeholderExtensionInvokeOnInnerBuildee() }
)
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<InnerBuildee<TargetType>>>(buildee)
}
class TargetType
class InnerBuildee<ITV> {
fun setInnerTypeVariable(value: ITV) { storage = value }
private var storage: ITV = null!!
}
fun <EITV> InnerBuildee<EITV>.placeholderExtensionInvokeOnInnerBuildee() {}
class Buildee<TV>
fun <IPTV> innerBuild(instructions: InnerBuildee<IPTV>.() -> Unit): InnerBuildee<IPTV> {
return InnerBuildee<IPTV>().apply(instructions)
}
fun <PTV> buildFromValue(value: PTV, instructions: Buildee<PTV>.(PTV) -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply { instructions(value) }
}