Rework nullability in IR
This commit is contained in:
+2
-2
@@ -469,7 +469,7 @@ class ExportModelGenerator(
|
||||
return ExportedType.ErrorType("NonSimpleType ${type.render()}")
|
||||
|
||||
val classifier = type.classifier
|
||||
val isNullable = type.hasQuestionMark
|
||||
val isMarkedNullable = type.isMarkedNullable()
|
||||
val nonNullType = type.makeNotNull() as IrSimpleType
|
||||
|
||||
val exportedType = when {
|
||||
@@ -528,7 +528,7 @@ class ExportModelGenerator(
|
||||
else -> error("Unexpected classifier $classifier")
|
||||
}
|
||||
|
||||
return exportedType.withNullability(isNullable)
|
||||
return exportedType.withNullability(isMarkedNullable)
|
||||
}
|
||||
|
||||
private fun IrClass.getExportableName(): String {
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : FileLowe
|
||||
endOffset,
|
||||
IrSimpleTypeImpl(
|
||||
context.ir.symbols.functionN(newN),
|
||||
(type as IrSimpleType).hasQuestionMark,
|
||||
(type as IrSimpleType).nullability,
|
||||
arguments,
|
||||
type.annotations
|
||||
),
|
||||
@@ -111,7 +111,7 @@ class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : FileLowe
|
||||
endOffset,
|
||||
IrSimpleTypeImpl(
|
||||
(if (setter == null) getPropertyN(newN) else getMutablePropertyN(newN)),
|
||||
(type as IrSimpleType).hasQuestionMark,
|
||||
(type as IrSimpleType).nullability,
|
||||
arguments,
|
||||
type.annotations
|
||||
),
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.symbols.IrScriptSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
|
||||
import org.jetbrains.kotlin.ir.util.getInlineClassUnderlyingType
|
||||
import org.jetbrains.kotlin.ir.util.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsNameRef
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
@@ -26,7 +25,11 @@ fun IrType.asString(): String = when (this) {
|
||||
is IrDynamicType -> "dynamic"
|
||||
is IrSimpleType ->
|
||||
classifier.asString() +
|
||||
(if (hasQuestionMark) "?" else "") +
|
||||
when (nullability) {
|
||||
SimpleTypeNullability.MARKED_NULLABLE -> "?"
|
||||
SimpleTypeNullability.NOT_SPECIFIED -> ""
|
||||
SimpleTypeNullability.DEFINITELY_NOT_NULL -> if (classifier is IrTypeParameterSymbol) " & Any" else ""
|
||||
} +
|
||||
(arguments.ifNotEmpty {
|
||||
joinToString(separator = ",", prefix = "<", postfix = ">") { it.asString() }
|
||||
} ?: "")
|
||||
|
||||
+5
-8
@@ -34,11 +34,8 @@ private val IrTypeParameter.erasedUpperBound: IrClass?
|
||||
|
||||
val IrType.erasedUpperBound: IrClass?
|
||||
get() =
|
||||
if (this is IrDefinitelyNotNullType)
|
||||
this.original.erasedUpperBound
|
||||
else
|
||||
when (val classifier = classifierOrNull) {
|
||||
is IrClassSymbol -> classifier.owner
|
||||
is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
when (val classifier = classifierOrNull) {
|
||||
is IrClassSymbol -> classifier.owner
|
||||
is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
Reference in New Issue
Block a user