[BE] Add context receivers to inline class replacements
This commit is contained in:
committed by
TeamCityServer
parent
c148a12e4b
commit
a3cf1a11bf
+10
-1
@@ -184,6 +184,7 @@ class MemoizedInlineClassReplacements(
|
|||||||
// The function's name will be mangled, so preserve the old receiver name.
|
// The function's name will be mangled, so preserve the old receiver name.
|
||||||
this, index = -1, name = Name.identifier(function.extensionReceiverName(context.state))
|
this, index = -1, name = Name.identifier(function.extensionReceiverName(context.state))
|
||||||
)
|
)
|
||||||
|
contextReceiverParametersCount = function.contextReceiverParametersCount
|
||||||
valueParameters = function.valueParameters.mapIndexed { index, parameter ->
|
valueParameters = function.valueParameters.mapIndexed { index, parameter ->
|
||||||
parameter.copyTo(this, index = index, defaultValue = null).also {
|
parameter.copyTo(this, index = index, defaultValue = null).also {
|
||||||
// Assuming that constructors and non-override functions are always replaced with the unboxed
|
// Assuming that constructors and non-override functions are always replaced with the unboxed
|
||||||
@@ -205,13 +206,21 @@ class MemoizedInlineClassReplacements(
|
|||||||
type = function.parentAsClass.defaultType, origin = IrDeclarationOrigin.MOVED_DISPATCH_RECEIVER
|
type = function.parentAsClass.defaultType, origin = IrDeclarationOrigin.MOVED_DISPATCH_RECEIVER
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (function.contextReceiverParametersCount != 0) {
|
||||||
|
function.valueParameters.take(function.contextReceiverParametersCount).forEachIndexed { i, contextReceiver ->
|
||||||
|
newValueParameters += contextReceiver.copyTo(
|
||||||
|
this, index = newValueParameters.size, name = Name.identifier("contextReceiver$i"),
|
||||||
|
origin = IrDeclarationOrigin.MOVED_CONTEXT_RECEIVER
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
function.extensionReceiverParameter?.let {
|
function.extensionReceiverParameter?.let {
|
||||||
newValueParameters += it.copyTo(
|
newValueParameters += it.copyTo(
|
||||||
this, index = newValueParameters.size, name = Name.identifier(function.extensionReceiverName(context.state)),
|
this, index = newValueParameters.size, name = Name.identifier(function.extensionReceiverName(context.state)),
|
||||||
origin = IrDeclarationOrigin.MOVED_EXTENSION_RECEIVER
|
origin = IrDeclarationOrigin.MOVED_EXTENSION_RECEIVER
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
for (parameter in function.valueParameters) {
|
for (parameter in function.valueParameters.drop(function.contextReceiverParametersCount)) {
|
||||||
newValueParameters += parameter.copyTo(this, index = newValueParameters.size, defaultValue = null).also {
|
newValueParameters += parameter.copyTo(this, index = newValueParameters.size, defaultValue = null).also {
|
||||||
// See comment next to a similar line above.
|
// See comment next to a similar line above.
|
||||||
it.defaultValue = parameter.defaultValue?.patchDeclarationParents(this)
|
it.defaultValue = parameter.defaultValue?.patchDeclarationParents(this)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ interface IrDeclarationOrigin {
|
|||||||
object METHOD_HANDLER_IN_DEFAULT_FUNCTION : IrDeclarationOriginImpl("METHOD_HANDLER_IN_DEFAULT_FUNCTION", isSynthetic = true)
|
object METHOD_HANDLER_IN_DEFAULT_FUNCTION : IrDeclarationOriginImpl("METHOD_HANDLER_IN_DEFAULT_FUNCTION", isSynthetic = true)
|
||||||
object MOVED_DISPATCH_RECEIVER : IrDeclarationOriginImpl("MOVED_DISPATCH_RECEIVER")
|
object MOVED_DISPATCH_RECEIVER : IrDeclarationOriginImpl("MOVED_DISPATCH_RECEIVER")
|
||||||
object MOVED_EXTENSION_RECEIVER : IrDeclarationOriginImpl("MOVED_EXTENSION_RECEIVER")
|
object MOVED_EXTENSION_RECEIVER : IrDeclarationOriginImpl("MOVED_EXTENSION_RECEIVER")
|
||||||
|
object MOVED_CONTEXT_RECEIVER : IrDeclarationOriginImpl("MOVED_CONTEXT_RECEIVER")
|
||||||
|
|
||||||
object FILE_CLASS : IrDeclarationOriginImpl("FILE_CLASS")
|
object FILE_CLASS : IrDeclarationOriginImpl("FILE_CLASS")
|
||||||
object SYNTHETIC_FILE_CLASS : IrDeclarationOriginImpl("SYNTHETIC_FILE_CLASS", isSynthetic = true)
|
object SYNTHETIC_FILE_CLASS : IrDeclarationOriginImpl("SYNTHETIC_FILE_CLASS", isSynthetic = true)
|
||||||
|
|||||||
Reference in New Issue
Block a user