JVM IR: fix monitorEnterMonitorExit.kt
After an inaccurate merge of31936890andd6ed93b2, this test was now failing with the newly added assertion. It seems that currently the best way to handle it would be to special-case these two methods in SyntheticAccessorLowering.kt.
This commit is contained in:
+7
-1
@@ -48,7 +48,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
|
|||||||
irFile.transformChildrenVoid(this)
|
irFile.transformChildrenVoid(this)
|
||||||
|
|
||||||
for (accessor in pendingAccessorsToAdd) {
|
for (accessor in pendingAccessorsToAdd) {
|
||||||
assert(accessor.file == irFile) {
|
assert(accessor.fileOrNull == irFile || accessor.isAllowedToBeAddedToForeignFile()) {
|
||||||
"SyntheticAccessorLowering should not attempt to modify other files!\n" +
|
"SyntheticAccessorLowering should not attempt to modify other files!\n" +
|
||||||
"While lowering this file: ${irFile.render()}\n" +
|
"While lowering this file: ${irFile.render()}\n" +
|
||||||
"Trying to add this accessor: ${accessor.render()}"
|
"Trying to add this accessor: ${accessor.render()}"
|
||||||
@@ -560,4 +560,10 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
|
|||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// monitorEnter/monitorExit are the only functions which are accessed "illegally" (see kotlin/util/Synchronized.kt).
|
||||||
|
// Since they are intrinsified in the codegen, SyntheticAccessorLowering should not crash on attempt to add accessors for them.
|
||||||
|
private fun IrFunction.isAllowedToBeAddedToForeignFile(): Boolean =
|
||||||
|
(name.asString() == "access\$monitorEnter" || name.asString() == "access\$monitorExit") &&
|
||||||
|
context.irIntrinsics.getIntrinsic(symbol) != null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,16 +600,17 @@ private fun IrMemberAccessExpression.copyTypeAndValueArgumentsFrom(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val IrDeclaration.file: IrFile
|
val IrDeclaration.fileOrNull: IrFile?
|
||||||
get() = parent.let {
|
get() = when (val parent = parent) {
|
||||||
when (it) {
|
is IrFile -> parent
|
||||||
is IrFile -> it
|
is IrPackageFragment -> null
|
||||||
is IrPackageFragment -> TODO("Unknown file")
|
is IrDeclaration -> parent.fileOrNull
|
||||||
is IrDeclaration -> it.file
|
else -> TODO("Unexpected declaration parent")
|
||||||
else -> TODO("Unexpected declaration parent")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val IrDeclaration.file: IrFile
|
||||||
|
get() = fileOrNull ?: TODO("Unknown file")
|
||||||
|
|
||||||
val IrFunction.allTypeParameters: List<IrTypeParameter>
|
val IrFunction.allTypeParameters: List<IrTypeParameter>
|
||||||
get() = if (this is IrConstructor)
|
get() = if (this is IrConstructor)
|
||||||
parentAsClass.typeParameters + typeParameters
|
parentAsClass.typeParameters + typeParameters
|
||||||
|
|||||||
Reference in New Issue
Block a user