Multiple minor fixes.

This commit is contained in:
Dmitry Petrov
2016-09-02 18:09:48 +03:00
committed by Dmitry Petrov
parent da93f57afb
commit ea83407dce
11 changed files with 65 additions and 41 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.ir
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
interface IrElement {
@@ -73,7 +74,7 @@ fun IrElement.assertDetached() {
}
fun IrElement.throwNoSuchSlot(slot: Int): Nothing =
throw AssertionError("$this: no such slot $slot")
throw AssertionError("${this.render()}: no such slot $slot")
inline fun <reified T : IrElement> IrElement.assertCast(): T =
if (this is T) this else throw AssertionError("Expected ${T::class.simpleName}: $this")
@@ -27,7 +27,8 @@ import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
interface IrSyntheticPropertyAccessorDescriptor : PropertyAccessorDescriptor {
enum class Kind {
STATIC_PROPERTY
STATIC_PROPERTY,
MEMBER_PROPERTY
}
val kind: Kind
@@ -18,9 +18,7 @@ package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.ir.SETTER_ARGUMENT_INDEX
import org.jetbrains.kotlin.ir.assertDetached
import org.jetbrains.kotlin.ir.detach
import org.jetbrains.kotlin.ir.*
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrPropertyAccessorCallBase(
@@ -106,4 +104,17 @@ class IrSetterCallImpl(
argumentImpl?.detach()
argumentImpl = null
}
override fun getChild(slot: Int): IrElement? =
when (slot) {
SETTER_ARGUMENT_INDEX -> argumentImpl
else -> super.getChild(slot)
}
override fun replaceChild(slot: Int, newChild: IrElement) {
when (slot) {
SETTER_ARGUMENT_INDEX -> putArgument(slot, newChild.assertCast())
else -> super.replaceChild(slot, newChild)
}
}
}