Files
kotlin-fork/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt
T
Dmitry Petrov 202e992ae3 psi2ir: handle 'this' as reference to a super companion object
In super class constructor arguments, 'this' can be resolved
as a reference to a companion object of a superclass.
This breaks an assumption in psi2ir that 'this' can only refer to some
receiver from the current scope.

If 'this' refers to an 'object' (including 'companion obejct'),
and we are not inside the corresponding class scope,
then 'this' represents a reference to a singleton instance "by name"
(represented as IrGetObjectValue).
2019-01-21 10:56:02 +03:00

13 lines
248 B
Kotlin
Vendored

fun WithCompanion.test(): String {
object : WithCompanion(this) {}
return "OK"
}
open class WithCompanion(a: WithCompanion.Companion) {
companion object
}
fun box(): String {
return WithCompanion(WithCompanion.Companion).test()
}