Rework nullability in IR
This commit is contained in:
@@ -194,7 +194,11 @@ internal fun IrFunction.getArgsForMethodInvocation(
|
||||
|
||||
internal fun IrType.getOnlyName(): String {
|
||||
if (this !is IrSimpleType) return this.render()
|
||||
return (this.classifierOrFail.owner as IrDeclarationWithName).name.asString() + (if (this.hasQuestionMark) "?" else "")
|
||||
return (this.classifierOrFail.owner as IrDeclarationWithName).name.asString() + when (nullability) {
|
||||
SimpleTypeNullability.MARKED_NULLABLE -> "?"
|
||||
SimpleTypeNullability.NOT_SPECIFIED -> ""
|
||||
SimpleTypeNullability.DEFINITELY_NOT_NULL -> if (this.classifierOrNull is IrTypeParameterSymbol) " & Any" else ""
|
||||
}
|
||||
}
|
||||
|
||||
internal fun IrFieldAccessExpression.accessesTopLevelOrObjectField(): Boolean {
|
||||
@@ -251,7 +255,7 @@ internal fun IrType.getTypeIfReified(getType: (IrClassifierSymbol) -> IrType): I
|
||||
val owner = this.classifierOrNull?.owner
|
||||
if (owner is IrTypeParameter && owner.isReified) {
|
||||
return (getType(owner.symbol) as IrSimpleType)
|
||||
.buildSimpleType { hasQuestionMark = this.hasQuestionMark || this@getTypeIfReified.hasQuestionMark }
|
||||
.mergeNullability(this)
|
||||
}
|
||||
|
||||
val newArguments = this.arguments.map {
|
||||
@@ -261,7 +265,6 @@ internal fun IrType.getTypeIfReified(getType: (IrClassifierSymbol) -> IrType): I
|
||||
type.getTypeIfReified(getType) as IrTypeArgument
|
||||
}
|
||||
return this.buildSimpleType {
|
||||
hasQuestionMark = this.hasQuestionMark || this@getTypeIfReified.hasQuestionMark
|
||||
arguments = newArguments
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ internal class Wrapper(val value: Any, override val irClass: IrClass, environmen
|
||||
|
||||
fun getStaticGetter(field: IrField): MethodHandle {
|
||||
val jvmClass = field.parentAsClass.defaultType.getClass(true)
|
||||
val returnType = field.type.let { it.getClass((it as IrSimpleType).hasQuestionMark) }
|
||||
val returnType = field.type.let { it.getClass(it.isNullable()) }
|
||||
return MethodHandles.lookup().findStaticGetter(jvmClass, field.name.asString(), returnType)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user