IR: minor, fix offset check in IrElement.sourceElement.

There's also SYNTHETIC_OFFSET, which is used for example for
declarations generated by interface delegation, for which
`sourceElement` threw exception. It didn't lead to any user-visible
error AFAIK, I've encountered this problem while working on 5f2ff06296.
This commit is contained in:
Alexander Udalov
2023-07-31 19:25:09 +02:00
committed by Space Team
parent 2d728727da
commit 19653df1c6
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.backend.common
import org.jetbrains.kotlin.AbstractKtSourceElement
import org.jetbrains.kotlin.KtOffsetsOnlySourceElement
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.IrFile
fun CommonBackendContext.reportWarning(message: String, irFile: IrFile?, irElement: IrElement) {
@@ -33,5 +32,5 @@ fun <E> MutableList<E>.pop() = this.removeAt(size - 1)
fun <E> MutableList<E>.peek(): E? = if (size == 0) null else this[size - 1]
fun IrElement.sourceElement(): AbstractKtSourceElement? =
if (startOffset != UNDEFINED_OFFSET) KtOffsetsOnlySourceElement(this.startOffset, this.endOffset)
if (startOffset >= 0) KtOffsetsOnlySourceElement(this.startOffset, this.endOffset)
else null