// ISSUE: KT-63840 // IGNORE_LIGHT_ANALYSIS // IGNORE_BACKEND_K1: ANY // REASON: red code (see corresponding diagnostic test) fun box(): String { build { if (true) replaceTypeVariable(TargetType()) else DifferentType() } return "OK" } class TargetType class DifferentType class Buildee { fun replaceTypeVariable(value: TV): TV { val temp = storage; storage = value; return temp } private var storage: TV = TargetType() as TV } fun build(instructions: Buildee.() -> Unit): Buildee { return Buildee().apply(instructions) }