KT-37448 'this' in delegating constructor call may refer to outer object
This commit is contained in:
+3
-2
@@ -368,10 +368,11 @@ class StatementGenerator(
|
||||
override fun visitSafeQualifiedExpression(expression: KtSafeQualifiedExpression, data: Nothing?): IrStatement =
|
||||
expression.selectorExpression!!.accept(this, data)
|
||||
|
||||
private fun isInsideClass(classDescriptor: ClassDescriptor): Boolean {
|
||||
private fun isThisForClassPhysicallyAvailable(classDescriptor: ClassDescriptor): Boolean {
|
||||
var scopeDescriptor: DeclarationDescriptor? = scopeOwner
|
||||
while (scopeDescriptor != null) {
|
||||
if (scopeDescriptor == classDescriptor) return true
|
||||
if (scopeDescriptor is ClassDescriptor && !scopeDescriptor.isInner) return false
|
||||
scopeDescriptor = scopeDescriptor.containingDeclaration
|
||||
}
|
||||
return false
|
||||
@@ -381,7 +382,7 @@ class StatementGenerator(
|
||||
val thisAsReceiverParameter = classDescriptor.thisAsReceiverParameter
|
||||
val thisType = kotlinType.toIrType()
|
||||
|
||||
return if (DescriptorUtils.isObject(classDescriptor) && !isInsideClass(classDescriptor)) {
|
||||
return if (DescriptorUtils.isObject(classDescriptor) && !isThisForClassPhysicallyAvailable(classDescriptor)) {
|
||||
IrGetObjectValueImpl(
|
||||
startOffset, endOffset,
|
||||
thisType,
|
||||
|
||||
Reference in New Issue
Block a user