[tests] Add test data for KT-47989

This commit is contained in:
Stanislav Ruban
2023-11-30 22:02:41 +01:00
committed by Space Team
parent 83117fa464
commit cef44cfa7d
6 changed files with 179 additions and 0 deletions
@@ -0,0 +1,32 @@
// ISSUE: KT-47989
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
build {
object: TypeSourceInterface {
override fun produceTargetType() = getTypeVariable()
}
}
return "OK"
}
class TargetType
interface TypeSourceInterface {
fun produceTargetType(): TargetType
}
class Buildee<TV> {
fun getTypeVariable(): TV = storage
private var storage: TV = TargetType() as TV
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}
@@ -0,0 +1,29 @@
// ISSUE: KT-47989
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
build {
object: TypeSourceInterface {
override fun produceTargetTypeBuildee() = this@build
}
}
return "OK"
}
class TargetType
interface TypeSourceInterface {
fun produceTargetTypeBuildee(): Buildee<TargetType>
}
class Buildee<TV>
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}