[IR] Remove custom error messages for missing IrDeclaration.parent

This is to remove custom logic from those classes,
so that source generator will be able to generate
them in a straight-forward way.
Otherwise, it would need to be thought about those special cases, which
is better to be avoided.

It is also a small step for future work,
which likely involves making parent property nullable.

Unfortunately, this change causes a loss of some details from exception
messages.

^KT-65773 In Progress
This commit is contained in:
Wojciech Litewka
2024-02-15 11:49:29 +01:00
committed by Space Team
parent f6b2a5915e
commit 92c56d0535
2 changed files with 2 additions and 14 deletions
@@ -30,13 +30,7 @@ class IrScriptImpl(
) : IrScript() {
override var origin: IrDeclarationOrigin = SCRIPT_ORIGIN
private var _parent: IrDeclarationParent? = null
override var parent: IrDeclarationParent
get() = _parent
?: throw UninitializedPropertyAccessException("Parent not initialized: $this")
set(v) {
_parent = v
}
override lateinit var parent: IrDeclarationParent
override var annotations: List<IrConstructorCall> = SmartList()
@@ -39,13 +39,7 @@ class IrVariableImpl(
override var isConst: Boolean,
override var isLateinit: Boolean
) : IrVariable() {
private var _parent: IrDeclarationParent? = null
override var parent: IrDeclarationParent
get() = _parent
?: throw UninitializedPropertyAccessException("Parent not initialized: $this")
set(v) {
_parent = v
}
override lateinit var parent: IrDeclarationParent
override var annotations: List<IrConstructorCall> = emptyList()