FIR checker: fix local type approximation on delegated property

Previously types of delegated property is not approximated, which can
cause local types to leak through public APIs.
This commit is contained in:
Tianyu Geng
2021-09-02 15:02:34 -07:00
committed by teamcityserver
parent 76e192fc8a
commit d3e8cc577c
12 changed files with 314 additions and 31 deletions
@@ -0,0 +1,30 @@
interface I1
interface I2
interface Lazy<T> {
operator fun getValue(a1: Any, a2: Any): T
}
fun <T> lazy(f: () -> T): Lazy<T> = throw Exception()
class A {
private inner class B {
val o1 = object : I1 {}
val o2 by lazy {
object : I1 {}
}
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val o3<!> = object : I1, I2 {} // FIR allows this since the containing class is private
<!AMBIGUOUS_ANONYMOUS_TYPE_INFERRED!>val o4<!> by lazy { // FIR allows this since the containing class is private
object : I1, I2 {}
}
private val privateO1 = object : I1 {}
private val privateO2 by lazy {
object : I1 {}
}
private val privateO3 = object : I1, I2 {}
private val privateO4 by lazy {
object : I1, I2 {}
}
}
}