Files
kotlin-fork/compiler/testData/diagnostics/tests/declarationChecks/localObjectInInnerClass.kt
T
Tianyu Geng d3e8cc577c 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.
2021-09-16 22:38:08 +03:00

30 lines
844 B
Kotlin
Vendored

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 {}
}
}
}