diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index 9f52c664f14..e6cc99c0adc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -321,7 +321,6 @@ class Fir2IrImplicitCastInserter( internal fun implicitCastOrExpression(original: IrExpression, castType: IrType): IrExpression { val originalNotNull = original.type.makeNotNull() if (originalNotNull == castType.makeNotNull()) return original - if (castType is IrDefinitelyNotNullType && originalNotNull == castType.original.makeNotNull()) return original return implicitCast(original, castType) } @@ -358,7 +357,7 @@ class Fir2IrImplicitCastInserter( val classId = it.symbol.owner.parentAsClass.classId classId == StandardClassIds.Annotations.EnhancedNullability || classId == StandardClassIds.Annotations.FlexibleNullability - }.withHasQuestionMark(false) + }.makeNotNull() return IrTypeOperatorCallImpl( original.startOffset, original.endOffset, diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 61789ce3572..a25480c4e4f 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrTypeArgument import org.jetbrains.kotlin.ir.types.IrTypeProjection -import org.jetbrains.kotlin.ir.types.impl.IrDefinitelyNotNullTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection +import org.jetbrains.kotlin.ir.types.makeNotNull import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.name.StandardClassIds.Annotations.ExtensionFunctionType @@ -190,7 +190,7 @@ class Fir2IrTypeConverter( } } is ConeDefinitelyNotNullType -> { - IrDefinitelyNotNullTypeImpl(null, original.toIrType(typeContext)) + original.toIrType(typeContext).makeNotNull() } is ConeIntersectionType -> { // TODO: add intersectionTypeApproximation diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt index 316e9473cb5..2840b93929d 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt @@ -69,7 +69,7 @@ class IrBuiltInsOverFir( } override val anyClass: IrClassSymbol get() = any.klass override val anyType: IrType get() = any.type - override val anyNType by lazy { anyType.withHasQuestionMark(true) } + override val anyNType by lazy { anyType.makeNullable() } private val number by createClass(kotlinIrPackage, IdSignatureValues.number, build = { modality = Modality.ABSTRACT }) { configureSuperTypes() @@ -84,7 +84,7 @@ class IrBuiltInsOverFir( private val nothing by createClass(kotlinIrPackage, IdSignatureValues.nothing) override val nothingClass: IrClassSymbol get() = nothing.klass override val nothingType: IrType get() = nothing.type - override val nothingNType: IrType by lazy { nothingType.withHasQuestionMark(true) } + override val nothingNType: IrType by lazy { nothingType.makeNullable() } private val unit by createClass(kotlinIrPackage, IdSignatureValues.unit, build = { kind = ClassKind.OBJECT; modality = Modality.FINAL }) override val unitClass: IrClassSymbol get() = unit.klass @@ -401,7 +401,7 @@ class IrBuiltInsOverFir( createFunction( fqName, "CHECK_NOT_NULL", - IrSimpleTypeImpl(typeParameter.symbol, hasQuestionMark = false, emptyList(), emptyList()), + IrSimpleTypeImpl(typeParameter.symbol, SimpleTypeNullability.DEFINITELY_NOT_NULL, emptyList(), emptyList()), arrayOf("" to IrSimpleTypeImpl(typeParameter.symbol, hasQuestionMark = true, emptyList(), emptyList())), origin = BUILTIN_OPERATOR ).also { @@ -471,7 +471,7 @@ class IrBuiltInsOverFir( override val extensionStringPlus: IrSimpleFunctionSymbol by lazy { findFunctions(kotlinPackage, OperatorNameConventions.PLUS).single { function -> val isStringExtension = - function.owner.extensionReceiverParameter?.let { receiver -> receiver.type == stringType.withHasQuestionMark(true) } + function.owner.extensionReceiverParameter?.let { receiver -> receiver.type == stringType.makeNullable() } ?: false isStringExtension && function.owner.valueParameters.size == 1 && function.owner.valueParameters[0].type == anyNType } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index d724889b666..4f27ededd89 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -359,7 +359,7 @@ internal class AdapterGenerator( reifiedVarargElementType = adaptedType.getArgumentTypeAt(index) reifiedVarargType = IrSimpleTypeImpl( parameterType.classifier, - parameterType.hasQuestionMark, + parameterType.nullability, listOf(makeTypeProjection(reifiedVarargElementType, Variance.OUT_VARIANCE)), parameterType.annotations, parameterType.abbreviation diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt index 0fedad0cb04..38e78934f2e 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/OperatorExpressionGenerator.kt @@ -18,10 +18,8 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.classifierOrFail +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl -import org.jetbrains.kotlin.ir.types.isDoubleOrFloatWithoutNullability import org.jetbrains.kotlin.ir.util.getSimpleFunction internal class OperatorExpressionGenerator( @@ -173,19 +171,14 @@ internal class OperatorExpressionGenerator( if (noImplicitCast && !isDoubleOrFloatWithoutNullability && irExpression.operator == IrTypeOperator.IMPLICIT_CAST) { return irExpression.argument } else { - val simpleType = irExpression.type as? IrSimpleType + val expressionType = irExpression.type if (isDoubleOrFloatWithoutNullability && isOriginalNullable && - simpleType?.hasQuestionMark == false + expressionType is IrSimpleType && + !expressionType.isNullable() ) { // Make it compatible with IR lowering - val nullableDoubleOrFloatType = IrSimpleTypeImpl( - simpleType.classifier, - true, - simpleType.arguments, - simpleType.annotations, - simpleType.abbreviation - ) + val nullableDoubleOrFloatType = expressionType.makeNullable() return IrTypeOperatorCallImpl( irExpression.startOffset, irExpression.endOffset, diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt index eb49cfc15ba..f86a7f8e3c2 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt @@ -329,13 +329,13 @@ fun IrType.remapTypeParameters( target.typeParameters[classifier.index] else classifier - IrSimpleTypeImpl(newClassifier.symbol, hasQuestionMark, arguments, annotations) + IrSimpleTypeImpl(newClassifier.symbol, nullability, arguments, annotations) } classifier is IrClass -> IrSimpleTypeImpl( classifier.symbol, - hasQuestionMark, + nullability, arguments.map { when (it) { is IrTypeProjection -> makeTypeProjection( diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt index b6edf3894d1..7f519204215 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt @@ -335,7 +335,7 @@ abstract class AbstractSuspendFunctionsLowering(val co val constructor = coroutine.coroutineConstructor generateCoroutineStart(coroutine.stateMachineFunction, irCallConstructor(constructor.symbol, irFunction.typeParameters.map { - IrSimpleTypeImpl(it.symbol, true, emptyList(), emptyList()) + it.defaultType.makeNullable() }).apply { val functionParameters = irFunction.explicitParameters functionParameters.forEachIndexed { index, argument -> diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt index 771918c2cb3..c18d00b9e42 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.transformStatement +import org.jetbrains.kotlin.ir.types.SimpleTypeNullability import org.jetbrains.kotlin.ir.types.extractTypeParameters import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.util.* @@ -293,7 +294,7 @@ class InlineClassLowering(val context: CommonBackendContext) { val typeParameters = extractTypeParameters(function.parentAsClass) + function.typeParameters for ((index, typeParameter) in typeParameters.withIndex()) { - putTypeArgument(index, IrSimpleTypeImpl(typeParameter.symbol, false, emptyList(), emptyList())) + putTypeArgument(index, IrSimpleTypeImpl(typeParameter.symbol, SimpleTypeNullability.NOT_SPECIFIED, emptyList(), emptyList())) } } ) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt index b16cb15fb1d..7fc8a696ec4 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/DeepCopyIrTreeWithDescriptors.kt @@ -98,16 +98,13 @@ internal class DeepCopyIrTreeWithSymbolsForInliner( erasedParameters.remove(classifier) - return if (type.hasQuestionMark) erasedUpperBound.makeNullable() else erasedUpperBound + return erasedUpperBound.mergeNullability(type) } if (substitutedType is IrDynamicType) return substitutedType if (substitutedType is IrSimpleType) { - return substitutedType.buildSimpleType { - kotlinType = null - hasQuestionMark = type.hasQuestionMark or substitutedType.isMarkedNullable() - } + return substitutedType.mergeNullability(type) } return type.buildSimpleType { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/IrBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/IrBuilders.kt index 264a45285ee..a08e9ec93ea 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/IrBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/builders/IrBuilders.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl import org.jetbrains.kotlin.ir.expressions.impl.IrWhileLoopImpl import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.SimpleTypeNullability import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.name.Name @@ -43,7 +44,7 @@ fun IrBuilderWithScope.irContinue(loop: IrLoop) = IrContinueImpl(startOffset, endOffset, context.irBuiltIns.nothingType, loop) fun IrBuilderWithScope.irGetObject(classSymbol: IrClassSymbol) = - IrGetObjectValueImpl(startOffset, endOffset, IrSimpleTypeImpl(classSymbol, false, emptyList(), emptyList()), classSymbol) + IrGetObjectValueImpl(startOffset, endOffset, IrSimpleTypeImpl(classSymbol, SimpleTypeNullability.NOT_SPECIFIED, emptyList(), emptyList()), classSymbol) // Also adds created variable into building block fun IrStatementsBuilder.createTmpVariable( diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt index e542c65497f..482b873f7e0 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/ir/util/IrTypeUtils.kt @@ -95,10 +95,7 @@ fun IrType.substitute(substitutionMap: Map): IrTy substitutionMap[classifier]?.let { substitutedType -> // Add nullability and annotations from original type return substitutedType - .withHasQuestionMark( - hasQuestionMark || - substitutedType is IrSimpleType && substitutedType.hasQuestionMark - ) + .mergeNullability(this) .addAnnotations(newAnnotations) } @@ -112,7 +109,7 @@ fun IrType.substitute(substitutionMap: Map): IrTy return IrSimpleTypeImpl( classifier, - hasQuestionMark, + nullability, newArguments, newAnnotations ) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelGenerator.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelGenerator.kt index 10b324195c3..6c4b708582d 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelGenerator.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/export/ExportModelGenerator.kt @@ -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 { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt index 0bdad880334..41928691dea 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt @@ -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 ), diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/IrTypeUtils.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/IrTypeUtils.kt index a183f304842..ad01853aba6 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/IrTypeUtils.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/IrTypeUtils.kt @@ -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() } } ?: "") diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/TypeTranformer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/TypeTranformer.kt index 62dd248444b..f3b100a223b 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/TypeTranformer.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/TypeTranformer.kt @@ -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() - } \ No newline at end of file + when (val classifier = classifierOrNull) { + is IrClassSymbol -> classifier.owner + is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound + else -> throw IllegalStateException() + } \ No newline at end of file diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStringConcatenationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStringConcatenationLowering.kt index f33938df338..ead6dab2a26 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStringConcatenationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStringConcatenationLowering.kt @@ -80,7 +80,7 @@ private fun JvmIrBuilder.normalizeArgument(expression: IrExpression): IrExpressi // upcast to 'String?' return irImplicitCast(expression, context.irBuiltIns.stringType.makeNullable()) } - if (type is IrSimpleType && !type.hasQuestionMark || type is IrDefinitelyNotNullType) { + if (!type.isNullable()) { if (upperBound.isByte() || upperBound.isShort()) { // Expression type is not null, // T <: Byte || T <: Short => diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt index 00c595b6723..596f53c8dbc 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt @@ -548,9 +548,7 @@ internal class LambdaMetafactoryArgumentsBuilder( ) } - private fun computeParameterTypeAdaptationConstraint(adapteeType0: IrType, expectedType0: IrType): TypeAdaptationConstraint? { - val adapteeType = adapteeType0.unwrapDefinitelyNotNullType() - val expectedType = expectedType0.unwrapDefinitelyNotNullType() + private fun computeParameterTypeAdaptationConstraint(adapteeType: IrType, expectedType: IrType): TypeAdaptationConstraint? { if (adapteeType !is IrSimpleType) throw AssertionError("Simple type expected: ${adapteeType.render()}") if (expectedType !is IrSimpleType) @@ -582,7 +580,7 @@ internal class LambdaMetafactoryArgumentsBuilder( // Inline classes mapped to non-null reference types are a special case because they can't be boxed trivially. // TODO consider adding a special type annotation to force boxing on an inline class type regardless of its underlying type. val underlyingAdapteeType = getInlineClassUnderlyingType(erasedAdapteeClass) - if (!underlyingAdapteeType.hasQuestionMark && !underlyingAdapteeType.isPrimitiveType()) { + if (!underlyingAdapteeType.isNullable() && !underlyingAdapteeType.isPrimitiveType()) { return TypeAdaptationConstraint.CONFLICT } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrTypeSystemContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrTypeSystemContext.kt index 8892f196e42..23451e624f9 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrTypeSystemContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrTypeSystemContext.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.types.IrSimpleType import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrTypeSystemContext +import org.jetbrains.kotlin.ir.types.isMarkedNullable as irIsMarkedNullable import org.jetbrains.kotlin.types.model.FlexibleTypeMarker import org.jetbrains.kotlin.types.model.KotlinTypeMarker import org.jetbrains.kotlin.types.model.SimpleTypeMarker @@ -35,5 +36,5 @@ class JvmIrTypeSystemContext(override val irBuiltIns: IrBuiltIns) : IrTypeSystem } override fun KotlinTypeMarker.isMarkedNullable(): Boolean = - this is IrSimpleType && !isWithFlexibleNullability() && hasQuestionMark + this is IrSimpleType && !isWithFlexibleNullability() && irIsMarkedNullable() } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/MemoizedInlineClassReplacements.kt index 223caca7524..94b6b6525d4 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/MemoizedInlineClassReplacements.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/MemoizedInlineClassReplacements.kt @@ -158,7 +158,7 @@ class MemoizedInlineClassReplacements( parent = irClass // We ignore type arguments here, since there is no good way to go from type arguments to types in the IR anyway. val typeArgument = - IrSimpleTypeImpl(null, irClass.symbol, false, List(irClass.typeParameters.size) { IrStarProjectionImpl }, listOf()) + IrSimpleTypeImpl(irClass.symbol, false, List(irClass.typeParameters.size) { IrStarProjectionImpl }, listOf()) addValueParameter { name = InlineClassDescriptorResolver.SPECIALIZED_EQUALS_FIRST_PARAMETER_NAME type = typeArgument diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrJvmFlexibleType.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrJvmFlexibleType.kt index 1847f876654..3b3a8be5fb5 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrJvmFlexibleType.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrJvmFlexibleType.kt @@ -9,12 +9,9 @@ import org.jetbrains.kotlin.backend.jvm.JvmSymbols import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.classFqName +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.buildSimpleType -import org.jetbrains.kotlin.ir.types.removeAnnotations import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.ir.util.hasAnnotation import org.jetbrains.kotlin.ir.util.render @@ -35,7 +32,7 @@ private class IrJvmFlexibleTypeImpl( ) : IrJvmFlexibleType { override val lowerBound: IrSimpleType get() = irType.buildSimpleType { - if (nullability) hasQuestionMark = false + if (this@IrJvmFlexibleTypeImpl.nullability) nullability = SimpleTypeNullability.NOT_SPECIFIED // No change in classifier is needed for mutability because type's classifier is set to the lower bound anyway // (see TypeTranslator.translateType). kotlinType = null @@ -43,7 +40,7 @@ private class IrJvmFlexibleTypeImpl( override val upperBound: IrSimpleType get() = irType.buildSimpleType { - if (nullability) hasQuestionMark = true + if (this@IrJvmFlexibleTypeImpl.nullability) nullability = SimpleTypeNullability.MARKED_NULLABLE if (mutability) { val klass = classifier?.owner as? IrClass ?: error("Mutability-flexible type's classifier is not a class: ${irType.render()}") diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt index 3954e1b0f52..e57fcca9fcc 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrTypeUtils.kt @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection -import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.isLocal import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -41,9 +40,9 @@ fun IrType.eraseTypeParameters(): IrType = when (this) { when (val owner = classifier.owner) { is IrScript -> { assert(arguments.isEmpty()) { "Script can't be generic: " + owner.render() } - IrSimpleTypeImpl(classifier, hasQuestionMark, emptyList(), annotations) + IrSimpleTypeImpl(classifier, nullability, emptyList(), annotations) } - is IrClass -> IrSimpleTypeImpl(classifier, hasQuestionMark, arguments.map { it.eraseTypeParameters() }, annotations) + is IrClass -> IrSimpleTypeImpl(classifier, nullability, arguments.map { it.eraseTypeParameters() }, annotations) is IrTypeParameter -> { val upperBound = owner.erasedUpperBound IrSimpleTypeImpl( @@ -56,8 +55,6 @@ fun IrType.eraseTypeParameters(): IrType = when (this) { } else -> error("Unknown IrSimpleType classifier kind: $owner") } - is IrDefinitelyNotNullType -> - this.original.eraseTypeParameters() is IrErrorType -> this else -> error("Unknown IrType kind: $this") @@ -88,15 +85,12 @@ 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 - is IrScriptSymbol -> classifier.owner.targetClass!!.owner - else -> error(render()) - } + when (val classifier = classifierOrNull) { + is IrClassSymbol -> classifier.owner + is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound + is IrScriptSymbol -> classifier.owner.targetClass!!.owner + else -> error(render()) + } /** * Get the default null/0 value for the type. @@ -111,7 +105,7 @@ fun IrType.defaultValue(startOffset: Int, endOffset: Int, context: JvmBackendCon return classifier.owner.representativeUpperBound.defaultValue(startOffset, endOffset, context) } - if (this !is IrSimpleType || hasQuestionMark || classOrNull?.owner?.isSingleFieldValueClass != true) + if (this !is IrSimpleType || this.isMarkedNullable() || classOrNull?.owner?.isSingleFieldValueClass != true) return IrConstImpl.defaultValueForType(startOffset, endOffset, this) val underlyingType = unboxInlineClass() @@ -137,13 +131,13 @@ fun IrType.eraseToScope(visibleTypeParameters: Set): IrType { return when (classifier) { is IrClassSymbol -> IrSimpleTypeImpl( - classifier, hasQuestionMark, arguments.map { it.eraseToScope(visibleTypeParameters) }, annotations + classifier, nullability, arguments.map { it.eraseToScope(visibleTypeParameters) }, annotations ) is IrTypeParameterSymbol -> if (classifier.owner in visibleTypeParameters) this else - upperBound.withHasQuestionMark(this.hasQuestionMark) + upperBound.mergeNullability(this) else -> error("unknown IrType classifier kind: ${classifier.owner.render()}") } } diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/Utils.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/Utils.kt index 00d1a144fd8..6101458ad02 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/Utils.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/Utils.kt @@ -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 } } diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/Wrapper.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/Wrapper.kt index d9e257dfdcb..70743f4879a 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/Wrapper.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/Wrapper.kt @@ -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) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index eb0eb3f6b57..221a754e2c5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -1131,12 +1131,13 @@ private fun getContainingDeclaration(declaration: IrDeclaration): DeclarationDes fun IrType.toIrBasedKotlinType(): KotlinType = when (this) { is IrSimpleType -> - makeKotlinType(classifier, arguments, hasQuestionMark) - is IrDefinitelyNotNullType -> { - val kotlinType = this.original.toIrBasedKotlinType() - DefinitelyNotNullType.makeDefinitelyNotNull(kotlinType.unwrap()) - ?: kotlinType - } + makeKotlinType(classifier, arguments, isMarkedNullable()).let { + if (classifier is IrTypeParameterSymbol && nullability == SimpleTypeNullability.DEFINITELY_NOT_NULL) { + DefinitelyNotNullType.makeDefinitelyNotNull(it.unwrap()) ?: it + } else { + it + } + } else -> throw AssertionError("Unexpected type: $this = ${this.render()}") } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt index 44e78696e5d..7b5ede7cbc9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltInsOverDescriptors.kt @@ -26,7 +26,6 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeBuilder @@ -186,14 +185,14 @@ class IrBuiltInsOverDescriptors( val returnIrType = IrSimpleTypeBuilder().run { classifier = typeParameterSymbol kotlinType = returnKotlinType - hasQuestionMark = false + nullability = SimpleTypeNullability.DEFINITELY_NOT_NULL buildSimpleType() } val valueIrType = IrSimpleTypeBuilder().run { classifier = typeParameterSymbol kotlinType = valueKotlinType - hasQuestionMark = true + nullability = SimpleTypeNullability.MARKED_NULLABLE buildSimpleType() } @@ -232,7 +231,7 @@ class IrBuiltInsOverDescriptors( val any = builtIns.anyType override val anyType = any.toIrType() override val anyClass = builtIns.any.toIrSymbol() - override val anyNType = anyType.withHasQuestionMark(true) + override val anyNType = anyType.makeNullable() val bool = builtIns.booleanType override val booleanType = bool.toIrType() @@ -273,7 +272,7 @@ class IrBuiltInsOverDescriptors( val nothing = builtIns.nothingType override val nothingType = nothing.toIrType() override val nothingClass = builtIns.nothing.toIrSymbol() - override val nothingNType = nothingType.withHasQuestionMark(true) + override val nothingNType = nothingType.makeNullable() val unit = builtIns.unitType override val unitType = unit.toIrType() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDescriptorBasedFunctionFactory.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDescriptorBasedFunctionFactory.kt index 3a513e91f1f..916f5d80a86 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDescriptorBasedFunctionFactory.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDescriptorBasedFunctionFactory.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.SimpleTypeNullability import org.jetbrains.kotlin.ir.types.impl.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.FqName @@ -329,7 +330,7 @@ class IrDescriptorBasedFunctionFactory( return with(IrSimpleTypeBuilder()) { classifier = symbolTable.referenceClassifier(kotlinType.constructor.declarationDescriptor ?: error("No classifier for type $kotlinType")) - hasQuestionMark = kotlinType.isMarkedNullable + nullability = SimpleTypeNullability.fromHasQuestionMark(kotlinType.isMarkedNullable) arguments = kotlinType.arguments.map { if (it.isStarProjection) IrStarProjectionImpl else makeTypeProjection(toIrType(it.type), it.projectionKind) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt index 4bacd020a54..880dce9c969 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/DeepCopyIrTreeWithSymbolsForFakeOverrides.kt @@ -52,11 +52,7 @@ class DeepCopyIrTreeWithSymbolsForFakeOverrides(typeArguments: Map substitutedType - is IrDefinitelyNotNullType -> substitutedType - is IrSimpleType -> substitutedType.buildSimpleType { - kotlinType = null - hasQuestionMark = type.hasQuestionMark or substitutedType.isMarkedNullable() - } + is IrSimpleType -> substitutedType.mergeNullability(type) else -> type.buildSimpleType { kotlinType = null classifier = symbolRemapper.getReferencedClassifier(type.classifier) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrType.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrType.kt index 3bd77e8c05b..2930e0a72f9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrType.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrType.kt @@ -32,15 +32,56 @@ abstract class IrErrorType(kotlinType: KotlinType?) : IrTypeBase(kotlinType) abstract class IrDynamicType(kotlinType: KotlinType?) : IrTypeBase(kotlinType), DynamicTypeMarker -abstract class IrDefinitelyNotNullType(kotlinType: KotlinType?) : IrTypeBase(kotlinType), DefinitelyNotNullTypeMarker { - abstract val original: IrType +enum class SimpleTypeNullability { + MARKED_NULLABLE, + NOT_SPECIFIED, + DEFINITELY_NOT_NULL; + + companion object { + fun fromHasQuestionMark(hasQuestionMark: Boolean) = if (hasQuestionMark) MARKED_NULLABLE else NOT_SPECIFIED + } } abstract class IrSimpleType(kotlinType: KotlinType?) : IrTypeBase(kotlinType), SimpleTypeMarker, TypeArgumentListMarker { abstract val classifier: IrClassifierSymbol - abstract val hasQuestionMark: Boolean + + /** + * If type is explicitly marked as nullable, [nullability] is [SimpleTypeNullability.MARKED_NULLABLE] + * + * If classifier is type parameter, not marked as nullable, but can store null values, + * if corresponding argument would be nullable, [nullability] is [SimpleTypeNullability.NOT_SPECIFIED] + * + * If type can't store null values, [nullability] is [SimpleTypeNullability.DEFINITELY_NOT_NULL] + * + * Direct usages of this property should be avoided in most cases. Use relevant util functions instead. + * + * In most cases one of following is needed: + * + * Use [IrType.isNullable] to check if null value is possible for this type + * + * Use [IrType.isMarkedNullable] to check if type is marked with question mark in code + * + * Use [IrType.mergeNullability] to apply nullability of type parameter to actual type argument in type substitutions + * + * Use [IrType.makeNotNull] or [IrType.makeNullable] to transfer nullability from one type to another + */ + abstract val nullability: SimpleTypeNullability abstract val arguments: List abstract val abbreviation: IrTypeAbbreviation? + + /** + * This property was deprecated and replaced with [nullability] property. + * + * Anyway, in most cases one of utils function would be more suitable, than direct usage. + * + * Check [nullability] property documentation for details + */ + @Deprecated( + level = DeprecationLevel.WARNING, + message = "hasQuestionMark has ambiguous meaning. Use isNullable() or isMarkedNullable() instead.", + ) + val hasQuestionMark: Boolean + get() = nullability == SimpleTypeNullability.MARKED_NULLABLE } interface IrTypeArgument : TypeArgumentMarker { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSubstitutor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSubstitutor.kt index ba931e058d7..c97b7913c16 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSubstitutor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSubstitutor.kt @@ -43,8 +43,6 @@ abstract class AbstractIrTypeSubstitutor(private val irBuiltIns: IrBuiltIns) : T arguments = irType.arguments.map { substituteTypeArgument(it) } buildSimpleType() } - is IrDefinitelyNotNullType -> - IrDefinitelyNotNullTypeImpl(null, substituteType(irType.original)) is IrDynamicType, is IrErrorType -> irType diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt index 4785e31bee6..854c640663b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt @@ -28,6 +28,9 @@ import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.types.TypeCheckerState import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.ir.types.makeNotNull as irMakeNotNull +import org.jetbrains.kotlin.ir.types.makeNullable as irMakeNullable +import org.jetbrains.kotlin.ir.types.isMarkedNullable as irIsMarkedNullable import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.ir.types.isPrimitiveType as irTypePredicates_isPrimitiveType @@ -71,20 +74,18 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon override fun SimpleTypeMarker.asDefinitelyNotNullType(): DefinitelyNotNullTypeMarker? = null - override fun SimpleTypeMarker.isMarkedNullable(): Boolean = this is IrSimpleType && hasQuestionMark + override fun SimpleTypeMarker.isMarkedNullable(): Boolean = this is IrSimpleType && this.irIsMarkedNullable() - override fun KotlinTypeMarker.isMarkedNullable(): Boolean = this is IrSimpleType && hasQuestionMark + override fun KotlinTypeMarker.isMarkedNullable(): Boolean = this is IrSimpleType && this.irIsMarkedNullable() override fun SimpleTypeMarker.withNullability(nullable: Boolean): SimpleTypeMarker { val simpleType = this as IrSimpleType - return if (simpleType.hasQuestionMark == nullable) simpleType - else simpleType.run { IrSimpleTypeImpl(classifier, nullable, arguments, annotations) } + return (if (nullable) simpleType.irMakeNullable() else simpleType.irMakeNotNull()) as IrSimpleType } override fun SimpleTypeMarker.typeConstructor(): TypeConstructorMarker = when (this) { is IrCapturedType -> constructor is IrSimpleType -> classifier - is IrDefinitelyNotNullType -> original.typeConstructor() else -> error("Unknown type constructor") } @@ -290,7 +291,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon } } - return IrSimpleTypeImpl(type.classifier, type.hasQuestionMark, newArguments, type.annotations) + return IrSimpleTypeImpl(type.classifier, type.nullability, newArguments, type.annotations) } override fun SimpleTypeMarker.asArgumentList() = this as IrSimpleType @@ -341,7 +342,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon require(ourAnnotations?.size == attributes?.size) return IrSimpleTypeImpl( constructor as IrClassifierSymbol, - nullable, + if (nullable) SimpleTypeNullability.MARKED_NULLABLE else SimpleTypeNullability.DEFINITELY_NOT_NULL, arguments.map { it as IrTypeArgument }, ourAnnotations ?: emptyList() ) @@ -556,7 +557,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon error("Captured type is unsupported in IR") override fun DefinitelyNotNullTypeMarker.original(): SimpleTypeMarker = - (this as IrDefinitelyNotNullType).original as IrSimpleType + error("DefinitelyNotNullTypeMarker.original() type is unsupported in IR") override fun KotlinTypeMarker.makeDefinitelyNotNullOrNotNull(): KotlinTypeMarker { error("makeDefinitelyNotNullOrNotNull is not supported in IR") diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt index d788f6ca945..ac3ffe68fe5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt @@ -7,10 +7,7 @@ package org.jetbrains.kotlin.ir.types import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.ir.IrBuiltIns -import org.jetbrains.kotlin.ir.symbols.FqNameEqualityChecker -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol +import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.types.AbstractTypeChecker @@ -37,10 +34,15 @@ fun IrType.isSubtypeOf(superType: IrType, typeSystem: IrTypeSystemContext): Bool fun IrType.isNullable(): Boolean = when (this) { - is IrDefinitelyNotNullType -> false is IrSimpleType -> when (val classifier = classifier) { - is IrClassSymbol -> hasQuestionMark - is IrTypeParameterSymbol -> hasQuestionMark || classifier.owner.superTypes.any(IrType::isNullable) + is IrClassSymbol -> nullability == SimpleTypeNullability.MARKED_NULLABLE + is IrTypeParameterSymbol -> when (nullability) { + SimpleTypeNullability.MARKED_NULLABLE -> true + // here is a bug, there should be .all check (not .any), + // but fixing it is a breaking change, see KT-31545 for details + SimpleTypeNullability.NOT_SPECIFIED -> classifier.owner.superTypes.any(IrType::isNullable) + SimpleTypeNullability.DEFINITELY_NOT_NULL -> false + } else -> error("Unsupported classifier: $classifier") } is IrDynamicType -> true @@ -73,9 +75,3 @@ fun IrType.toArrayOrPrimitiveArrayType(irBuiltIns: IrBuiltIns): IrType = } else { irBuiltIns.arrayClass.typeWith(this) } - -fun IrType.unwrapDefinitelyNotNullType(): IrType = - if (this is IrDefinitelyNotNullType) - this.original.unwrapDefinitelyNotNullType() - else - this diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrDefinitelyNotNullTypeImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrDefinitelyNotNullTypeImpl.kt deleted file mode 100644 index 5249724be5d..00000000000 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrDefinitelyNotNullTypeImpl.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.ir.types.impl - -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.types.IrDefinitelyNotNullType -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.Variance - -class IrDefinitelyNotNullTypeImpl( - kotlinType: KotlinType?, - override val original: IrType, -) : IrDefinitelyNotNullType(kotlinType) { - - override val annotations: List - get() = original.annotations - - override val variance: Variance - get() = Variance.INVARIANT - - override fun equals(other: Any?): Boolean = - other is IrDefinitelyNotNullType && - this.original == other.original - - override fun hashCode(): Int = - original.hashCode() -} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrSimpleTypeImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrSimpleTypeImpl.kt index 7478da16f93..34e2aa85058 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrSimpleTypeImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrSimpleTypeImpl.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.ir.types.impl import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.FqNameEqualityChecker import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol +import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance @@ -18,7 +19,7 @@ abstract class IrAbstractSimpleType(kotlinType: KotlinType?) : IrSimpleType(kotl get() = Variance.INVARIANT abstract override val classifier: IrClassifierSymbol - abstract override val hasQuestionMark: Boolean + abstract override val nullability: SimpleTypeNullability abstract override val arguments: List abstract override val annotations: List abstract override val abbreviation: IrTypeAbbreviation? @@ -26,12 +27,12 @@ abstract class IrAbstractSimpleType(kotlinType: KotlinType?) : IrSimpleType(kotl override fun equals(other: Any?): Boolean = other is IrAbstractSimpleType && FqNameEqualityChecker.areEqual(classifier, other.classifier) && - hasQuestionMark == other.hasQuestionMark && + nullability == other.nullability && arguments == other.arguments override fun hashCode(): Int = (FqNameEqualityChecker.getHashCode(classifier) * 31 + - hasQuestionMark.hashCode()) * 31 + + nullability.hashCode()) * 31 + arguments.hashCode() } @@ -41,8 +42,8 @@ abstract class IrDelegatedSimpleType(kotlinType: KotlinType? = null) : IrAbstrac override val classifier: IrClassifierSymbol get() = delegate.classifier - override val hasQuestionMark: Boolean - get() = delegate.hasQuestionMark + override val nullability: SimpleTypeNullability + get() = delegate.nullability override val arguments: List get() = delegate.arguments override val abbreviation: IrTypeAbbreviation? @@ -54,25 +55,40 @@ abstract class IrDelegatedSimpleType(kotlinType: KotlinType? = null) : IrAbstrac class IrSimpleTypeImpl( kotlinType: KotlinType?, override val classifier: IrClassifierSymbol, - override val hasQuestionMark: Boolean, + nullability: SimpleTypeNullability, override val arguments: List, override val annotations: List, override val abbreviation: IrTypeAbbreviation? = null ) : IrAbstractSimpleType(kotlinType) { + override val nullability = + if (classifier !is IrTypeParameterSymbol && nullability == SimpleTypeNullability.NOT_SPECIFIED) + SimpleTypeNullability.DEFINITELY_NOT_NULL + else + nullability + + + constructor( + classifier: IrClassifierSymbol, + nullability: SimpleTypeNullability, + arguments: List, + annotations: List, + abbreviation: IrTypeAbbreviation? = null + ) : this(null, classifier, nullability, arguments, annotations, abbreviation) + constructor( classifier: IrClassifierSymbol, hasQuestionMark: Boolean, arguments: List, annotations: List, abbreviation: IrTypeAbbreviation? = null - ) : this(null, classifier, hasQuestionMark, arguments, annotations, abbreviation) + ) : this(null, classifier, SimpleTypeNullability.fromHasQuestionMark(hasQuestionMark), arguments, annotations, abbreviation) } class IrSimpleTypeBuilder { var kotlinType: KotlinType? = null var classifier: IrClassifierSymbol? = null - var hasQuestionMark = false + var nullability = SimpleTypeNullability.NOT_SPECIFIED var arguments: List = emptyList() var annotations: List = emptyList() var abbreviation: IrTypeAbbreviation? = null @@ -83,7 +99,7 @@ fun IrSimpleType.toBuilder() = IrSimpleTypeBuilder().also { b -> b.kotlinType = originalKotlinType b.classifier = classifier - b.hasQuestionMark = hasQuestionMark + b.nullability = nullability b.arguments = arguments b.annotations = annotations b.abbreviation = abbreviation @@ -93,7 +109,7 @@ fun IrSimpleTypeBuilder.buildSimpleType() = IrSimpleTypeImpl( kotlinType, classifier ?: throw AssertionError("Classifier not provided"), - hasQuestionMark, + nullability, arguments, annotations, abbreviation @@ -122,7 +138,6 @@ class IrTypeProjectionImpl internal constructor( fun makeTypeProjection(type: IrType, variance: Variance): IrTypeProjection = when { type is IrCapturedType -> IrTypeProjectionImpl(type, variance) - type is IrDefinitelyNotNullType -> IrTypeProjectionImpl(type, variance) type is IrTypeProjection && type.variance == variance -> type type is IrSimpleType -> type.toBuilder().apply { this.variance = variance }.buildTypeProjection() type is IrDynamicType -> IrDynamicTypeImpl(null, type.annotations, variance) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt index 62a119f3642..83476db32e2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt @@ -103,7 +103,7 @@ class IrCapturedType( override val classifier: IrClassifierSymbol get() = error("Captured Type does not have a classifier") override val arguments: List get() = emptyList() override val abbreviation: IrTypeAbbreviation? get () = null - override val hasQuestionMark: Boolean get() = false + override val nullability: SimpleTypeNullability get() = SimpleTypeNullability.DEFINITELY_NOT_NULL override val annotations: List get() = emptyList() override fun equals(other: Any?): Boolean { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt index 9e51fdd9d1e..7088e6a736a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt @@ -48,15 +48,15 @@ object IdSignatureValues { @JvmField val sequence = IdSignature.CommonSignature("kotlin.sequences", "Sequence", null, 0) } -private fun IrType.isNotNullClassType(signature: IdSignature.CommonSignature) = isClassType(signature, hasQuestionMark = false) -private fun IrType.isNullableClassType(signature: IdSignature.CommonSignature) = isClassType(signature, hasQuestionMark = true) +private fun IrType.isNotNullClassType(signature: IdSignature.CommonSignature) = isClassType(signature, nullable = false) +private fun IrType.isNullableClassType(signature: IdSignature.CommonSignature) = isClassType(signature, nullable = true) fun getPublicSignature(packageFqName: FqName, name: String) = IdSignature.CommonSignature(packageFqName.asString(), name, null, 0) -private fun IrType.isClassType(signature: IdSignature.CommonSignature, hasQuestionMark: Boolean? = null): Boolean { +private fun IrType.isClassType(signature: IdSignature.CommonSignature, nullable: Boolean? = null): Boolean { if (this !is IrSimpleType) return false - if (hasQuestionMark != null && this.hasQuestionMark != hasQuestionMark) return false + if (nullable != null && this.isMarkedNullable() != nullable) return false return signature == classifier.signature || classifier.owner.let { it is IrClass && it.hasFqNameEqualToSignature(signature) } } @@ -109,16 +109,16 @@ fun IrType.isCollection(): Boolean = isNotNullClassType(IdSignatureValues.collec fun IrType.isNothing(): Boolean = isNotNullClassType(IdSignatureValues.nothing) fun IrType.isNullableNothing(): Boolean = isNullableClassType(IdSignatureValues.nothing) -fun IrType.isPrimitiveType(hasQuestionMark: Boolean = false): Boolean = - this is IrSimpleType && hasQuestionMark == this.hasQuestionMark && getPrimitiveType() != null +fun IrType.isPrimitiveType(nullable: Boolean = false): Boolean = + nullable == this.isMarkedNullable() && getPrimitiveType() != null fun IrType.isNullablePrimitiveType(): Boolean = isPrimitiveType(true) fun IrType.getPrimitiveType(): PrimitiveType? = getPrimitiveOrUnsignedType(idSignatureToPrimitiveType, shortNameToPrimitiveType) -fun IrType.isUnsignedType(hasQuestionMark: Boolean = false): Boolean = - this is IrSimpleType && hasQuestionMark == this.hasQuestionMark && getUnsignedType() != null +fun IrType.isUnsignedType(nullable: Boolean = false): Boolean = + nullable == this.isMarkedNullable() && getUnsignedType() != null fun IrType.getUnsignedType(): UnsignedType? = getPrimitiveOrUnsignedType(idSignatureToUnsignedType, shortNameToUnsignedType) @@ -134,7 +134,8 @@ fun > IrType.getPrimitiveOrUnsignedType(byIdSignature: Map withHasQuestionMark(newHasQuestionMark) + is IrSimpleType -> withNullability(newNullability) else -> this } -fun IrSimpleType.withHasQuestionMark(newHasQuestionMark: Boolean): IrSimpleType = - if (this.hasQuestionMark == newHasQuestionMark) +private fun IrSimpleType.withNullability(newNullability: Boolean): IrSimpleType { + val requiredNullability = if (newNullability) SimpleTypeNullability.MARKED_NULLABLE else SimpleTypeNullability.DEFINITELY_NOT_NULL + return if (nullability == requiredNullability) this else buildSimpleType { - hasQuestionMark = newHasQuestionMark + nullability = requiredNullability kotlinType = originalKotlinType?.run { - if (newHasQuestionMark) makeNullable() else makeNotNullable() + if (newNullability) { + TypeUtils.makeNullable(this) + } else { + DefinitelyNotNullType.makeDefinitelyNotNull(this.unwrap()) ?: TypeUtils.makeNotNullable(this) + } } } +} fun IrType.addAnnotations(newAnnotations: List): IrType = if (newAnnotations.isEmpty()) @@ -86,7 +88,6 @@ val IrType.classifierOrFail: IrClassifierSymbol val IrType.classifierOrNull: IrClassifierSymbol? get() = when (this) { is IrSimpleType -> classifier - is IrDefinitelyNotNullType -> original.classifierOrNull else -> null } @@ -103,34 +104,18 @@ val IrType.classFqName: FqName? val IrTypeArgument.typeOrNull: IrType? get() = (this as? IrTypeProjection)?.type -fun IrType.makeNotNull() = - if (this is IrSimpleType && this.hasQuestionMark) { - buildSimpleType { - kotlinType = originalKotlinType?.makeNotNullable() - hasQuestionMark = false - } - } else { - this - } +fun IrType.makeNotNull() = withNullability(false) -fun IrType.makeNullable(): IrType = - when (this) { - is IrSimpleType -> { - if (this.hasQuestionMark) - this - else - buildSimpleType { - kotlinType = originalKotlinType?.makeNullable() - hasQuestionMark = true - } - } - is IrDefinitelyNotNullType -> { - // '{ T & Any }?' => 'T?' - this.original.makeNullable() - } - else -> - this +fun IrType.makeNullable() = withNullability(true) + +fun IrType.mergeNullability(other: IrType) = when (other) { + is IrSimpleType -> when (other.nullability) { + SimpleTypeNullability.MARKED_NULLABLE -> makeNullable() + SimpleTypeNullability.NOT_SPECIFIED -> this + SimpleTypeNullability.DEFINITELY_NOT_NULL -> makeNotNull() } + else -> this +} @ObsoleteDescriptorBasedAPI fun IrType.toKotlinType(): KotlinType { @@ -139,7 +124,7 @@ fun IrType.toKotlinType(): KotlinType { } return when (this) { - is IrSimpleType -> makeKotlinType(classifier, arguments, hasQuestionMark) + is IrSimpleType -> makeKotlinType(classifier, arguments, nullability == SimpleTypeNullability.MARKED_NULLABLE) else -> TODO(toString()) } } @@ -181,7 +166,7 @@ val IrClassifierSymbol.defaultType: IrType val IrTypeParameter.defaultType: IrType get() = IrSimpleTypeImpl( symbol, - hasQuestionMark = false, + SimpleTypeNullability.NOT_SPECIFIED, arguments = emptyList(), annotations = emptyList() ) @@ -189,7 +174,7 @@ val IrTypeParameter.defaultType: IrType val IrClassSymbol.starProjectedType: IrSimpleType get() = IrSimpleTypeImpl( this, - hasQuestionMark = false, + SimpleTypeNullability.NOT_SPECIFIED, arguments = owner.typeConstructorParameters.map { IrStarProjectionImpl }.toList(), annotations = emptyList() ) @@ -230,13 +215,13 @@ fun IrClassifierSymbol.typeWith(vararg arguments: IrType): IrSimpleType = typeWi fun IrClassifierSymbol.typeWith(arguments: List): IrSimpleType = IrSimpleTypeImpl( this, - false, + SimpleTypeNullability.NOT_SPECIFIED, arguments.map { makeTypeProjection(it, Variance.INVARIANT) }, emptyList() ) fun IrClassifierSymbol.typeWithArguments(arguments: List): IrSimpleType = - IrSimpleTypeImpl(this, false, arguments, emptyList()) + IrSimpleTypeImpl(this, SimpleTypeNullability.NOT_SPECIFIED, arguments, emptyList()) fun IrClass.typeWith(arguments: List) = this.symbol.typeWith(arguments) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyTypeRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyTypeRemapper.kt index 1feb9993acd..951efa69d53 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyTypeRemapper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyTypeRemapper.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.ir.util import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.* -import org.jetbrains.kotlin.ir.types.impl.IrDefinitelyNotNullTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrTypeAbbreviationImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection @@ -29,11 +28,10 @@ class DeepCopyTypeRemapper( override fun remapType(type: IrType): IrType { return when (type) { - is IrDefinitelyNotNullType -> IrDefinitelyNotNullTypeImpl(null, remapType(type.original)) is IrSimpleType -> IrSimpleTypeImpl( null, symbolRemapper.getReferencedClassifier(type.classifier), - type.hasQuestionMark, + type.nullability, type.arguments.map { remapTypeArgument(it) }, type.annotations.map { it.transform(deepCopy, null) as IrConstructorCall }, type.abbreviation?.remapTypeAbbreviation() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrTypeParameterRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrTypeParameterRemapper.kt index 527fa0da1d7..07fb2d2d57d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrTypeParameterRemapper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrTypeParameterRemapper.kt @@ -29,7 +29,7 @@ class IrTypeParameterRemapper( IrSimpleTypeImpl( null, type.classifier.remap(), - type.hasQuestionMark, + type.nullability, type.arguments.map { it.remap() }, type.annotations, type.abbreviation?.remap() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt index af106e66891..673898d32ef 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt @@ -12,10 +12,7 @@ import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.ir.symbols.IrSymbol -import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol -import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol +import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException import org.jetbrains.kotlin.ir.types.impl.originalKotlinType @@ -113,9 +110,9 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat is IrErrorType -> "IrErrorType(${if (verboseErrorTypes) originalKotlinType else null})" - is IrDefinitelyNotNullType -> "{${original.render()} & Any}" - is IrSimpleType -> buildTrimEnd { + val isDefinitelyNotNullType = classifier is IrTypeParameterSymbol && nullability == SimpleTypeNullability.DEFINITELY_NOT_NULL + if (isDefinitelyNotNullType) append("{") append(classifier.renderClassifierFqn()) if (arguments.isNotEmpty()) { append( @@ -124,7 +121,9 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat } ) } - if (hasQuestionMark) { + if (isDefinitelyNotNullType) { + append(" & Any}") + } else if (isMarkedNullable()) { append('?') } abbreviation?.let { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SimpleTypeRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SimpleTypeRemapper.kt index cf6ef7b9749..f467390e2c5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SimpleTypeRemapper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SimpleTypeRemapper.kt @@ -33,7 +33,7 @@ class SimpleTypeRemapper( IrSimpleTypeImpl( null, symbol, - type.hasQuestionMark, + type.nullability, arguments, type.annotations, type.abbreviation?.remapTypeAbbreviation() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt index 34214d8eee8..c64d71564f6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt @@ -17,9 +17,7 @@ import org.jetbrains.kotlin.ir.descriptors.IrBasedTypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.IrTypeAbbreviation -import org.jetbrains.kotlin.ir.types.IrTypeProjection +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.* import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections @@ -101,7 +99,7 @@ abstract class TypeTranslator( approximatedType.isDynamic() -> return IrDynamicTypeImpl(approximatedType, translateTypeAnnotations(approximatedType), variance) supportDefinitelyNotNullTypes && approximatedType is DefinitelyNotNullType -> - return makeTypeProjection(IrDefinitelyNotNullTypeImpl(approximatedType, translateType(approximatedType.original)), variance) + return makeTypeProjection(translateType(approximatedType.original).makeNotNull(), variance) } val upperType = approximatedType.upperIfFlexible() @@ -121,7 +119,7 @@ abstract class TypeTranslator( return IrSimpleTypeBuilder().apply { this.kotlinType = approximatedType - this.hasQuestionMark = upperType.isMarkedNullable + this.nullability = SimpleTypeNullability.fromHasQuestionMark(upperType.isMarkedNullable) this.variance = variance this.abbreviation = upperType.getAbbreviation()?.toIrTypeAbbreviation() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt index 362d1d45ab8..75f03661bc4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/dumpKotlinLike.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.name.Name @@ -422,14 +423,14 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption // TODO don't print `Any?` as upper bound? printAnnotationsWithNoIndent() when (this) { - is IrDefinitelyNotNullType -> { - p.printWithNoIndent("(") - original.printTypeWithNoIndent() - p.printWithNoIndent(" & Any)") - } is IrSimpleType -> { // TODO abbreviation + val dnn = classifier is IrTypeParameterSymbol && nullability == SimpleTypeNullability.DEFINITELY_NOT_NULL + if (dnn) { + p.printWithNoIndent("(") + } + p.printWithNoIndent((classifier.owner as IrDeclarationWithName).name.asString()) if (arguments.isNotEmpty()) { @@ -442,7 +443,11 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption p.printWithNoIndent(">") } - if (hasQuestionMark) p.printWithNoIndent("?") + if (dnn) { + p.printWithNoIndent(" & Any)") + } + + if (isMarkedNullable()) p.printWithNoIndent("?") } is IrDynamicType -> p.printWithNoIndent("dynamic") diff --git a/compiler/ir/serialization.common/src/KotlinIr.proto b/compiler/ir/serialization.common/src/KotlinIr.proto index cdfd26ea6ca..679789095c6 100644 --- a/compiler/ir/serialization.common/src/KotlinIr.proto +++ b/compiler/ir/serialization.common/src/KotlinIr.proto @@ -80,7 +80,7 @@ message Actual { // Note: IrTypeArgument [63..2 - IrType index | 1..0 - Variance] // If x...xxx00 -> * -message IrSimpleType { +message IrSimpleTypeLegacy { repeated IrConstructorCall annotation = 1; required int64 classifier = 2; required bool has_question_mark = 3; @@ -88,6 +88,20 @@ message IrSimpleType { optional IrTypeAbbreviation abbreviation = 5; } +enum IrSimpleTypeNullability { + MARKED_NULLABLE = 0; + NOT_SPECIFIED = 1; + DEFINITELY_NOT_NULL = 2; +} + +message IrSimpleType { + repeated IrConstructorCall annotation = 1; + required int64 classifier = 2; + optional IrSimpleTypeNullability nullability = 3 [default=NOT_SPECIFIED]; + repeated int64 argument = 4 [packed=true]; // 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance] + optional IrTypeAbbreviation abbreviation = 5; +} + message IrTypeAbbreviation { repeated IrConstructorCall annotation = 1; required int64 type_alias = 2; @@ -110,10 +124,11 @@ message IrErrorType { message IrType { oneof kind { - IrSimpleType simple = 1; + IrSimpleTypeLegacy legacySimple = 1; IrDynamicType dynamic = 2; IrErrorType error = 3; IrDefinitelyNotNullType dnn = 4; + IrSimpleType simple = 5; } } diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt index 7f19e110301..f578ab04683 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt @@ -50,7 +50,9 @@ import org.jetbrains.kotlin.backend.common.serialization.proto.IrInlineClassRepr import org.jetbrains.kotlin.backend.common.serialization.proto.IrLocalDelegatedProperty as ProtoLocalDelegatedProperty import org.jetbrains.kotlin.backend.common.serialization.proto.IrMultiFieldValueClassRepresentation as ProtoIrMultiFieldValueClassRepresentation import org.jetbrains.kotlin.backend.common.serialization.proto.IrProperty as ProtoProperty +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability as ProtoSimpleTypeNullablity import org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType as ProtoSimpleType +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy as ProtoSimpleTypeLegacy import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoType import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation as ProtoTypeAbbreviation @@ -110,6 +112,12 @@ class IrDeclarationDeserializer( } } + private fun deserializeSimpleTypeNullability(proto: ProtoSimpleTypeNullablity) = when (proto) { + ProtoSimpleTypeNullablity.MARKED_NULLABLE -> SimpleTypeNullability.MARKED_NULLABLE + ProtoSimpleTypeNullablity.NOT_SPECIFIED -> SimpleTypeNullability.NOT_SPECIFIED + ProtoSimpleTypeNullablity.DEFINITELY_NOT_NULL -> SimpleTypeNullability.DEFINITELY_NOT_NULL + } + private fun deserializeSimpleType(proto: ProtoSimpleType): IrSimpleType { val symbol = checkSymbolType(deserializeIrSymbolAndRemap(proto.classifier)) @@ -119,7 +127,23 @@ class IrDeclarationDeserializer( return IrSimpleTypeImpl( null, symbol, - proto.hasQuestionMark, + deserializeSimpleTypeNullability(proto.nullability), + arguments, + annotations, + if (proto.hasAbbreviation()) deserializeTypeAbbreviation(proto.abbreviation) else null + ) + } + + private fun deserializeLegacySimpleType(proto: ProtoSimpleTypeLegacy): IrSimpleType { + val symbol = checkSymbolType(deserializeIrSymbolAndRemap(proto.classifier)) + + val arguments = proto.argumentList.map { deserializeIrTypeArgument(it) } + val annotations = deserializeAnnotations(proto.annotationList) + + return IrSimpleTypeImpl( + null, + symbol, + SimpleTypeNullability.fromHasQuestionMark(proto.hasQuestionMark), arguments, annotations, if (proto.hasAbbreviation()) deserializeTypeAbbreviation(proto.abbreviation) else null @@ -145,16 +169,17 @@ class IrDeclarationDeserializer( return IrErrorTypeImpl(null, annotations, Variance.INVARIANT) } - private fun deserializeDefinitelyNotNullType(proto: ProtoDefinitelyNotNullType): IrDefinitelyNotNullType { + private fun deserializeDefinitelyNotNullType(proto: ProtoDefinitelyNotNullType): IrSimpleType { assert(proto.typesCount == 1) { "Only DefinitelyNotNull type is now supported" } // TODO support general case of intersection type - return IrDefinitelyNotNullTypeImpl(null, deserializeIrType(proto.typesList[0])) + return deserializeIrType(proto.typesList[0]).makeNotNull() as IrSimpleType } private fun deserializeIrTypeData(proto: ProtoType): IrType { return when (proto.kindCase) { DNN -> deserializeDefinitelyNotNullType(proto.dnn) SIMPLE -> deserializeSimpleType(proto.simple) + LEGACYSIMPLE -> deserializeLegacySimpleType(proto.legacySimple) DYNAMIC -> deserializeDynamicType(proto.dynamic) ERROR -> deserializeErrorType(proto.error) else -> error("Unexpected IrType kind: ${proto.kindCase}") diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt index 66e8b73a8cb..a09ff71a4e3 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.backend.common.serialization import org.jetbrains.kotlin.backend.common.serialization.encodings.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrFileEntry @@ -52,7 +53,6 @@ import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall import org.jetbrains.kotlin.backend.common.serialization.proto.IrContinue as ProtoContinue import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoDeclaration import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase as ProtoDeclarationBase -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType as ProtoDefinitelyNotNullType import org.jetbrains.kotlin.backend.common.serialization.proto.IrDelegatingConstructorCall as ProtoDelegatingConstructorCall import org.jetbrains.kotlin.backend.common.serialization.proto.IrDoWhile as ProtoDoWhile import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicMemberExpression as ProtoDynamicMemberExpression @@ -378,11 +378,19 @@ open class IrFileSerializer( } } + private fun serializeNullability(nullability: SimpleTypeNullability) = when (nullability) { + SimpleTypeNullability.MARKED_NULLABLE -> IrSimpleTypeNullability.MARKED_NULLABLE + SimpleTypeNullability.NOT_SPECIFIED -> IrSimpleTypeNullability.NOT_SPECIFIED + SimpleTypeNullability.DEFINITELY_NOT_NULL -> IrSimpleTypeNullability.DEFINITELY_NOT_NULL + } + private fun serializeSimpleType(type: IrSimpleType): ProtoSimpleType { val proto = ProtoSimpleType.newBuilder() .addAllAnnotation(serializeAnnotations(type.annotations)) .setClassifier(serializeIrSymbol(type.classifier)) - .setHasQuestionMark(type.hasQuestionMark) + if (type.nullability != SimpleTypeNullability.NOT_SPECIFIED) { + proto.setNullability(serializeNullability(type.nullability)) + } type.abbreviation?.let { ta -> proto.setAbbreviation(serializeIrTypeAbbreviation(ta)) } @@ -411,17 +419,10 @@ open class IrFileSerializer( .addAllAnnotation(serializeAnnotations(type.annotations)) .build() - private fun serializeDefinitelyNotNullType(type: IrDefinitelyNotNullType): ProtoDefinitelyNotNullType = - ProtoDefinitelyNotNullType.newBuilder() - .addTypes(serializeIrType(type.original)) -// .addTypes(serializeIrType(kotlin.Any)) - .build() private fun serializeIrTypeData(type: IrType): ProtoType { val proto = ProtoType.newBuilder() when (type) { - is IrDefinitelyNotNullType -> - proto.dnn = serializeDefinitelyNotNullType(type) is IrSimpleType -> proto.simple = serializeSimpleType(type) is IrDynamicType -> @@ -437,7 +438,6 @@ open class IrFileSerializer( SIMPLE, DYNAMIC, ERROR, - DEFINITELY_NOT_NULL } enum class IrTypeArgumentKind { @@ -449,7 +449,7 @@ open class IrFileSerializer( data class IrTypeKey( val kind: IrTypeKind, val classifier: IrClassifierSymbol?, - val hasQuestionMark: Boolean?, + val nullability: SimpleTypeNullability?, val arguments: List?, val annotations: List, val abbreviation: IrTypeAbbreviation? @@ -463,17 +463,16 @@ open class IrFileSerializer( private val IrType.toIrTypeKey: IrTypeKey get() { - var type = this + val type = this return IrTypeKey( kind = when (this) { - is IrDefinitelyNotNullType -> IrTypeKind.DEFINITELY_NOT_NULL.also { type = original } is IrSimpleType -> IrTypeKind.SIMPLE is IrDynamicType -> IrTypeKind.DYNAMIC is IrErrorType -> IrTypeKind.ERROR else -> error("Unexpected IrType kind: $this") }, classifier = type.classifierOrNull, - hasQuestionMark = (type as? IrSimpleType)?.hasQuestionMark, + nullability = (type as? IrSimpleType)?.nullability, arguments = (type as? IrSimpleType)?.arguments?.map { it.toIrTypeArgumentKey }, annotations = type.annotations, abbreviation = (type as? IrSimpleType)?.abbreviation diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/mangle/ir/IrMangleComputer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/mangle/ir/IrMangleComputer.kt index 7babf6b6488..e9258b24bb1 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/mangle/ir/IrMangleComputer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/mangle/ir/IrMangleComputer.kt @@ -186,15 +186,12 @@ abstract class IrMangleComputer(protected val builder: StringBuilder, private va } } - if (type.hasQuestionMark) tBuilder.appendSignature(MangleConstant.Q_MARK) + //TODO + if (type.isMarkedNullable()) tBuilder.appendSignature(MangleConstant.Q_MARK) mangleTypePlatformSpecific(type, tBuilder) } is IrDynamicType -> tBuilder.appendSignature(MangleConstant.DYNAMIC_MARK) - is IrDefinitelyNotNullType -> { - // TODO mangle DNN type differently from original simple type? - mangleType(tBuilder, type.original) - } is IrErrorType -> tBuilder.appendSignature(MangleConstant.ERROR_MARK) else -> error("Unexpected type $type") } diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleType.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleType.java index be6f4330028..5ce172760b8 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleType.java +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleType.java @@ -67,8 +67,15 @@ public final class IrSimpleType extends break; } case 24: { - bitField0_ |= 0x00000002; - hasQuestionMark_ = input.readBool(); + int rawValue = input.readEnum(); + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability value = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability.valueOf(rawValue); + if (value == null) { + unknownFieldsCodedOutput.writeRawVarint32(tag); + unknownFieldsCodedOutput.writeRawVarint32(rawValue); + } else { + bitField0_ |= 0x00000002; + nullability_ = value; + } break; } case 32: { @@ -195,19 +202,19 @@ public final class IrSimpleType extends return classifier_; } - public static final int HAS_QUESTION_MARK_FIELD_NUMBER = 3; - private boolean hasQuestionMark_; + public static final int NULLABILITY_FIELD_NUMBER = 3; + private org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability_; /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - public boolean hasHasQuestionMark() { + public boolean hasNullability() { return ((bitField0_ & 0x00000002) == 0x00000002); } /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - public boolean getHasQuestionMark() { - return hasQuestionMark_; + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability getNullability() { + return nullability_; } public static final int ARGUMENT_FIELD_NUMBER = 4; @@ -263,7 +270,7 @@ public final class IrSimpleType extends private void initFields() { annotation_ = java.util.Collections.emptyList(); classifier_ = 0L; - hasQuestionMark_ = false; + nullability_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability.NOT_SPECIFIED; argument_ = java.util.Collections.emptyList(); abbreviation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.getDefaultInstance(); } @@ -277,10 +284,6 @@ public final class IrSimpleType extends memoizedIsInitialized = 0; return false; } - if (!hasHasQuestionMark()) { - memoizedIsInitialized = 0; - return false; - } for (int i = 0; i < getAnnotationCount(); i++) { if (!getAnnotation(i).isInitialized()) { memoizedIsInitialized = 0; @@ -307,7 +310,7 @@ public final class IrSimpleType extends output.writeInt64(2, classifier_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBool(3, hasQuestionMark_); + output.writeEnum(3, nullability_.getNumber()); } if (getArgumentList().size() > 0) { output.writeRawVarint32(34); @@ -338,7 +341,7 @@ public final class IrSimpleType extends } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeBoolSize(3, hasQuestionMark_); + .computeEnumSize(3, nullability_.getNumber()); } { int dataSize = 0; @@ -456,7 +459,7 @@ public final class IrSimpleType extends bitField0_ = (bitField0_ & ~0x00000001); classifier_ = 0L; bitField0_ = (bitField0_ & ~0x00000002); - hasQuestionMark_ = false; + nullability_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability.NOT_SPECIFIED; bitField0_ = (bitField0_ & ~0x00000004); argument_ = java.util.Collections.emptyList(); bitField0_ = (bitField0_ & ~0x00000008); @@ -497,7 +500,7 @@ public final class IrSimpleType extends if (((from_bitField0_ & 0x00000004) == 0x00000004)) { to_bitField0_ |= 0x00000002; } - result.hasQuestionMark_ = hasQuestionMark_; + result.nullability_ = nullability_; if (((bitField0_ & 0x00000008) == 0x00000008)) { argument_ = java.util.Collections.unmodifiableList(argument_); bitField0_ = (bitField0_ & ~0x00000008); @@ -526,8 +529,8 @@ public final class IrSimpleType extends if (other.hasClassifier()) { setClassifier(other.getClassifier()); } - if (other.hasHasQuestionMark()) { - setHasQuestionMark(other.getHasQuestionMark()); + if (other.hasNullability()) { + setNullability(other.getNullability()); } if (!other.argument_.isEmpty()) { if (argument_.isEmpty()) { @@ -552,10 +555,6 @@ public final class IrSimpleType extends return false; } - if (!hasHasQuestionMark()) { - - return false; - } for (int i = 0; i < getAnnotationCount(); i++) { if (!getAnnotation(i).isInitialized()) { @@ -747,34 +746,37 @@ public final class IrSimpleType extends return this; } - private boolean hasQuestionMark_ ; + private org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability.NOT_SPECIFIED; /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - public boolean hasHasQuestionMark() { + public boolean hasNullability() { return ((bitField0_ & 0x00000004) == 0x00000004); } /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - public boolean getHasQuestionMark() { - return hasQuestionMark_; + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability getNullability() { + return nullability_; } /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - public Builder setHasQuestionMark(boolean value) { + public Builder setNullability(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability value) { + if (value == null) { + throw new NullPointerException(); + } bitField0_ |= 0x00000004; - hasQuestionMark_ = value; + nullability_ = value; return this; } /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - public Builder clearHasQuestionMark() { + public Builder clearNullability() { bitField0_ = (bitField0_ & ~0x00000004); - hasQuestionMark_ = false; + nullability_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability.NOT_SPECIFIED; return this; } diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeLegacy.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeLegacy.java new file mode 100644 index 00000000000..da9ba71a489 --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeLegacy.java @@ -0,0 +1,945 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: compiler/ir/serialization.common/src/KotlinIr.proto + +package org.jetbrains.kotlin.backend.common.serialization.proto; + +/** + * Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy} + */ +public final class IrSimpleTypeLegacy extends + org.jetbrains.kotlin.protobuf.GeneratedMessageLite implements + // @@protoc_insertion_point(message_implements:org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) + IrSimpleTypeLegacyOrBuilder { + // Use IrSimpleTypeLegacy.newBuilder() to construct. + private IrSimpleTypeLegacy(org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private IrSimpleTypeLegacy(boolean noInit) { this.unknownFields = org.jetbrains.kotlin.protobuf.ByteString.EMPTY;} + + private static final IrSimpleTypeLegacy defaultInstance; + public static IrSimpleTypeLegacy getDefaultInstance() { + return defaultInstance; + } + + public IrSimpleTypeLegacy getDefaultInstanceForType() { + return defaultInstance; + } + + private final org.jetbrains.kotlin.protobuf.ByteString unknownFields; + private IrSimpleTypeLegacy( + org.jetbrains.kotlin.protobuf.CodedInputStream input, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + org.jetbrains.kotlin.protobuf.ByteString.Output unknownFieldsOutput = + org.jetbrains.kotlin.protobuf.ByteString.newOutput(); + org.jetbrains.kotlin.protobuf.CodedOutputStream unknownFieldsCodedOutput = + org.jetbrains.kotlin.protobuf.CodedOutputStream.newInstance( + unknownFieldsOutput, 1); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFieldsCodedOutput, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + annotation_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + annotation_.add(input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.PARSER, extensionRegistry)); + break; + } + case 16: { + bitField0_ |= 0x00000001; + classifier_ = input.readInt64(); + break; + } + case 24: { + bitField0_ |= 0x00000002; + hasQuestionMark_ = input.readBool(); + break; + } + case 32: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + argument_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + argument_.add(input.readInt64()); + break; + } + case 34: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008) && input.getBytesUntilLimit() > 0) { + argument_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + while (input.getBytesUntilLimit() > 0) { + argument_.add(input.readInt64()); + } + input.popLimit(limit); + break; + } + case 42: { + org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.Builder subBuilder = null; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subBuilder = abbreviation_.toBuilder(); + } + abbreviation_ = input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(abbreviation_); + abbreviation_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000004; + break; + } + } + } + } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + annotation_ = java.util.Collections.unmodifiableList(annotation_); + } + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + argument_ = java.util.Collections.unmodifiableList(argument_); + } + try { + unknownFieldsCodedOutput.flush(); + } catch (java.io.IOException e) { + // Should not happen + } finally { + unknownFields = unknownFieldsOutput.toByteString(); + } + makeExtensionsImmutable(); + } + } + public static org.jetbrains.kotlin.protobuf.Parser PARSER = + new org.jetbrains.kotlin.protobuf.AbstractParser() { + public IrSimpleTypeLegacy parsePartialFrom( + org.jetbrains.kotlin.protobuf.CodedInputStream input, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException { + return new IrSimpleTypeLegacy(input, extensionRegistry); + } + }; + + @java.lang.Override + public org.jetbrains.kotlin.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int ANNOTATION_FIELD_NUMBER = 1; + private java.util.List annotation_; + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public java.util.List getAnnotationList() { + return annotation_; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public java.util.List + getAnnotationOrBuilderList() { + return annotation_; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public int getAnnotationCount() { + return annotation_.size(); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall getAnnotation(int index) { + return annotation_.get(index); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCallOrBuilder getAnnotationOrBuilder( + int index) { + return annotation_.get(index); + } + + public static final int CLASSIFIER_FIELD_NUMBER = 2; + private long classifier_; + /** + * required int64 classifier = 2; + */ + public boolean hasClassifier() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required int64 classifier = 2; + */ + public long getClassifier() { + return classifier_; + } + + public static final int HAS_QUESTION_MARK_FIELD_NUMBER = 3; + private boolean hasQuestionMark_; + /** + * required bool has_question_mark = 3; + */ + public boolean hasHasQuestionMark() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required bool has_question_mark = 3; + */ + public boolean getHasQuestionMark() { + return hasQuestionMark_; + } + + public static final int ARGUMENT_FIELD_NUMBER = 4; + private java.util.List argument_; + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+   * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+   * 
+ */ + public java.util.List + getArgumentList() { + return argument_; + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+   * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+   * 
+ */ + public int getArgumentCount() { + return argument_.size(); + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+   * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+   * 
+ */ + public long getArgument(int index) { + return argument_.get(index); + } + private int argumentMemoizedSerializedSize = -1; + + public static final int ABBREVIATION_FIELD_NUMBER = 5; + private org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation_; + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public boolean hasAbbreviation() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation getAbbreviation() { + return abbreviation_; + } + + private void initFields() { + annotation_ = java.util.Collections.emptyList(); + classifier_ = 0L; + hasQuestionMark_ = false; + argument_ = java.util.Collections.emptyList(); + abbreviation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasClassifier()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasHasQuestionMark()) { + memoizedIsInitialized = 0; + return false; + } + for (int i = 0; i < getAnnotationCount(); i++) { + if (!getAnnotation(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + if (hasAbbreviation()) { + if (!getAbbreviation().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(org.jetbrains.kotlin.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < annotation_.size(); i++) { + output.writeMessage(1, annotation_.get(i)); + } + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt64(2, classifier_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBool(3, hasQuestionMark_); + } + if (getArgumentList().size() > 0) { + output.writeRawVarint32(34); + output.writeRawVarint32(argumentMemoizedSerializedSize); + } + for (int i = 0; i < argument_.size(); i++) { + output.writeInt64NoTag(argument_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeMessage(5, abbreviation_); + } + output.writeRawBytes(unknownFields); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < annotation_.size(); i++) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeMessageSize(1, annotation_.get(i)); + } + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeInt64Size(2, classifier_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeBoolSize(3, hasQuestionMark_); + } + { + int dataSize = 0; + for (int i = 0; i < argument_.size(); i++) { + dataSize += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeInt64SizeNoTag(argument_.get(i)); + } + size += dataSize; + if (!getArgumentList().isEmpty()) { + size += 1; + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + argumentMemoizedSerializedSize = dataSize; + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeMessageSize(5, abbreviation_); + } + size += unknownFields.size(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom( + org.jetbrains.kotlin.protobuf.ByteString data) + throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom( + org.jetbrains.kotlin.protobuf.ByteString data, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom(byte[] data) + throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom( + byte[] data, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom( + java.io.InputStream input, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseDelimitedFrom( + java.io.InputStream input, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom( + org.jetbrains.kotlin.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parseFrom( + org.jetbrains.kotlin.protobuf.CodedInputStream input, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + /** + * Protobuf type {@code org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy} + */ + public static final class Builder extends + org.jetbrains.kotlin.protobuf.GeneratedMessageLite.Builder< + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy, Builder> + implements + // @@protoc_insertion_point(builder_implements:org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacyOrBuilder { + // Construct using org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + annotation_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + classifier_ = 0L; + bitField0_ = (bitField0_ & ~0x00000002); + hasQuestionMark_ = false; + bitField0_ = (bitField0_ & ~0x00000004); + argument_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + abbreviation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.getDefaultInstance(); + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy getDefaultInstanceForType() { + return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.getDefaultInstance(); + } + + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy build() { + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy buildPartial() { + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy result = new org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + annotation_ = java.util.Collections.unmodifiableList(annotation_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.annotation_ = annotation_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000001; + } + result.classifier_ = classifier_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000002; + } + result.hasQuestionMark_ = hasQuestionMark_; + if (((bitField0_ & 0x00000008) == 0x00000008)) { + argument_ = java.util.Collections.unmodifiableList(argument_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.argument_ = argument_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000004; + } + result.abbreviation_ = abbreviation_; + result.bitField0_ = to_bitField0_; + return result; + } + + public Builder mergeFrom(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy other) { + if (other == org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.getDefaultInstance()) return this; + if (!other.annotation_.isEmpty()) { + if (annotation_.isEmpty()) { + annotation_ = other.annotation_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAnnotationIsMutable(); + annotation_.addAll(other.annotation_); + } + + } + if (other.hasClassifier()) { + setClassifier(other.getClassifier()); + } + if (other.hasHasQuestionMark()) { + setHasQuestionMark(other.getHasQuestionMark()); + } + if (!other.argument_.isEmpty()) { + if (argument_.isEmpty()) { + argument_ = other.argument_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureArgumentIsMutable(); + argument_.addAll(other.argument_); + } + + } + if (other.hasAbbreviation()) { + mergeAbbreviation(other.getAbbreviation()); + } + setUnknownFields( + getUnknownFields().concat(other.unknownFields)); + return this; + } + + public final boolean isInitialized() { + if (!hasClassifier()) { + + return false; + } + if (!hasHasQuestionMark()) { + + return false; + } + for (int i = 0; i < getAnnotationCount(); i++) { + if (!getAnnotation(i).isInitialized()) { + + return false; + } + } + if (hasAbbreviation()) { + if (!getAbbreviation().isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + org.jetbrains.kotlin.protobuf.CodedInputStream input, + org.jetbrains.kotlin.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List annotation_ = + java.util.Collections.emptyList(); + private void ensureAnnotationIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + annotation_ = new java.util.ArrayList(annotation_); + bitField0_ |= 0x00000001; + } + } + + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public java.util.List getAnnotationList() { + return java.util.Collections.unmodifiableList(annotation_); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public int getAnnotationCount() { + return annotation_.size(); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall getAnnotation(int index) { + return annotation_.get(index); + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder setAnnotation( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAnnotationIsMutable(); + annotation_.set(index, value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder setAnnotation( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.Builder builderForValue) { + ensureAnnotationIsMutable(); + annotation_.set(index, builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder addAnnotation(org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAnnotationIsMutable(); + annotation_.add(value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder addAnnotation( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAnnotationIsMutable(); + annotation_.add(index, value); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder addAnnotation( + org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.Builder builderForValue) { + ensureAnnotationIsMutable(); + annotation_.add(builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder addAnnotation( + int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.Builder builderForValue) { + ensureAnnotationIsMutable(); + annotation_.add(index, builderForValue.build()); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder addAllAnnotation( + java.lang.Iterable values) { + ensureAnnotationIsMutable(); + org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( + values, annotation_); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder clearAnnotation() { + annotation_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + + return this; + } + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + public Builder removeAnnotation(int index) { + ensureAnnotationIsMutable(); + annotation_.remove(index); + + return this; + } + + private long classifier_ ; + /** + * required int64 classifier = 2; + */ + public boolean hasClassifier() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int64 classifier = 2; + */ + public long getClassifier() { + return classifier_; + } + /** + * required int64 classifier = 2; + */ + public Builder setClassifier(long value) { + bitField0_ |= 0x00000002; + classifier_ = value; + + return this; + } + /** + * required int64 classifier = 2; + */ + public Builder clearClassifier() { + bitField0_ = (bitField0_ & ~0x00000002); + classifier_ = 0L; + + return this; + } + + private boolean hasQuestionMark_ ; + /** + * required bool has_question_mark = 3; + */ + public boolean hasHasQuestionMark() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required bool has_question_mark = 3; + */ + public boolean getHasQuestionMark() { + return hasQuestionMark_; + } + /** + * required bool has_question_mark = 3; + */ + public Builder setHasQuestionMark(boolean value) { + bitField0_ |= 0x00000004; + hasQuestionMark_ = value; + + return this; + } + /** + * required bool has_question_mark = 3; + */ + public Builder clearHasQuestionMark() { + bitField0_ = (bitField0_ & ~0x00000004); + hasQuestionMark_ = false; + + return this; + } + + private java.util.List argument_ = java.util.Collections.emptyList(); + private void ensureArgumentIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + argument_ = new java.util.ArrayList(argument_); + bitField0_ |= 0x00000008; + } + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public java.util.List + getArgumentList() { + return java.util.Collections.unmodifiableList(argument_); + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public int getArgumentCount() { + return argument_.size(); + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public long getArgument(int index) { + return argument_.get(index); + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public Builder setArgument( + int index, long value) { + ensureArgumentIsMutable(); + argument_.set(index, value); + + return this; + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public Builder addArgument(long value) { + ensureArgumentIsMutable(); + argument_.add(value); + + return this; + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public Builder addAllArgument( + java.lang.Iterable values) { + ensureArgumentIsMutable(); + org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll( + values, argument_); + + return this; + } + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+     * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+     * 
+ */ + public Builder clearArgument() { + argument_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + + return this; + } + + private org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.getDefaultInstance(); + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public boolean hasAbbreviation() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation getAbbreviation() { + return abbreviation_; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public Builder setAbbreviation(org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation value) { + if (value == null) { + throw new NullPointerException(); + } + abbreviation_ = value; + + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public Builder setAbbreviation( + org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.Builder builderForValue) { + abbreviation_ = builderForValue.build(); + + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public Builder mergeAbbreviation(org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation value) { + if (((bitField0_ & 0x00000010) == 0x00000010) && + abbreviation_ != org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.getDefaultInstance()) { + abbreviation_ = + org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.newBuilder(abbreviation_).mergeFrom(value).buildPartial(); + } else { + abbreviation_ = value; + } + + bitField0_ |= 0x00000010; + return this; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + public Builder clearAbbreviation() { + abbreviation_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.getDefaultInstance(); + + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) + } + + static { + defaultInstance = new IrSimpleTypeLegacy(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) +} diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeLegacyOrBuilder.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeLegacyOrBuilder.java new file mode 100644 index 00000000000..0f88262cc8e --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeLegacyOrBuilder.java @@ -0,0 +1,75 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: compiler/ir/serialization.common/src/KotlinIr.proto + +package org.jetbrains.kotlin.backend.common.serialization.proto; + +public interface IrSimpleTypeLegacyOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) + org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder { + + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + java.util.List + getAnnotationList(); + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall getAnnotation(int index); + /** + * repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1; + */ + int getAnnotationCount(); + + /** + * required int64 classifier = 2; + */ + boolean hasClassifier(); + /** + * required int64 classifier = 2; + */ + long getClassifier(); + + /** + * required bool has_question_mark = 3; + */ + boolean hasHasQuestionMark(); + /** + * required bool has_question_mark = 3; + */ + boolean getHasQuestionMark(); + + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+   * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+   * 
+ */ + java.util.List getArgumentList(); + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+   * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+   * 
+ */ + int getArgumentCount(); + /** + * repeated int64 argument = 4 [packed = true]; + * + *
+   * 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
+   * 
+ */ + long getArgument(int index); + + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + boolean hasAbbreviation(); + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5; + */ + org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation getAbbreviation(); +} \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeNullability.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeNullability.java new file mode 100644 index 00000000000..51fe68c617e --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeNullability.java @@ -0,0 +1,69 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: compiler/ir/serialization.common/src/KotlinIr.proto + +package org.jetbrains.kotlin.backend.common.serialization.proto; + +/** + * Protobuf enum {@code org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability} + */ +public enum IrSimpleTypeNullability + implements org.jetbrains.kotlin.protobuf.Internal.EnumLite { + /** + * MARKED_NULLABLE = 0; + */ + MARKED_NULLABLE(0, 0), + /** + * NOT_SPECIFIED = 1; + */ + NOT_SPECIFIED(1, 1), + /** + * DEFINITELY_NOT_NULL = 2; + */ + DEFINITELY_NOT_NULL(2, 2), + ; + + /** + * MARKED_NULLABLE = 0; + */ + public static final int MARKED_NULLABLE_VALUE = 0; + /** + * NOT_SPECIFIED = 1; + */ + public static final int NOT_SPECIFIED_VALUE = 1; + /** + * DEFINITELY_NOT_NULL = 2; + */ + public static final int DEFINITELY_NOT_NULL_VALUE = 2; + + + public final int getNumber() { return value; } + + public static IrSimpleTypeNullability valueOf(int value) { + switch (value) { + case 0: return MARKED_NULLABLE; + case 1: return NOT_SPECIFIED; + case 2: return DEFINITELY_NOT_NULL; + default: return null; + } + } + + public static org.jetbrains.kotlin.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static org.jetbrains.kotlin.protobuf.Internal.EnumLiteMap + internalValueMap = + new org.jetbrains.kotlin.protobuf.Internal.EnumLiteMap() { + public IrSimpleTypeNullability findValueByNumber(int number) { + return IrSimpleTypeNullability.valueOf(number); + } + }; + + private final int value; + + private IrSimpleTypeNullability(int index, int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability) +} diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeOrBuilder.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeOrBuilder.java index 9246e57b469..44f389f693d 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeOrBuilder.java +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrSimpleTypeOrBuilder.java @@ -31,13 +31,13 @@ public interface IrSimpleTypeOrBuilder extends long getClassifier(); /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - boolean hasHasQuestionMark(); + boolean hasNullability(); /** - * required bool has_question_mark = 3; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED]; */ - boolean getHasQuestionMark(); + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability getNullability(); /** * repeated int64 argument = 4 [packed = true]; diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrType.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrType.java index eed40ac60ae..e23a85c47ca 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrType.java +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrType.java @@ -54,13 +54,13 @@ public final class IrType extends break; } case 10: { - org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.Builder subBuilder = null; + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.Builder subBuilder = null; if (kindCase_ == 1) { - subBuilder = ((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_).toBuilder(); + subBuilder = ((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_).toBuilder(); } - kind_ = input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.PARSER, extensionRegistry); + kind_ = input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.PARSER, extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_); + subBuilder.mergeFrom((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_); kind_ = subBuilder.buildPartial(); } kindCase_ = 1; @@ -105,6 +105,19 @@ public final class IrType extends kindCase_ = 4; break; } + case 42: { + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.Builder subBuilder = null; + if (kindCase_ == 5) { + subBuilder = ((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_).toBuilder(); + } + kind_ = input.readMessage(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_); + kind_ = subBuilder.buildPartial(); + } + kindCase_ = 5; + break; + } } } } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { @@ -143,10 +156,11 @@ public final class IrType extends private java.lang.Object kind_; public enum KindCase implements org.jetbrains.kotlin.protobuf.Internal.EnumLite { - SIMPLE(1), + LEGACYSIMPLE(1), DYNAMIC(2), ERROR(3), DNN(4), + SIMPLE(5), KIND_NOT_SET(0); private int value = 0; private KindCase(int value) { @@ -154,10 +168,11 @@ public final class IrType extends } public static KindCase valueOf(int value) { switch (value) { - case 1: return SIMPLE; + case 1: return LEGACYSIMPLE; case 2: return DYNAMIC; case 3: return ERROR; case 4: return DNN; + case 5: return SIMPLE; case 0: return KIND_NOT_SET; default: throw new java.lang.IllegalArgumentException( "Value is undefined for this oneof enum."); @@ -174,21 +189,21 @@ public final class IrType extends kindCase_); } - public static final int SIMPLE_FIELD_NUMBER = 1; + public static final int LEGACYSIMPLE_FIELD_NUMBER = 1; /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public boolean hasSimple() { + public boolean hasLegacySimple() { return kindCase_ == 1; } /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple() { + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy getLegacySimple() { if (kindCase_ == 1) { - return (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_; + return (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_; } - return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.getDefaultInstance(); + return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.getDefaultInstance(); } public static final int DYNAMIC_FIELD_NUMBER = 2; @@ -242,6 +257,23 @@ public final class IrType extends return org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType.getDefaultInstance(); } + public static final int SIMPLE_FIELD_NUMBER = 5; + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public boolean hasSimple() { + return kindCase_ == 5; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple() { + if (kindCase_ == 5) { + return (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_; + } + return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.getDefaultInstance(); + } + private void initFields() { } private byte memoizedIsInitialized = -1; @@ -250,8 +282,8 @@ public final class IrType extends if (isInitialized == 1) return true; if (isInitialized == 0) return false; - if (hasSimple()) { - if (!getSimple().isInitialized()) { + if (hasLegacySimple()) { + if (!getLegacySimple().isInitialized()) { memoizedIsInitialized = 0; return false; } @@ -268,6 +300,12 @@ public final class IrType extends return false; } } + if (hasSimple()) { + if (!getSimple().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } memoizedIsInitialized = 1; return true; } @@ -276,7 +314,7 @@ public final class IrType extends throws java.io.IOException { getSerializedSize(); if (kindCase_ == 1) { - output.writeMessage(1, (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_); + output.writeMessage(1, (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_); } if (kindCase_ == 2) { output.writeMessage(2, (org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicType) kind_); @@ -287,6 +325,9 @@ public final class IrType extends if (kindCase_ == 4) { output.writeMessage(4, (org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType) kind_); } + if (kindCase_ == 5) { + output.writeMessage(5, (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_); + } output.writeRawBytes(unknownFields); } @@ -298,7 +339,7 @@ public final class IrType extends size = 0; if (kindCase_ == 1) { size += org.jetbrains.kotlin.protobuf.CodedOutputStream - .computeMessageSize(1, (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_); + .computeMessageSize(1, (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_); } if (kindCase_ == 2) { size += org.jetbrains.kotlin.protobuf.CodedOutputStream @@ -312,6 +353,10 @@ public final class IrType extends size += org.jetbrains.kotlin.protobuf.CodedOutputStream .computeMessageSize(4, (org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType) kind_); } + if (kindCase_ == 5) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeMessageSize(5, (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_); + } size += unknownFields.size(); memoizedSerializedSize = size; return size; @@ -443,6 +488,9 @@ public final class IrType extends if (kindCase_ == 4) { result.kind_ = kind_; } + if (kindCase_ == 5) { + result.kind_ = kind_; + } result.bitField0_ = to_bitField0_; result.kindCase_ = kindCase_; return result; @@ -451,8 +499,8 @@ public final class IrType extends public Builder mergeFrom(org.jetbrains.kotlin.backend.common.serialization.proto.IrType other) { if (other == org.jetbrains.kotlin.backend.common.serialization.proto.IrType.getDefaultInstance()) return this; switch (other.getKindCase()) { - case SIMPLE: { - mergeSimple(other.getSimple()); + case LEGACYSIMPLE: { + mergeLegacySimple(other.getLegacySimple()); break; } case DYNAMIC: { @@ -467,6 +515,10 @@ public final class IrType extends mergeDnn(other.getDnn()); break; } + case SIMPLE: { + mergeSimple(other.getSimple()); + break; + } case KIND_NOT_SET: { break; } @@ -477,8 +529,8 @@ public final class IrType extends } public final boolean isInitialized() { - if (hasSimple()) { - if (!getSimple().isInitialized()) { + if (hasLegacySimple()) { + if (!getLegacySimple().isInitialized()) { return false; } @@ -495,6 +547,12 @@ public final class IrType extends return false; } } + if (hasSimple()) { + if (!getSimple().isInitialized()) { + + return false; + } + } return true; } @@ -532,24 +590,24 @@ public final class IrType extends private int bitField0_; /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public boolean hasSimple() { + public boolean hasLegacySimple() { return kindCase_ == 1; } /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple() { + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy getLegacySimple() { if (kindCase_ == 1) { - return (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_; + return (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_; } - return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.getDefaultInstance(); + return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.getDefaultInstance(); } /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public Builder setSimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType value) { + public Builder setLegacySimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy value) { if (value == null) { throw new NullPointerException(); } @@ -559,22 +617,22 @@ public final class IrType extends return this; } /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public Builder setSimple( - org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.Builder builderForValue) { + public Builder setLegacySimple( + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.Builder builderForValue) { kind_ = builderForValue.build(); kindCase_ = 1; return this; } /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public Builder mergeSimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType value) { + public Builder mergeLegacySimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy value) { if (kindCase_ == 1 && - kind_ != org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.getDefaultInstance()) { - kind_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.newBuilder((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_) + kind_ != org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.getDefaultInstance()) { + kind_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy.newBuilder((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy) kind_) .mergeFrom(value).buildPartial(); } else { kind_ = value; @@ -584,9 +642,9 @@ public final class IrType extends return this; } /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - public Builder clearSimple() { + public Builder clearLegacySimple() { if (kindCase_ == 1) { kindCase_ = 0; kind_ = null; @@ -787,6 +845,70 @@ public final class IrType extends return this; } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public boolean hasSimple() { + return kindCase_ == 5; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple() { + if (kindCase_ == 5) { + return (org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_; + } + return org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.getDefaultInstance(); + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public Builder setSimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType value) { + if (value == null) { + throw new NullPointerException(); + } + kind_ = value; + + kindCase_ = 5; + return this; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public Builder setSimple( + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.Builder builderForValue) { + kind_ = builderForValue.build(); + + kindCase_ = 5; + return this; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public Builder mergeSimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType value) { + if (kindCase_ == 5 && + kind_ != org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.getDefaultInstance()) { + kind_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.newBuilder((org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType) kind_) + .mergeFrom(value).buildPartial(); + } else { + kind_ = value; + } + + kindCase_ = 5; + return this; + } + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + public Builder clearSimple() { + if (kindCase_ == 5) { + kindCase_ = 0; + kind_ = null; + + } + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrType) } diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrTypeOrBuilder.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrTypeOrBuilder.java index e76a12a75df..9191c581422 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrTypeOrBuilder.java +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrTypeOrBuilder.java @@ -8,13 +8,13 @@ public interface IrTypeOrBuilder extends org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder { /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - boolean hasSimple(); + boolean hasLegacySimple(); /** - * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1; + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1; */ - org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple(); + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy getLegacySimple(); /** * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicType dynamic = 2; @@ -42,4 +42,13 @@ public interface IrTypeOrBuilder extends * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType dnn = 4; */ org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType getDnn(); + + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + boolean hasSimple(); + /** + * optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5; + */ + org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple(); } \ No newline at end of file diff --git a/compiler/testData/codegen/box/fir/callableReferenceToJavaField.fir.ir.txt b/compiler/testData/codegen/box/fir/callableReferenceToJavaField.fir.ir.txt index 1f9e6599318..1a48be4ad79 100644 --- a/compiler/testData/codegen/box/fir/callableReferenceToJavaField.fir.ir.txt +++ b/compiler/testData/codegen/box/fir/callableReferenceToJavaField.fir.ir.txt @@ -42,7 +42,7 @@ FILE fqName:foo fileName:/main.kt $this: VALUE_PARAMETER name: type:foo.Derived BLOCK_BODY CALL 'public open fun set (p0: @[FlexibleNullability] kotlin.Any?, p1: @[FlexibleNullability] kotlin.Any?): kotlin.Unit [operator] declared in java.lang.reflect.Field' type=kotlin.Unit origin=null - $this: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=java.lang.reflect.Field origin=EXCLEXCL + $this: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=java.lang.reflect.Field origin=EXCLEXCL : java.lang.reflect.Field arg0: CALL 'public final fun (): java.lang.reflect.Field? declared in kotlin.reflect.jvm.ReflectJvmMapping' type=java.lang.reflect.Field? origin=GET_PROPERTY $receiver: PROPERTY_REFERENCE 'protected/*protected and package*/ open a: @[FlexibleNullability] foo.A? [var]' field='FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:a type:@[FlexibleNullability] foo.A? visibility:protected/*protected and package*/' getter='protected/*protected and package*/ open fun (): @[FlexibleNullability] foo.A? declared in foo.Derived' setter='protected/*protected and package*/ open fun (: @[FlexibleNullability] foo.A?): kotlin.Unit declared in foo.Derived' type=kotlin.reflect.KMutableProperty1 origin=null diff --git a/compiler/testData/codegen/box/fir/callableReferenceToJavaField.ir.txt b/compiler/testData/codegen/box/fir/callableReferenceToJavaField.ir.txt index dea0f99dbd6..b92e1e25bc4 100644 --- a/compiler/testData/codegen/box/fir/callableReferenceToJavaField.ir.txt +++ b/compiler/testData/codegen/box/fir/callableReferenceToJavaField.ir.txt @@ -42,7 +42,7 @@ FILE fqName:foo fileName:/main.kt $this: VALUE_PARAMETER name: type:foo.Derived BLOCK_BODY CALL 'public open fun set (p0: @[FlexibleNullability] kotlin.Any?, p1: @[FlexibleNullability] kotlin.Any?): kotlin.Unit [operator] declared in java.lang.reflect.Field' type=kotlin.Unit origin=EQ - $this: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=java.lang.reflect.Field origin=EXCLEXCL + $this: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=java.lang.reflect.Field origin=EXCLEXCL : java.lang.reflect.Field arg0: CALL 'public final fun (): java.lang.reflect.Field? declared in kotlin.reflect.jvm.ReflectJvmMapping' type=java.lang.reflect.Field? origin=GET_PROPERTY $receiver: PROPERTY_REFERENCE 'protected/*protected and package*/ final a [fake_override,var]' field='FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:a type:@[FlexibleNullability] foo.A? visibility:protected/*protected and package*/' getter=null setter=null type=kotlin.reflect.KMutableProperty1 origin=null diff --git a/compiler/testData/ir/irJsText/dynamic/dynamicExclExclOperator.txt b/compiler/testData/ir/irJsText/dynamic/dynamicExclExclOperator.txt index a42e946b202..37d3c98dc0c 100644 --- a/compiler/testData/ir/irJsText/dynamic/dynamicExclExclOperator.txt +++ b/compiler/testData/ir/irJsText/dynamic/dynamicExclExclOperator.txt @@ -3,6 +3,6 @@ FILE fqName: fileName:/dynamicExclExclOperator.kt VALUE_PARAMETER name:d index:0 type:dynamic BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (d: dynamic): dynamic declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=dynamic origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=dynamic origin=EXCLEXCL : dynamic arg0: GET_VAR 'd: dynamic declared in .test' type=dynamic origin=null diff --git a/compiler/testData/ir/irText/classes/dataClasses/kt31649.kt.txt b/compiler/testData/ir/irText/classes/dataClasses/kt31649.kt.txt index cab6a120915..de04e526cd5 100644 --- a/compiler/testData/ir/irText/classes/dataClasses/kt31649.kt.txt +++ b/compiler/testData/ir/irText/classes/dataClasses/kt31649.kt.txt @@ -78,4 +78,3 @@ value class TestInline { } } - diff --git a/compiler/testData/ir/irText/classes/inlineClass.kt.txt b/compiler/testData/ir/irText/classes/inlineClass.kt.txt index 861ec1a51cf..ec5dccc1cca 100644 --- a/compiler/testData/ir/irText/classes/inlineClass.kt.txt +++ b/compiler/testData/ir/irText/classes/inlineClass.kt.txt @@ -29,4 +29,3 @@ value class Test { } } - diff --git a/compiler/testData/ir/irText/classes/inlineClassSyntheticMethods.kt.txt b/compiler/testData/ir/irText/classes/inlineClassSyntheticMethods.kt.txt index 6d9a02e0f68..539459e3dd9 100644 --- a/compiler/testData/ir/irText/classes/inlineClassSyntheticMethods.kt.txt +++ b/compiler/testData/ir/irText/classes/inlineClassSyntheticMethods.kt.txt @@ -58,4 +58,3 @@ fun box(): String { } return "OK" } - diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt index c1758dad909..f05128f3fee 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt @@ -97,4 +97,3 @@ fun test() { } ) } - diff --git a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt.txt b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt.txt index fc336bd34fe..47b2b6b074a 100644 --- a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt.txt +++ b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt.txt @@ -106,4 +106,3 @@ value class InlineMutableSet : MutableSet { } } - diff --git a/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt b/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt index 1268151c68a..2eefcf73e51 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt @@ -3,14 +3,14 @@ FILE fqName: fileName:/bangbang.kt VALUE_PARAMETER name:a index:0 type:kotlin.Any? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?): kotlin.Any declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL : kotlin.Any arg0: GET_VAR 'a: kotlin.Any? declared in .test1' type=kotlin.Any? origin=null FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Int VALUE_PARAMETER name:a index:0 type:kotlin.Any? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): kotlin.Int declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Int origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Int origin=EXCLEXCL : kotlin.Int arg0: BLOCK type=kotlin.Int? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] @@ -30,8 +30,8 @@ FILE fqName: fileName:/bangbang.kt VALUE_PARAMETER name:a index:0 type:X of .test3 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (a: X of .test3): {X of .test3 & Any} declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={X of .test3 & Any} origin=EXCLEXCL - : X of .test3 + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type={X of .test3 & Any} origin=EXCLEXCL + : {X of .test3 & Any} arg0: GET_VAR 'a: X of .test3 declared in .test3' type=X of .test3 origin=null FUN name:useString visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit VALUE_PARAMETER name:s index:0 type:kotlin.String @@ -45,7 +45,7 @@ FILE fqName: fileName:/bangbang.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : kotlin.String arg0: TYPE_OP type=kotlin.String? origin=IMPLICIT_CAST typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null @@ -54,7 +54,7 @@ FILE fqName: fileName:/bangbang.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null then: CALL 'public final fun useString (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null - s: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + s: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : kotlin.String arg0: TYPE_OP type=kotlin.String? origin=IMPLICIT_CAST typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null diff --git a/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt b/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt index 8135699d2d0..e484c8e9ccd 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt @@ -13,7 +13,7 @@ fun test2(a: Any?): Int { } fun test3(a: X): (X & Any) { - return CHECK_NOT_NULL(arg0 = a) + return CHECK_NOT_NULL<(X & Any)>(arg0 = a) } fun useString(s: String) { @@ -27,4 +27,3 @@ fun test4(a: X) { a is String? -> useString(s = CHECK_NOT_NULL(arg0 = a /*as String? */)) } } - diff --git a/compiler/testData/ir/irText/expressions/bangbang.ir.txt b/compiler/testData/ir/irText/expressions/bangbang.ir.txt index c4aa6f09d9f..0531b4dd584 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.ir.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.ir.txt @@ -3,14 +3,14 @@ FILE fqName: fileName:/bangbang.kt VALUE_PARAMETER name:a index:0 type:kotlin.Any? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Any?): kotlin.Any declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL : kotlin.Any arg0: GET_VAR 'a: kotlin.Any? declared in .test1' type=kotlin.Any? origin=null FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any?) returnType:kotlin.Int VALUE_PARAMETER name:a index:0 type:kotlin.Any? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Any?): kotlin.Int declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Int origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Int origin=EXCLEXCL : kotlin.Int arg0: BLOCK type=kotlin.Int? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] @@ -30,7 +30,7 @@ FILE fqName: fileName:/bangbang.kt VALUE_PARAMETER name:a index:0 type:X of .test3 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (a: X of .test3): {X of .test3 & Any} declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=X of .test3 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=X of .test3 origin=EXCLEXCL : X of .test3 arg0: GET_VAR 'a: X of .test3 declared in .test3' type=X of .test3 origin=null FUN name:useString visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit @@ -45,7 +45,7 @@ FILE fqName: fileName:/bangbang.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=X of .test4 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=X of .test4 origin=EXCLEXCL : X of .test4 arg0: GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null WHEN type=kotlin.Unit origin=IF @@ -54,6 +54,6 @@ FILE fqName: fileName:/bangbang.kt GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null then: CALL 'public final fun useString (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=X of .test4 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=X of .test4 origin=EXCLEXCL : X of .test4 arg0: GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null diff --git a/compiler/testData/ir/irText/expressions/bangbang.kt.txt b/compiler/testData/ir/irText/expressions/bangbang.kt.txt index afba0e9c630..a2703527a6b 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.kt.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.kt.txt @@ -27,4 +27,3 @@ fun test4(a: X) { a is String? -> useString(s = CHECK_NOT_NULL(arg0 = a) /*as String */) } } - diff --git a/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.fir.ir.txt b/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.fir.ir.txt index d533dcbd36f..e5e77ddb6d7 100644 --- a/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.fir.ir.txt @@ -5,14 +5,14 @@ FILE fqName: fileName:/exclExclOnPlatformType.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (a: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null - a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : kotlin.String arg0: CALL 'public open fun get (): T of java.lang.ref.WeakReference? [fake_override,operator] declared in java.lang.ref.WeakReference' type=kotlin.String? origin=null $this: CONSTRUCTOR_CALL 'public constructor (p0: @[FlexibleNullability] T of java.lang.ref.WeakReference?) declared in java.lang.ref.WeakReference' type=java.lang.ref.WeakReference<@[FlexibleNullability] kotlin.String?> origin=null : @[FlexibleNullability] kotlin.String? p0: CONST String type=kotlin.String value="" CALL 'public final fun use (a: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null - a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : @[FlexibleNullability] kotlin.String arg0: CALL 'public open fun getProperty (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] kotlin.String? declared in java.lang.System' type=@[FlexibleNullability] kotlin.String? origin=null p0: CONST String type=kotlin.String value="abc" diff --git a/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.ir.txt b/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.ir.txt index f11e263aae9..9721f5d8a3b 100644 --- a/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.ir.txt +++ b/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.ir.txt @@ -5,14 +5,14 @@ FILE fqName: fileName:/exclExclOnPlatformType.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (a: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null - a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : kotlin.String arg0: CALL 'public open fun get (): @[EnhancedNullability] T of java.lang.ref.WeakReference? [fake_override] declared in java.lang.ref.WeakReference' type=@[EnhancedNullability] kotlin.String? origin=null $this: CONSTRUCTOR_CALL 'public constructor (p0: @[FlexibleNullability] T of java.lang.ref.WeakReference?) declared in java.lang.ref.WeakReference' type=java.lang.ref.WeakReference<@[FlexibleNullability] kotlin.String?> origin=null : @[FlexibleNullability] kotlin.String? p0: CONST String type=kotlin.String value="" CALL 'public final fun use (a: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null - a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + a: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : kotlin.String arg0: CALL 'public open fun getProperty (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] kotlin.String? declared in java.lang.System' type=@[FlexibleNullability] kotlin.String? origin=null p0: CONST String type=kotlin.String value="abc" diff --git a/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.kt.txt b/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.kt.txt index 88071518ea0..5764056ce36 100644 --- a/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.kt.txt +++ b/compiler/testData/ir/irText/expressions/exclExclOnPlatformType.kt.txt @@ -5,4 +5,3 @@ fun test() { use(a = CHECK_NOT_NULL(arg0 = WeakReference<@FlexibleNullability String?>(p0 = "").get())) use(a = CHECK_NOT_NULL(arg0 = getProperty(p0 = "abc"))) } - diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/eqeqRhsConditionPossiblyAffectingLhs.ir.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/eqeqRhsConditionPossiblyAffectingLhs.ir.txt index 64e90c41880..a07a0dbf49b 100644 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/eqeqRhsConditionPossiblyAffectingLhs.ir.txt +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/eqeqRhsConditionPossiblyAffectingLhs.ir.txt @@ -9,7 +9,7 @@ FILE fqName: fileName:/eqeqRhsConditionPossiblyAffectingLhs.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=kotlin.Double GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null - then: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Nothing origin=EXCLEXCL + then: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Nothing origin=EXCLEXCL : kotlin.Nothing arg0: CONST Null type=kotlin.Nothing? value=null BRANCH diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt index e9ebc6b0a15..727674634f8 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt @@ -65,7 +65,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -78,7 +78,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -91,7 +91,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' type=kotlin.reflect.KFunction1, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -104,7 +104,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -117,7 +117,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=EXCLEXCL : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' type=kotlin.reflect.KFunction1, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -130,7 +130,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL : kotlin.Function1 arg0: GET_VAR 'function: kotlin.Function1 declared in .test3.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -143,7 +143,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3a' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL : kotlin.Function1 arg0: GET_VAR 'function: kotlin.Function1 declared in .test3a.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3a' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -156,7 +156,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3b' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1 origin=EXCLEXCL : kotlin.Function1 arg0: GET_VAR 'function: kotlin.Function1 declared in .test3b.KConsumer' type=kotlin.Function1 origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1): .KConsumer declared in .test3b' type=kotlin.reflect.KFunction1, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt index 0202f327678..8ac84e96b09 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.ir.txt @@ -65,7 +65,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=null : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test1.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -78,7 +78,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=null : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test1a.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -91,7 +91,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=null : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test1b.KRunnable' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KRunnable (function: kotlin.Function0): .KRunnable declared in .test1b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KRunnable> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -104,7 +104,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=null : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test2.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -117,7 +117,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' TYPE_OP type=.KSupplier origin=SAM_CONVERSION typeOperand=.KSupplier - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function0 origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0 origin=null : kotlin.Function0 arg0: GET_VAR 'function: kotlin.Function0 declared in .test2a.KSupplier' type=kotlin.Function0 origin=null FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0): .KSupplier declared in .test2a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function0, .KSupplier> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -130,7 +130,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null : kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> arg0: GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -143,7 +143,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3a' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null : kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> arg0: GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3a.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3a' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= @@ -156,7 +156,7 @@ FILE fqName: fileName:/funInterfaceConstructorReference.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3b' TYPE_OP type=.KConsumer origin=SAM_CONVERSION typeOperand=.KConsumer - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null : kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> arg0: GET_VAR 'function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> declared in .test3b.KConsumer' type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit> origin=null FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>): .KConsumer declared in .test3b' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'function')] kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String, kotlin.Unit>, .KConsumer> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt index 84888202536..d6f57efb122 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt @@ -95,4 +95,3 @@ fun test3b(): KFunction> { ::KConsumer } } - diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt.txt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt.txt index 5ef08532517..38c279849ad 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt.txt @@ -31,4 +31,3 @@ fun test5(x: T, fn: Function1) { EQEQ(arg0 = x, arg1 = null).not() -> fn.invoke(p1 = x) } } - diff --git a/compiler/testData/ir/irText/expressions/kt30020.fir.ir.txt b/compiler/testData/ir/irText/expressions/kt30020.fir.ir.txt index c640d01d237..781b351669b 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.fir.ir.txt @@ -48,7 +48,7 @@ FILE fqName: fileName:/kt30020.kt element: CONST Int type=kotlin.Int value=4 CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int - $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL + $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList arg0: BLOCK type=kotlin.collections.MutableList? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.X? [val] @@ -66,7 +66,7 @@ FILE fqName: fileName:/kt30020.kt element: CONST Int type=kotlin.Int value=5 CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int - $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL + $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList arg0: BLOCK type=kotlin.collections.MutableList? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.X? [val] diff --git a/compiler/testData/ir/irText/expressions/kt30020.ir.txt b/compiler/testData/ir/irText/expressions/kt30020.ir.txt index 7e7488dc1f5..50755ddf5c3 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.ir.txt @@ -51,7 +51,7 @@ FILE fqName: fileName:/kt30020.kt element: CONST Int type=kotlin.Int value=4 CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int - $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL + $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList arg0: BLOCK type=kotlin.collections.MutableList? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.X? [val] @@ -69,7 +69,7 @@ FILE fqName: fileName:/kt30020.kt element: CONST Int type=kotlin.Int value=5 CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int - $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL + $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList arg0: BLOCK type=kotlin.collections.MutableList? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.X? [val] diff --git a/compiler/testData/ir/irText/expressions/kt36963.ir.txt b/compiler/testData/ir/irText/expressions/kt36963.ir.txt index 334ffd0f603..4b6fae0fc59 100644 --- a/compiler/testData/ir/irText/expressions/kt36963.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt36963.ir.txt @@ -4,6 +4,6 @@ FILE fqName: fileName:/kt36963.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (): kotlin.reflect.KFunction0 declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.reflect.KFunction0 origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.reflect.KFunction0 origin=EXCLEXCL : kotlin.reflect.KFunction0 arg0: FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/kt44993.ir.txt b/compiler/testData/ir/irText/expressions/kt44993.ir.txt index 89a3e04fb70..641b36bb545 100644 --- a/compiler/testData/ir/irText/expressions/kt44993.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt44993.ir.txt @@ -3,7 +3,7 @@ FILE fqName: fileName:/kt44993.kt VALUE_PARAMETER name:r index:0 type:.KotlinBox<.JavaBox> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun f (r: .KotlinBox<.JavaBox>): kotlin.String declared in ' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL : kotlin.String arg0: BLOCK type=@[FlexibleNullability] kotlin.String? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.JavaBox? [val] diff --git a/compiler/testData/ir/irText/expressions/simpleUnaryOperators.kt.txt b/compiler/testData/ir/irText/expressions/simpleUnaryOperators.kt.txt index cc3c0593ddb..99e9507121e 100644 --- a/compiler/testData/ir/irText/expressions/simpleUnaryOperators.kt.txt +++ b/compiler/testData/ir/irText/expressions/simpleUnaryOperators.kt.txt @@ -21,4 +21,3 @@ fun test5(x: Boolean): Boolean { fun test6(): Boolean { return true.not() } - diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt index 00ba7fb422a..bda7ce0cd82 100644 --- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.ir.txt @@ -76,14 +76,14 @@ FILE fqName: fileName:/AbstractMutableMap.kt VALUE_PARAMETER name:p0 index:0 type:@[EnhancedNullability] java.util.function.BiFunction.MyMap, in @[EnhancedNullability] V of .MyMap, out @[EnhancedNullability] V of .MyMap> FUN FAKE_OVERRIDE name:merge visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, p0:@[EnhancedNullability] K of .MyMap, p1:@[EnhancedNullability] V of .MyMap, p2:@[EnhancedNullability] java.util.function.BiFunction.MyMap, in @[EnhancedNullability] V of .MyMap, out V of .MyMap?>) returnType:V of .MyMap? [fake_override] overridden: - public open fun merge (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] {@[EnhancedNullability] V of kotlin.collections.AbstractMutableMap & Any}, p2: @[EnhancedNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap + public open fun merge (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] {V of kotlin.collections.AbstractMutableMap & Any}, p2: @[EnhancedNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap VALUE_PARAMETER name:p0 index:0 type:@[EnhancedNullability] K of .MyMap VALUE_PARAMETER name:p1 index:1 type:@[EnhancedNullability] V of .MyMap VALUE_PARAMETER name:p2 index:2 type:@[EnhancedNullability] java.util.function.BiFunction.MyMap, in @[EnhancedNullability] V of .MyMap, out V of .MyMap?> FUN FAKE_OVERRIDE name:computeIfPresent visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, p0:@[EnhancedNullability] K of .MyMap, p1:@[EnhancedNullability] java.util.function.BiFunction.MyMap, in @[EnhancedNullability] V of .MyMap, out V of .MyMap?>) returnType:V of .MyMap? [fake_override] overridden: - public open fun computeIfPresent (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap + public open fun computeIfPresent (p0: @[EnhancedNullability] K of kotlin.collections.AbstractMutableMap, p1: @[EnhancedNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap VALUE_PARAMETER name:p0 index:0 type:@[EnhancedNullability] K of .MyMap VALUE_PARAMETER name:p1 index:1 type:@[EnhancedNullability] java.util.function.BiFunction.MyMap, in @[EnhancedNullability] V of .MyMap, out V of .MyMap?> diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.ir.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.ir.txt index ecff130ab23..eb887ce1fd5 100644 --- a/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.ir.txt @@ -96,7 +96,7 @@ FILE fqName: fileName:/AnnotationLoader.kt $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. BLOCK_BODY VAR name:visitor type:.Visitor [val] - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=.Visitor origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=.Visitor origin=EXCLEXCL : .Visitor arg0: CALL 'public final fun loadAnnotation (): .Visitor? declared in .AnnotationLoader' type=.Visitor? origin=null $this: GET_VAR ': .AnnotationLoader declared in .AnnotationLoader.loadAnnotation' type=.AnnotationLoader origin=null diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.ir.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.ir.txt index 54c94d1b018..37b7e4805e4 100644 --- a/compiler/testData/ir/irText/firProblems/AnnotationLoader.ir.txt +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.ir.txt @@ -96,7 +96,7 @@ FILE fqName: fileName:/AnnotationLoader.kt $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. BLOCK_BODY VAR name:visitor type:.Visitor [val] - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=.Visitor origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=.Visitor origin=EXCLEXCL : .Visitor arg0: CALL 'public final fun loadAnnotation (): .Visitor? declared in .AnnotationLoader' type=.Visitor? origin=null $this: GET_VAR ': .AnnotationLoader declared in .AnnotationLoader.loadAnnotation' type=.AnnotationLoader origin=null diff --git a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.ir.txt b/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.ir.txt index b015b9465e4..99a49b559dc 100644 --- a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.ir.txt +++ b/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.ir.txt @@ -61,7 +61,7 @@ FILE fqName: fileName:/functionLiteralGenericSignature.kt VALUE_PARAMETER name:l index:0 type:kotlin.collections.MutableList BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (l: kotlin.collections.MutableList): kotlin.collections.MutableList declared in .mutableListFun' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Nothing origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Nothing origin=EXCLEXCL : kotlin.Nothing arg0: CONST Null type=kotlin.Nothing? value=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.collections.MutableList> diff --git a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt index 3a8e58ed3e0..a6c19ce8fc2 100644 --- a/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt +++ b/compiler/testData/ir/irText/firProblems/lambdaInEnumEntryConstructorCall.kt.txt @@ -30,4 +30,3 @@ enum class ConfigurationParameter : Enum { fun valueOf(value: String): ConfigurationParameter /* Synthetic body for ENUM_VALUEOF */ } - diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt index b26f811287d..96b6b916daa 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt @@ -62,4 +62,3 @@ var fn: Function1 get set - diff --git a/compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt.txt b/compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt.txt index 0ba7d56ae4d..d1cd2937e7f 100644 --- a/compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt.txt +++ b/compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt.txt @@ -8,4 +8,3 @@ suspend fun box() { } ) } - diff --git a/compiler/testData/ir/irText/types/definitelyNonNull.kt.txt b/compiler/testData/ir/irText/types/definitelyNonNull.kt.txt index 3703830062f..1cc505bc050 100644 --- a/compiler/testData/ir/irText/types/definitelyNonNull.kt.txt +++ b/compiler/testData/ir/irText/types/definitelyNonNull.kt.txt @@ -14,4 +14,3 @@ fun main() { elvisLike(x = "", y = "").() /*~> Unit */ elvisLike(x = null, y = "").() /*~> Unit */ } - diff --git a/compiler/testData/ir/irText/types/definitelyNonNullSAM.ir.txt b/compiler/testData/ir/irText/types/definitelyNonNullSAM.ir.txt index 0d2e0ffe284..263ffbf687b 100644 --- a/compiler/testData/ir/irText/types/definitelyNonNullSAM.ir.txt +++ b/compiler/testData/ir/irText/types/definitelyNonNullSAM.ir.txt @@ -30,7 +30,7 @@ FILE fqName: fileName:/definitelyNonNullSAM.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun foo (): .FIn<{S of .Test & Any}> declared in .Test' TYPE_OP type=.FIn<{S of .Test & Any}> origin=SAM_CONVERSION typeOperand=.FIn<{S of .Test & Any}> - FUN_EXPR type=kotlin.Function1<@[ParameterName(name = 'x')] {@[ParameterName(name = 'x')] S of .Test & Any}, kotlin.Unit> origin=LAMBDA + FUN_EXPR type=kotlin.Function1<@[ParameterName(name = 'x')] {S of .Test & Any}, kotlin.Unit> origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (sx:{S of .Test & Any}) returnType:kotlin.Unit VALUE_PARAMETER name:sx index:0 type:{S of .Test & Any} BLOCK_BODY diff --git a/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt index a46e405d603..5f194a6a802 100644 --- a/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt +++ b/compiler/testData/ir/irText/types/definitelyNonNullWithJava.fir.ir.txt @@ -9,7 +9,7 @@ FILE fqName: fileName:/main.kt VALUE_PARAMETER name:x index:0 type:T1 of .B FUN name:bar visibility:public modality:ABSTRACT <> ($this:.B.B>, x:{T1 of .B & Any}) returnType:{T1 of .B & Any} overridden: - public abstract fun bar (x: @[EnhancedNullability] {@[EnhancedNullability] T of .A & Any}): @[EnhancedNullability] {@[EnhancedNullability] T of .A & Any} declared in .A + public abstract fun bar (x: @[EnhancedNullability] {T of .A & Any}): @[EnhancedNullability] {T of .A & Any} declared in .A $this: VALUE_PARAMETER name: type:.B.B> VALUE_PARAMETER name:x index:0 type:{T1 of .B & Any} FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt index 9dd064ae834..dab9011a038 100644 --- a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt +++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.ir.txt @@ -42,8 +42,8 @@ FILE fqName: fileName:/definitelyNotNullAsArgument.kt BLOCK_BODY CALL 'public abstract fun input (t: T of .I): kotlin.Unit declared in .I' type=kotlin.Unit origin=null $this: GET_VAR 'i: .I.qux & Any}> declared in .qux' type=.I.qux & Any}> origin=null - t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={T of .qux & Any} origin=EXCLEXCL - : T of .qux + t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type={T of .qux & Any} origin=EXCLEXCL + : {T of .qux & Any} arg0: GET_VAR 't: T of .qux declared in .qux' type=T of .qux origin=null CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I<{TT of .C & Any}>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C.C> @@ -76,8 +76,8 @@ FILE fqName: fileName:/definitelyNotNullAsArgument.kt $this: VALUE_PARAMETER name: type:.C.C> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun output (): {TT of .C & Any} declared in .C' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={TT of .C & Any} origin=EXCLEXCL - : TT of .C + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type={TT of .C & Any} origin=EXCLEXCL + : {TT of .C & Any} arg0: CALL 'public final fun (): TT of .C declared in .C' type=TT of .C origin=GET_PROPERTY $this: GET_VAR ': .C.C> declared in .C.output' type=.C.C> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] @@ -101,6 +101,6 @@ FILE fqName: fileName:/definitelyNotNullAsArgument.kt BLOCK_BODY CALL 'public abstract fun input (t: T of .I): kotlin.Unit declared in .I' type=kotlin.Unit origin=null $this: GET_VAR 'p2: T2 of .foo2 declared in .foo2' type=T2 of .foo2 origin=null - t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type={T1 of .foo2 & Any} origin=EXCLEXCL - : T1 of .foo2 + t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type={T1 of .foo2 & Any} origin=EXCLEXCL + : {T1 of .foo2 & Any} arg0: GET_VAR 'p1: T1 of .foo2 declared in .foo2' type=T1 of .foo2 origin=null diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt index 00844c322dc..9235a390412 100644 --- a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt +++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.fir.kt.txt @@ -13,7 +13,7 @@ fun bar(i: I): (T & Any) { } fun qux(t: T, i: I) { - i.input(t = CHECK_NOT_NULL(arg0 = t)) + i.input(t = CHECK_NOT_NULL<(T & Any)>(arg0 = t)) } class C : I<(TT & Any)> { @@ -31,12 +31,11 @@ class C : I<(TT & Any)> { } override fun output(): (TT & Any) { - return CHECK_NOT_NULL(arg0 = .()) + return CHECK_NOT_NULL<(TT & Any)>(arg0 = .()) } } fun > foo2(p1: T1, p2: T2) { - p2.input(t = CHECK_NOT_NULL(arg0 = p1)) + p2.input(t = CHECK_NOT_NULL<(T1 & Any)>(arg0 = p1)) } - diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.ir.txt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.ir.txt index f8a27db8be3..2907fa59282 100644 --- a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.ir.txt +++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.ir.txt @@ -42,7 +42,7 @@ FILE fqName: fileName:/definitelyNotNullAsArgument.kt BLOCK_BODY CALL 'public abstract fun input (t: T of .I): kotlin.Unit declared in .I' type=kotlin.Unit origin=null $this: GET_VAR 'i: .I.qux & Any}> declared in .qux' type=.I.qux & Any}> origin=null - t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=T of .qux origin=EXCLEXCL + t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=T of .qux origin=EXCLEXCL : T of .qux arg0: GET_VAR 't: T of .qux declared in .qux' type=T of .qux origin=null CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I<{TT of .C & Any}>] @@ -76,7 +76,7 @@ FILE fqName: fileName:/definitelyNotNullAsArgument.kt $this: VALUE_PARAMETER name: type:.C.C> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun output (): {TT of .C & Any} declared in .C' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=TT of .C origin=EXCLEXCL + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=TT of .C origin=EXCLEXCL : TT of .C arg0: CALL 'public final fun (): TT of .C declared in .C' type=TT of .C origin=GET_PROPERTY $this: GET_VAR ': .C.C> declared in .C.output' type=.C.C> origin=null @@ -102,6 +102,6 @@ FILE fqName: fileName:/definitelyNotNullAsArgument.kt CALL 'public abstract fun input (t: T of .I): kotlin.Unit declared in .I' type=kotlin.Unit origin=null $this: TYPE_OP type=.I<{T1 of .foo2 & Any}> origin=IMPLICIT_CAST typeOperand=.I<{T1 of .foo2 & Any}> GET_VAR 'p2: T2 of .foo2 declared in .foo2' type=T2 of .foo2 origin=null - t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=T1 of .foo2 origin=EXCLEXCL + t: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=T1 of .foo2 origin=EXCLEXCL : T1 of .foo2 arg0: GET_VAR 'p1: T1 of .foo2 declared in .foo2' type=T1 of .foo2 origin=null diff --git a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt.txt b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt.txt index 4f057ae8d8a..454b3b8691a 100644 --- a/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt.txt +++ b/compiler/testData/ir/irText/types/definitelyNotNullAsArgument.kt.txt @@ -39,4 +39,3 @@ class C : I<(TT & Any)> { fun > foo2(p1: T1, p2: T2) { p2 /*as I<(T1 & Any)> */.input(t = CHECK_NOT_NULL(arg0 = p1)) } - diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.kt.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.kt.txt index d5d25adc060..3a6460ede42 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.kt.txt @@ -34,4 +34,3 @@ fun testLocalVarUse() { val nns: String = notNullString() /*!! String */ use(s = nns) } - diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckInElvisRhs.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckInElvisRhs.kt.txt index cb2bd5e8af2..db7a7782a44 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckInElvisRhs.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckInElvisRhs.kt.txt @@ -15,4 +15,3 @@ fun test(): String { } } } - diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt index 01d0b451694..ea9d2180702 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt @@ -37,4 +37,3 @@ class Delegated : IFoo { fun testReturnValue(): String { return Delegated().foo() } - diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt index ddc74e513bc..0056e178b0e 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt @@ -8,4 +8,3 @@ fun testNullCheck() { } ) /*~> Unit */ } - diff --git a/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt.txt b/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt.txt index 87504ad3551..f7fad17869b 100644 --- a/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt.txt +++ b/compiler/testData/ir/irText/types/typeCheckOnDefinitelyNotNull.kt.txt @@ -12,4 +12,3 @@ inline fun implicitAsFoo(x: Any): Int { else -> x /*as (T & Any) */.() } } - diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt index c15774ab1d3..db6ffb0e00e 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.impl.* import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.SimpleTypeNullability import org.jetbrains.kotlin.ir.types.classOrNull import org.jetbrains.kotlin.ir.types.defaultType import org.jetbrains.kotlin.ir.types.impl.* @@ -289,7 +290,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory( val kotlinType = wrapped.unwrap() return with(IrSimpleTypeBuilder()) { classifier = symbolTable.referenceClassifier(kotlinType.constructor.declarationDescriptor ?: error("No classifier for type $kotlinType")) - hasQuestionMark = kotlinType.isMarkedNullable + nullability = SimpleTypeNullability.fromHasQuestionMark(kotlinType.isMarkedNullable) arguments = kotlinType.arguments.map { if (it.isStarProjection) IrStarProjectionImpl else makeTypeProjection(toIrType(it.type), it.projectionKind) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/InteropIrUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/InteropIrUtils.kt index 9c12c3a4544..2c568e57fb0 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/InteropIrUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/InteropIrUtils.kt @@ -23,9 +23,8 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name internal fun IrType.isCEnumType(): Boolean { - val simpleType = this as? IrSimpleType ?: return false - if (simpleType.hasQuestionMark) return false - val enumClass = simpleType.classifier.owner as? IrClass ?: return false + if (isNullable()) return false + val enumClass = classOrNull?.owner ?: return false if (!enumClass.isEnumClass) return false return enumClass.superTypes @@ -53,11 +52,10 @@ internal fun IrSimpleFunction.objCReturnsRetained() = hasCCallAnnotation("Return internal fun IrClass.getCStructSpelling(): String? = getAnnotationArgumentValue(FqName("kotlinx.cinterop.internal.CStruct"), "spelling") -internal fun IrType.isTypeOfNullLiteral(): Boolean = this is IrSimpleType && hasQuestionMark - && classifier.isClassWithFqName(StandardNames.FqNames.nothing) +internal fun IrType.isTypeOfNullLiteral(): Boolean = isNullableNothing() internal fun IrType.isVector(): Boolean { - if (this is IrSimpleType && !this.hasQuestionMark) { + if (this is IrSimpleType && !this.isNullable()) { return classifier.isClassWithFqName(KonanFqNames.Vector128.toUnsafe()) } return false diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index b77bcf7f17a..1dc1854208d 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -1515,8 +1515,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map { @@ -56,7 +56,7 @@ internal class DataClassOperatorsLowering(val context: Context) : FileLoweringPa // TODO: use more precise type arguments. val typeArguments = (0 until newCallee.typeParameters.size).map { irBuiltins.anyNType } - if (!argument.type.isSimpleTypeWithQuestionMark) { + if (!argument.type.isNullable()) { irCall(newCallee, typeArguments).apply { extensionReceiver = argument } diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt index cb96c680071..7e228c6fb83 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt @@ -1114,8 +1114,9 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi val receiverType = expression.symbol.owner.extensionReceiverParameter!!.type val source = receiverType.classifierOrFail as IrClassSymbol require(source in integerClasses) { renderCompilerError(expression) } - require(typeOperand is IrSimpleType && typeOperand.classifier in integerClasses - && !typeOperand.hasQuestionMark) { renderCompilerError(expression) } + require(typeOperand is IrSimpleType && !typeOperand.isNullable() && typeOperand.classifier in integerClasses) { + renderCompilerError(expression) + } val target = typeOperand.classifier as IrClassSymbol val valueToConvert = expression.extensionReceiver!! diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt index 30d0658e88c..c0f8b3dee77 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt @@ -71,7 +71,7 @@ internal class KTypeGenerator( return irKTypeImpl( kClassifier = kClassifier, irTypeArguments = type.arguments, - isMarkedNullable = type.hasQuestionMark, + isMarkedNullable = type.isMarkedNullable(), leaveReifiedForLater = leaveReifiedForLater, seenTypeParameters = seenTypeParameters, type = type, diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReturnsInsertionLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReturnsInsertionLowering.kt index 7dbfedef32c..a2bf9e884a4 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReturnsInsertionLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReturnsInsertionLowering.kt @@ -16,8 +16,8 @@ import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl +import org.jetbrains.kotlin.ir.types.isNullable import org.jetbrains.kotlin.ir.types.isNullableNothing -import org.jetbrains.kotlin.ir.util.isSimpleTypeWithQuestionMark import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptVoid @@ -39,7 +39,7 @@ internal class ReturnsInsertionLowering(val context: Context) : FileLoweringPass context.createIrBuilder(declaration.symbol, declaration.endOffset, declaration.endOffset).run { if (declaration is IrConstructor || declaration.returnType == context.irBuiltIns.unitType) { body.statements += irReturn(irGetObject(symbols.unit)) - } else if (declaration.returnType.isSimpleTypeWithQuestionMark) { + } else if (declaration.returnType.isNullable()) { // this is a workaround for KT-42832 val typeOperatorCall = body.statements.lastOrNull() as? IrTypeOperatorCall if (typeOperatorCall?.operator == IrTypeOperator.IMPLICIT_COERCION_TO_UNIT diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SamSuperTypesChecker.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SamSuperTypesChecker.kt index 720c7c3ea21..4727a8db6d6 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SamSuperTypesChecker.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SamSuperTypesChecker.kt @@ -34,7 +34,7 @@ internal class SamSuperTypesChecker(private val context: Context, if (this !is IrSimpleType) return this return buildSimpleType { this.classifier = this@eraseProjections.classifier - this.hasQuestionMark = this@eraseProjections.hasQuestionMark + this.nullability = this@eraseProjections.nullability this.annotations = this@eraseProjections.annotations this.arguments = this@eraseProjections.arguments.mapIndexed { index, argument -> if (argument !is IrTypeProjection) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt index 2717916bc05..191f8e50daa 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SpecialBackendChecksTraversal.kt @@ -452,7 +452,7 @@ private class BackendChecker(val context: Context, val irFile: IrFile) : IrEleme val typeOperand = expression.getTypeArgument(0)!! val receiverType = expression.symbol.owner.extensionReceiverParameter!!.type - if (typeOperand !is IrSimpleType || typeOperand.classifier !in integerClasses || typeOperand.hasQuestionMark) + if (typeOperand !is IrSimpleType || typeOperand.classifier !in integerClasses || typeOperand.isNullable()) reportError(expression, "unable to convert ${receiverType.toKotlinType()} to ${typeOperand.toKotlinType()}") } IntrinsicType.WORKER_EXECUTE -> { diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt index 8c6292c0e15..7ac8ccfbeb4 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid // TODO: Similar to IrType.erasedUpperBound from jvm.ir internal fun IrType.erasure(): IrType { - if (this is IrDefinitelyNotNullType) return this.original.erasure().makeNotNull() if (this !is IrSimpleType) return this val upperBound = when (val classifier = classifier) { @@ -40,10 +39,7 @@ internal fun IrType.erasure(): IrType { else -> TODO(classifier.toString()) } - return if (this.hasQuestionMark) - upperBound.makeNullable() - else - upperBound + return upperBound.mergeNullability(this) } internal val IrType.erasedUpperBound get() = this.erasure().getClass() ?: error(this.render()) @@ -72,7 +68,7 @@ internal class TypeOperatorLowering(val context: CommonBackendContext) : FileLow type = expression.type, condition = irEqeqeq(irGet(argument.owner), irNull()), - thenPart = if (typeOperand.isSimpleTypeWithQuestionMark) + thenPart = if (typeOperand.isNullable()) irNull() else irCall(this@TypeOperatorLowering.context.ir.symbols.throwNullPointerException.owner), @@ -83,7 +79,7 @@ internal class TypeOperatorLowering(val context: CommonBackendContext) : FileLow } } - typeOperand.isSimpleTypeWithQuestionMark -> builder.irAs(expression.argument, typeOperand.makeNotNull()) + typeOperand.isMarkedNullable() -> builder.irAs(expression.argument, typeOperand.makeNotNull()) typeOperand == expression.typeOperand -> expression diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt index 3991383fd05..a6070b4f872 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt @@ -192,9 +192,7 @@ fun IrType.substitute(map: Map): IrType { val classifier = this.classifier return when (classifier) { is IrTypeParameterSymbol -> - map[classifier]?.let { if (this.hasQuestionMark) it.makeNullable() else it } - ?: this - + map[classifier]?.mergeNullability(this) ?: this is IrClassSymbol -> if (this.arguments.isEmpty()) { this // Fast path. } else { @@ -205,7 +203,7 @@ fun IrType.substitute(map: Map): IrType { else -> error(it) } } - IrSimpleTypeImpl(classifier, hasQuestionMark, newArguments, annotations) + IrSimpleTypeImpl(classifier, nullability, newArguments, annotations) } else -> error(classifier) } @@ -368,9 +366,6 @@ fun IrValueParameter.copy(newDescriptor: ParameterDescriptor): IrValueParameter ) } -val IrType.isSimpleTypeWithQuestionMark: Boolean - get() = this is IrSimpleType && this.hasQuestionMark - fun IrClass.defaultOrNullableType(hasQuestionMark: Boolean) = if (hasQuestionMark) this.defaultType.makeNullable() else this.defaultType