Use ISE instead of NPE in serialization
This commit is contained in:
@@ -392,3 +392,15 @@ inline fun IrBuilderWithScope.irBlockBody(
|
||||
startOffset,
|
||||
endOffset
|
||||
).blockBody(body)
|
||||
|
||||
fun IrBuilderWithScope.irThrowIse(origin: IrStatementOrigin? = null) =
|
||||
IrCallImpl(
|
||||
startOffset, endOffset,
|
||||
context.irBuiltIns.nothingType,
|
||||
context.irBuiltIns.throwIseSymbol,
|
||||
context.irBuiltIns.throwIseSymbol.descriptor,
|
||||
typeArgumentsCount = 0,
|
||||
valueArgumentsCount = 0,
|
||||
origin = origin
|
||||
)
|
||||
|
||||
|
||||
@@ -295,7 +295,6 @@ class IrBuiltIns(
|
||||
const val EQEQ = "EQEQ"
|
||||
const val EQEQEQ = "EQEQEQ"
|
||||
const val IEEE754_EQUALS = "ieee754equals"
|
||||
const val THROW_NPE = "THROW_NPE"
|
||||
const val THROW_CCE = "THROW_CCE"
|
||||
const val THROW_ISE = "THROW_ISE"
|
||||
const val NO_WHEN_BRANCH_MATCHED_EXCEPTION = "noWhenBranchMatchedException"
|
||||
|
||||
+2
-2
@@ -351,7 +351,7 @@ class SerializerIrGenerator(val irClass: IrClass, override val compilerContext:
|
||||
+irSetVar(indexVar.symbol, irInvoke(localInput.get(), readElementF, localSerialDesc.get()))
|
||||
+irWhen {
|
||||
// if index == -2 (READ_ALL) todo...
|
||||
+IrBranchImpl(irEquals(indexVar.get(), irInt(-2)), irThrowNpe())
|
||||
+IrBranchImpl(irEquals(indexVar.get(), irInt(-2)), irThrowIse()) // TODO throw proper exception
|
||||
|
||||
// if index == -1 (READ_DONE) break loop
|
||||
+IrBranchImpl(irEquals(indexVar.get(), irInt(-1)), irSetVar(flagVar.symbol, irBoolean(false)))
|
||||
@@ -436,7 +436,7 @@ class SerializerIrGenerator(val irClass: IrClass, override val compilerContext:
|
||||
if (serializableDescriptor.modality != Modality.ABSTRACT && serializableDescriptor.modality != Modality.SEALED) {
|
||||
+irReturn(irInvoke(null, ctor, typeArgs, args))
|
||||
} else {
|
||||
+irThrowNpe()
|
||||
+irThrowIse() // TODO throw proper exception
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user