JVM_IR KT-42758 don't use 'this' for object self-reference by name
This commit is contained in:
-7
@@ -52,13 +52,6 @@ private class SingletonReferencesLowering(val context: JvmBackendContext) : File
|
||||
}
|
||||
|
||||
override fun visitGetObjectValue(expression: IrGetObjectValue): IrExpression {
|
||||
// When in an instance method of the object, use the dispatch receiver. Do not use the dispatch
|
||||
// receiver in the constructor, as in the case of an `object` the only way it can be used is
|
||||
// in a super constructor call argument (=> it has JVM type "uninitialized this" and is not usable)
|
||||
// while for a `companion object` all initializers are in `<clinit>` and have no receiver at all.
|
||||
thisOfClass(expression.symbol.owner, false)?.let {
|
||||
return IrGetValueImpl(expression.startOffset, expression.endOffset, it.symbol)
|
||||
}
|
||||
val instanceField = if (allScopes.any { it.irElement == expression.symbol.owner })
|
||||
context.cachedDeclarations.getPrivateFieldForObjectInstance(expression.symbol.owner) // Constructor or static method.
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user