From 7995684d075084d37179c7a394b19507ea0fc219 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 13 Apr 2017 15:55:18 +0300 Subject: [PATCH] Bind declaration symbols in DeepCopyIrTree. Check that symbols are properly bound. --- .../org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt b/compiler/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt index 6c40fad78ee..dceb15239ef 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt +++ b/compiler/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt @@ -101,6 +101,8 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() { private class IrVerifier : IrElementVisitorVoid { private val errors = ArrayList() + private val symbolForDeclaration = HashMap() + val hasErrors get() = errors.isNotEmpty() val errorsAsMessage get() = errors.joinToString(prefix = "IR verifier errors:\n", separator = "\n") @@ -183,9 +185,14 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() { expression.setter?.checkBinding("setter", expression) } - private fun IrSymbol.checkBinding(kind: String, owner: IrElement) { + private fun IrSymbol.checkBinding(kind: String, irElement: IrElement) { if (!isBound) { - error("$kind ${javaClass.simpleName} ${descriptor} is unbound: ${owner.render()}") + error("${javaClass.simpleName} $descriptor is unbound @$kind ${irElement.render()}") + } + + val otherSymbol = symbolForDeclaration.getOrPut(owner) { this } + if (this != otherSymbol) { + error("Multiple symbols for $descriptor @$kind ${irElement.render()}") } }