FIR: set dispatch receiver parameter for inner class's constructor.

This commit is contained in:
Jinseong Jeon
2020-03-25 00:05:06 -07:00
committed by Mikhail Glukhikh
parent 4558d48481
commit cdf5a2a5a1
24 changed files with 63 additions and 33 deletions
@@ -331,10 +331,10 @@ class Fir2IrDeclarationStorage(
}
}
}
if (function !is FirConstructor) {
with(classifierStorage) {
val thisOrigin = IrDeclarationOrigin.DEFINED
val receiverTypeRef = if (function !is FirPropertyAccessor) function?.receiverTypeRef else parentPropertyReceiverType
with(classifierStorage) {
if (function !is FirConstructor) {
val receiverTypeRef = if (function !is FirPropertyAccessor) function?.receiverTypeRef else parentPropertyReceiverType
if (receiverTypeRef != null) {
extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset ->
declareThisReceiverParameter(
@@ -353,6 +353,15 @@ class Fir2IrDeclarationStorage(
thisOrigin = thisOrigin
)
}
} else {
// Set dispatch receiver parameter for inner class's constructor.
if (containingClass?.isInner == true) {
dispatchReceiverParameter = declareThisReceiverParameter(
parent,
thisType = containingClass.thisReceiver!!.type,
thisOrigin = thisOrigin
)
}
}
}
}
@@ -478,7 +487,7 @@ class Fir2IrDeclarationStorage(
isInline = false, isExternal = false, isPrimary = isPrimary, isExpect = false
).apply {
enterScope(descriptor)
}.bindAndDeclareParameters(constructor, descriptor, irParent, isStatic = true).apply {
}.bindAndDeclareParameters(constructor, descriptor, irParent, isStatic = false).apply {
leaveScope(descriptor)
}
}