[Low Level FIR] fix one case in CME when traversing FIR tree

Before extra child nodes of classes were visited during declaration by ClassId search.
If some other thread was mutating this tree, CME could happen

this is a fix of one case from ^KTIJ-21791
This commit is contained in:
Ilya Kirillov
2022-09-26 15:31:14 +02:00
parent fdf826208f
commit 913bfc0838
3 changed files with 55 additions and 6 deletions
@@ -81,3 +81,16 @@ public inline fun checkWithAttachmentBuilder(
buildErrorWithAttachment(message(), buildAttachment = buildAttachment)
}
}
@OptIn(ExperimentalContracts::class)
public inline fun requireWithAttachmentBuilder(
condition: Boolean,
message: () -> String,
buildAttachment: ExceptionAttachmentBuilder.() -> Unit = {}
) {
contract { returns() implies (condition) }
if (!condition) {
buildErrorWithAttachment(message(), buildAttachment = buildAttachment)
}
}