[tests] Add test data for KT-53422

This commit is contained in:
Stanislav Ruban
2023-11-30 22:04:40 +01:00
committed by Space Team
parent 96e12584a1
commit 982e8133ba
6 changed files with 215 additions and 0 deletions
@@ -0,0 +1,35 @@
// ISSUE: KT-53422
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
buildFromValue(
innerBuild { setInnerTypeVariable(TargetType()) },
{ it.placeholderExtensionInvokeOnInnerBuildee() }
)
return "OK"
}
class TargetType
class InnerBuildee<ITV> {
fun setInnerTypeVariable(value: ITV) { storage = value }
private var storage: ITV = TargetType() as ITV
}
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) }
}
@@ -0,0 +1,38 @@
// ISSUE: KT-53422
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: ANY
// REASON: red code (see corresponding diagnostic test)
fun box(): String {
stepByStepBuild(
{
it.concreteTypeMemberProperty
TargetType()
},
{
consumeTargetTypeBase(it)
}
)
return "OK"
}
class ConcreteType
open class TargetTypeBase {
val concreteTypeMemberProperty: ConcreteType = ConcreteType()
}
class TargetType: TargetTypeBase()
fun consumeTargetTypeBase(value: TargetTypeBase) {}
class Buildee<TV>
fun <PTV> stepByStepBuild(
instructionsA: Buildee<PTV>.(PTV) -> PTV,
instructionsB: Buildee<PTV>.(PTV) -> Unit,
): Buildee<PTV> {
return Buildee<PTV>().apply { instructionsB(instructionsA(TargetType() as PTV)) }
}