Support nullable inline classes

This commit is contained in:
Svyatoslav Kuzmich
2018-11-06 19:07:14 +03:00
parent 5ea7673950
commit 0bf3199c19
4 changed files with 56 additions and 12 deletions
@@ -23,8 +23,20 @@ import org.jetbrains.kotlin.ir.types.isMarkedNullable
fun IrType.getInlinedClass(): IrClass? {
if (this is IrSimpleType) {
val erased = erase(this) ?: return null
if (!this.isMarkedNullable() && erased.isInline) {
// TODO: Don't box nullable type inline classes with non-nullable underlying type (JS IR BE)
if (erased.isInline) {
if (this.isMarkedNullable()) {
var fieldType: IrType
var fieldInlinedClass = erased
while (true) {
fieldType = getInlineClassBackingField(fieldInlinedClass).type
if (fieldType.isMarkedNullable()) {
return null
}
fieldInlinedClass = fieldType.getInlinedClass() ?: break
}
}
return erased
}
}