IR: improve "no such .. argument slot" exception message
Include the symbol signature, if it's available.
This commit is contained in:
+2
-2
@@ -21,14 +21,14 @@ abstract class IrFunctionAccessExpression(
|
||||
|
||||
override fun getValueArgument(index: Int): IrExpression? {
|
||||
if (index >= valueArgumentsCount) {
|
||||
throw AssertionError("$this: No such value argument slot: $index")
|
||||
throwNoSuchArgumentSlotException("value", index, valueArgumentsCount)
|
||||
}
|
||||
return argumentsByParameterIndex[index]
|
||||
}
|
||||
|
||||
override fun putValueArgument(index: Int, valueArgument: IrExpression?) {
|
||||
if (index >= valueArgumentsCount) {
|
||||
throw AssertionError("$this: No such value argument slot: $index")
|
||||
throwNoSuchArgumentSlotException("value", index, valueArgumentsCount)
|
||||
}
|
||||
argumentsByParameterIndex[index] = valueArgument
|
||||
}
|
||||
|
||||
+9
-2
@@ -39,14 +39,14 @@ abstract class IrMemberAccessExpression<S : IrSymbol>(typeArgumentsCount: Int) :
|
||||
|
||||
fun getTypeArgument(index: Int): IrType? {
|
||||
if (index >= typeArgumentsCount) {
|
||||
throw AssertionError("$this: No such type argument slot: $index")
|
||||
throwNoSuchArgumentSlotException("type", index, typeArgumentsCount)
|
||||
}
|
||||
return typeArgumentsByIndex[index]
|
||||
}
|
||||
|
||||
fun putTypeArgument(index: Int, type: IrType?) {
|
||||
if (index >= typeArgumentsCount) {
|
||||
throw AssertionError("$this: No such type argument slot: $index")
|
||||
throwNoSuchArgumentSlotException("type", index, typeArgumentsCount)
|
||||
}
|
||||
typeArgumentsByIndex[index] = type
|
||||
}
|
||||
@@ -62,6 +62,13 @@ abstract class IrMemberAccessExpression<S : IrSymbol>(typeArgumentsCount: Int) :
|
||||
}
|
||||
}
|
||||
|
||||
internal fun IrMemberAccessExpression<*>.throwNoSuchArgumentSlotException(kind: String, index: Int, total: Int): Nothing {
|
||||
throw AssertionError(
|
||||
"No such $kind argument slot in ${this::class.java.simpleName}: $index (total=$total)" +
|
||||
(symbol.signature?.let { ".\nSymbol: $it" } ?: "")
|
||||
)
|
||||
}
|
||||
|
||||
fun IrMemberAccessExpression<*>.getTypeArgument(typeParameterDescriptor: TypeParameterDescriptor): IrType? =
|
||||
getTypeArgument(typeParameterDescriptor.index)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user