JVM IR: fix isMarkedNullable for nullability-flexible types
Since nullability-flexible types in IR are represented by an annotation on an IrSimpleType, not a special instance, the common implementation of `KotlinTypeMarker.isMarkedNullable` in `TypeSystemContext` doesn't work. This method is used for example to generate `typeOf` in JVM IR, in `TypeSystemCommonBackendContext.generateTypeOf`, and this issue led to a difference in behavior of `typeOf` for nullability-flexible types. #KT-44726 Fixed
This commit is contained in:
@@ -77,6 +77,9 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
|
||||
override fun SimpleTypeMarker.isMarkedNullable(): Boolean = (this as IrSimpleType).hasQuestionMark
|
||||
|
||||
override fun KotlinTypeMarker.isMarkedNullable(): Boolean =
|
||||
this is IrSimpleType && !isWithFlexibleNullability() && hasQuestionMark
|
||||
|
||||
override fun SimpleTypeMarker.withNullability(nullable: Boolean): SimpleTypeMarker {
|
||||
val simpleType = this as IrSimpleType
|
||||
return if (simpleType.hasQuestionMark == nullable) simpleType
|
||||
|
||||
Reference in New Issue
Block a user