Rework nullability in IR

This commit is contained in:
Pavel Kunyavskiy
2022-03-18 13:40:20 +03:00
committed by Space
parent 000165b12b
commit 7ba4d9e1f0
108 changed files with 1679 additions and 469 deletions
@@ -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(
@@ -335,7 +335,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(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 ->
@@ -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()))
}
}
)
@@ -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 {
@@ -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 <T : IrElement> IrStatementsBuilder<T>.createTmpVariable(
@@ -95,10 +95,7 @@ fun IrType.substitute(substitutionMap: Map<IrTypeParameterSymbol, IrType>): 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<IrTypeParameterSymbol, IrType>): IrTy
return IrSimpleTypeImpl(
classifier,
hasQuestionMark,
nullability,
newArguments,
newAnnotations
)
@@ -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 {
@@ -74,7 +74,7 @@ class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : FileLowe
endOffset,
IrSimpleTypeImpl(
context.ir.symbols.functionN(newN),
(type as IrSimpleType).hasQuestionMark,
(type as IrSimpleType).nullability,
arguments,
type.annotations
),
@@ -111,7 +111,7 @@ class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : FileLowe
endOffset,
IrSimpleTypeImpl(
(if (setter == null) getPropertyN(newN) else getMutablePropertyN(newN)),
(type as IrSimpleType).hasQuestionMark,
(type as IrSimpleType).nullability,
arguments,
type.annotations
),
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.symbols.IrScriptSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.ir.util.getInlineClassUnderlyingType
import org.jetbrains.kotlin.ir.util.isEffectivelyExternal
import org.jetbrains.kotlin.js.backend.ast.JsNameRef
import org.jetbrains.kotlin.types.Variance
@@ -26,7 +25,11 @@ fun IrType.asString(): String = when (this) {
is IrDynamicType -> "dynamic"
is IrSimpleType ->
classifier.asString() +
(if (hasQuestionMark) "?" else "") +
when (nullability) {
SimpleTypeNullability.MARKED_NULLABLE -> "?"
SimpleTypeNullability.NOT_SPECIFIED -> ""
SimpleTypeNullability.DEFINITELY_NOT_NULL -> if (classifier is IrTypeParameterSymbol) " & Any" else ""
} +
(arguments.ifNotEmpty {
joinToString(separator = ",", prefix = "<", postfix = ">") { it.asString() }
} ?: "")
@@ -34,11 +34,8 @@ private val IrTypeParameter.erasedUpperBound: IrClass?
val IrType.erasedUpperBound: IrClass?
get() =
if (this is IrDefinitelyNotNullType)
this.original.erasedUpperBound
else
when (val classifier = classifierOrNull) {
is IrClassSymbol -> classifier.owner
is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound
else -> throw IllegalStateException()
}
when (val classifier = classifierOrNull) {
is IrClassSymbol -> classifier.owner
is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound
else -> throw IllegalStateException()
}
@@ -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 =>
@@ -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
}
@@ -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()
}
@@ -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
@@ -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()}")
@@ -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<IrTypeParameter>): 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()}")
}
}
@@ -194,7 +194,11 @@ internal fun IrFunction.getArgsForMethodInvocation(
internal fun IrType.getOnlyName(): String {
if (this !is IrSimpleType) return this.render()
return (this.classifierOrFail.owner as IrDeclarationWithName).name.asString() + (if (this.hasQuestionMark) "?" else "")
return (this.classifierOrFail.owner as IrDeclarationWithName).name.asString() + when (nullability) {
SimpleTypeNullability.MARKED_NULLABLE -> "?"
SimpleTypeNullability.NOT_SPECIFIED -> ""
SimpleTypeNullability.DEFINITELY_NOT_NULL -> if (this.classifierOrNull is IrTypeParameterSymbol) " & Any" else ""
}
}
internal fun IrFieldAccessExpression.accessesTopLevelOrObjectField(): Boolean {
@@ -251,7 +255,7 @@ internal fun IrType.getTypeIfReified(getType: (IrClassifierSymbol) -> IrType): I
val owner = this.classifierOrNull?.owner
if (owner is IrTypeParameter && owner.isReified) {
return (getType(owner.symbol) as IrSimpleType)
.buildSimpleType { hasQuestionMark = this.hasQuestionMark || this@getTypeIfReified.hasQuestionMark }
.mergeNullability(this)
}
val newArguments = this.arguments.map {
@@ -261,7 +265,6 @@ internal fun IrType.getTypeIfReified(getType: (IrClassifierSymbol) -> IrType): I
type.getTypeIfReified(getType) as IrTypeArgument
}
return this.buildSimpleType {
hasQuestionMark = this.hasQuestionMark || this@getTypeIfReified.hasQuestionMark
arguments = newArguments
}
}
@@ -172,7 +172,7 @@ internal class Wrapper(val value: Any, override val irClass: IrClass, environmen
fun getStaticGetter(field: IrField): MethodHandle {
val jvmClass = field.parentAsClass.defaultType.getClass(true)
val returnType = field.type.let { it.getClass((it as IrSimpleType).hasQuestionMark) }
val returnType = field.type.let { it.getClass(it.isNullable()) }
return MethodHandles.lookup().findStaticGetter(jvmClass, field.name.asString(), returnType)
}
@@ -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()}")
}
@@ -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()
@@ -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)
@@ -52,11 +52,7 @@ class DeepCopyIrTreeWithSymbolsForFakeOverrides(typeArguments: Map<IrTypeParamet
return when (val substitutedType = typeArguments[type.classifier]) {
is IrDynamicType -> 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)
@@ -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<IrTypeArgument>
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 {
@@ -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
@@ -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")
@@ -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
@@ -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<IrConstructorCall>
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()
}
@@ -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<IrTypeArgument>
abstract override val annotations: List<IrConstructorCall>
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<IrTypeArgument>
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<IrTypeArgument>,
override val annotations: List<IrConstructorCall>,
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<IrTypeArgument>,
annotations: List<IrConstructorCall>,
abbreviation: IrTypeAbbreviation? = null
) : this(null, classifier, nullability, arguments, annotations, abbreviation)
constructor(
classifier: IrClassifierSymbol,
hasQuestionMark: Boolean,
arguments: List<IrTypeArgument>,
annotations: List<IrConstructorCall>,
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<IrTypeArgument> = emptyList()
var annotations: List<IrConstructorCall> = 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)
@@ -103,7 +103,7 @@ class IrCapturedType(
override val classifier: IrClassifierSymbol get() = error("Captured Type does not have a classifier")
override val arguments: List<IrTypeArgument> 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<IrConstructorCall> get() = emptyList()
override fun equals(other: Any?): Boolean {
@@ -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 <T : Enum<T>> IrType.getPrimitiveOrUnsignedType(byIdSignature: Map<IdSignatu
return byShortName[klass.name]
}
fun IrType.isMarkedNullable() = (this as? IrSimpleType)?.hasQuestionMark ?: false
fun IrType.isMarkedNullable() = (this as? IrSimpleType)?.nullability == SimpleTypeNullability.MARKED_NULLABLE
fun IrSimpleType.isMarkedNullable() = nullability == SimpleTypeNullability.MARKED_NULLABLE
fun IrType.isUnit() = isNotNullClassType(IdSignatureValues.unit)
@@ -152,8 +153,8 @@ fun IrType.isFloat(): Boolean = isNotNullClassType(IdSignatureValues._float)
fun IrType.isDouble(): Boolean = isNotNullClassType(IdSignatureValues._double)
fun IrType.isNumber(): Boolean = isNotNullClassType(IdSignatureValues.number)
fun IrType.isDoubleOrFloatWithoutNullability(): Boolean {
return isClassType(IdSignatureValues._double, hasQuestionMark = null) ||
isClassType(IdSignatureValues._float, hasQuestionMark = null)
return isClassType(IdSignatureValues._double, nullable = null) ||
isClassType(IdSignatureValues._float, nullable = null)
}
fun IrType.isComparable(): Boolean = isNotNullClassType(IdSignatureValues.comparable)
@@ -170,9 +171,9 @@ fun IrType.isLongArray(): Boolean = isNotNullClassType(primitiveArrayTypesSignat
fun IrType.isFloatArray(): Boolean = isNotNullClassType(primitiveArrayTypesSignatures[PrimitiveType.FLOAT]!!)
fun IrType.isDoubleArray(): Boolean = isNotNullClassType(primitiveArrayTypesSignatures[PrimitiveType.DOUBLE]!!)
fun IrType.isClassType(fqName: FqNameUnsafe, hasQuestionMark: Boolean): Boolean {
fun IrType.isClassType(fqName: FqNameUnsafe, nullable: Boolean): Boolean {
if (this !is IrSimpleType) return false
if (this.hasQuestionMark != hasQuestionMark) return false
if (this.isMarkedNullable() != nullable) return false
return classifier.isClassWithFqName(fqName)
}
@@ -20,27 +20,29 @@ import org.jetbrains.kotlin.ir.types.impl.*
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
fun IrType.withHasQuestionMark(newHasQuestionMark: Boolean): IrType =
private fun IrType.withNullability(newNullability: Boolean): IrType =
when (this) {
is IrSimpleType -> 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<IrConstructorCall>): 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<IrType>): IrSimpleType =
IrSimpleTypeImpl(
this,
false,
SimpleTypeNullability.NOT_SPECIFIED,
arguments.map { makeTypeProjection(it, Variance.INVARIANT) },
emptyList()
)
fun IrClassifierSymbol.typeWithArguments(arguments: List<IrTypeArgument>): IrSimpleType =
IrSimpleTypeImpl(this, false, arguments, emptyList())
IrSimpleTypeImpl(this, SimpleTypeNullability.NOT_SPECIFIED, arguments, emptyList())
fun IrClass.typeWith(arguments: List<IrType>) = this.symbol.typeWith(arguments)
@@ -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()
@@ -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()
@@ -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 {
@@ -33,7 +33,7 @@ class SimpleTypeRemapper(
IrSimpleTypeImpl(
null,
symbol,
type.hasQuestionMark,
type.nullability,
arguments,
type.annotations,
type.abbreviation?.remapTypeAbbreviation()
@@ -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()
@@ -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")
@@ -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;
}
}
@@ -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<IrClassifierSymbol>(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<IrClassifierSymbol>(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}")
@@ -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<IrTypeArgumentKey>?,
val annotations: List<IrConstructorCall>,
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
@@ -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")
}
@@ -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_;
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
public boolean hasHasQuestionMark() {
public boolean hasNullability() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
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;
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
public boolean hasHasQuestionMark() {
public boolean hasNullability() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
public boolean getHasQuestionMark() {
return hasQuestionMark_;
public org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability getNullability() {
return nullability_;
}
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
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;
}
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
public Builder clearHasQuestionMark() {
public Builder clearNullability() {
bitField0_ = (bitField0_ & ~0x00000004);
hasQuestionMark_ = false;
nullability_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability.NOT_SPECIFIED;
return this;
}
@@ -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<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall>();
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<java.lang.Long>();
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<java.lang.Long>();
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<IrSimpleTypeLegacy> PARSER =
new org.jetbrains.kotlin.protobuf.AbstractParser<IrSimpleTypeLegacy>() {
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<IrSimpleTypeLegacy> getParserForType() {
return PARSER;
}
private int bitField0_;
public static final int ANNOTATION_FIELD_NUMBER = 1;
private java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall> annotation_;
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall> getAnnotationList() {
return annotation_;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public java.util.List<? extends org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCallOrBuilder>
getAnnotationOrBuilderList() {
return annotation_;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public int getAnnotationCount() {
return annotation_.size();
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall getAnnotation(int index) {
return annotation_.get(index);
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
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_;
/**
* <code>required int64 classifier = 2;</code>
*/
public boolean hasClassifier() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int64 classifier = 2;</code>
*/
public long getClassifier() {
return classifier_;
}
public static final int HAS_QUESTION_MARK_FIELD_NUMBER = 3;
private boolean hasQuestionMark_;
/**
* <code>required bool has_question_mark = 3;</code>
*/
public boolean hasHasQuestionMark() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required bool has_question_mark = 3;</code>
*/
public boolean getHasQuestionMark() {
return hasQuestionMark_;
}
public static final int ARGUMENT_FIELD_NUMBER = 4;
private java.util.List<java.lang.Long> argument_;
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public java.util.List<java.lang.Long>
getArgumentList() {
return argument_;
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public int getArgumentCount() {
return argument_.size();
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
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_;
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
public boolean hasAbbreviation() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
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<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall> annotation_ =
java.util.Collections.emptyList();
private void ensureAnnotationIsMutable() {
if (!((bitField0_ & 0x00000001) == 0x00000001)) {
annotation_ = new java.util.ArrayList<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall>(annotation_);
bitField0_ |= 0x00000001;
}
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall> getAnnotationList() {
return java.util.Collections.unmodifiableList(annotation_);
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public int getAnnotationCount() {
return annotation_.size();
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall getAnnotation(int index) {
return annotation_.get(index);
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
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;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder setAnnotation(
int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.Builder builderForValue) {
ensureAnnotationIsMutable();
annotation_.set(index, builderForValue.build());
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder addAnnotation(org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall value) {
if (value == null) {
throw new NullPointerException();
}
ensureAnnotationIsMutable();
annotation_.add(value);
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
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;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder addAnnotation(
org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.Builder builderForValue) {
ensureAnnotationIsMutable();
annotation_.add(builderForValue.build());
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder addAnnotation(
int index, org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall.Builder builderForValue) {
ensureAnnotationIsMutable();
annotation_.add(index, builderForValue.build());
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder addAllAnnotation(
java.lang.Iterable<? extends org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall> values) {
ensureAnnotationIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, annotation_);
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder clearAnnotation() {
annotation_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
public Builder removeAnnotation(int index) {
ensureAnnotationIsMutable();
annotation_.remove(index);
return this;
}
private long classifier_ ;
/**
* <code>required int64 classifier = 2;</code>
*/
public boolean hasClassifier() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required int64 classifier = 2;</code>
*/
public long getClassifier() {
return classifier_;
}
/**
* <code>required int64 classifier = 2;</code>
*/
public Builder setClassifier(long value) {
bitField0_ |= 0x00000002;
classifier_ = value;
return this;
}
/**
* <code>required int64 classifier = 2;</code>
*/
public Builder clearClassifier() {
bitField0_ = (bitField0_ & ~0x00000002);
classifier_ = 0L;
return this;
}
private boolean hasQuestionMark_ ;
/**
* <code>required bool has_question_mark = 3;</code>
*/
public boolean hasHasQuestionMark() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>required bool has_question_mark = 3;</code>
*/
public boolean getHasQuestionMark() {
return hasQuestionMark_;
}
/**
* <code>required bool has_question_mark = 3;</code>
*/
public Builder setHasQuestionMark(boolean value) {
bitField0_ |= 0x00000004;
hasQuestionMark_ = value;
return this;
}
/**
* <code>required bool has_question_mark = 3;</code>
*/
public Builder clearHasQuestionMark() {
bitField0_ = (bitField0_ & ~0x00000004);
hasQuestionMark_ = false;
return this;
}
private java.util.List<java.lang.Long> argument_ = java.util.Collections.emptyList();
private void ensureArgumentIsMutable() {
if (!((bitField0_ & 0x00000008) == 0x00000008)) {
argument_ = new java.util.ArrayList<java.lang.Long>(argument_);
bitField0_ |= 0x00000008;
}
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public java.util.List<java.lang.Long>
getArgumentList() {
return java.util.Collections.unmodifiableList(argument_);
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public int getArgumentCount() {
return argument_.size();
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public long getArgument(int index) {
return argument_.get(index);
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public Builder setArgument(
int index, long value) {
ensureArgumentIsMutable();
argument_.set(index, value);
return this;
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public Builder addArgument(long value) {
ensureArgumentIsMutable();
argument_.add(value);
return this;
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
public Builder addAllArgument(
java.lang.Iterable<? extends java.lang.Long> values) {
ensureArgumentIsMutable();
org.jetbrains.kotlin.protobuf.AbstractMessageLite.Builder.addAll(
values, argument_);
return this;
}
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
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();
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
public boolean hasAbbreviation() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
public org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation getAbbreviation() {
return abbreviation_;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
public Builder setAbbreviation(org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation value) {
if (value == null) {
throw new NullPointerException();
}
abbreviation_ = value;
bitField0_ |= 0x00000010;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
public Builder setAbbreviation(
org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation.Builder builderForValue) {
abbreviation_ = builderForValue.build();
bitField0_ |= 0x00000010;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
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;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
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)
}
@@ -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 {
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
java.util.List<org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall>
getAnnotationList();
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall getAnnotation(int index);
/**
* <code>repeated .org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall annotation = 1;</code>
*/
int getAnnotationCount();
/**
* <code>required int64 classifier = 2;</code>
*/
boolean hasClassifier();
/**
* <code>required int64 classifier = 2;</code>
*/
long getClassifier();
/**
* <code>required bool has_question_mark = 3;</code>
*/
boolean hasHasQuestionMark();
/**
* <code>required bool has_question_mark = 3;</code>
*/
boolean getHasQuestionMark();
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
java.util.List<java.lang.Long> getArgumentList();
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
int getArgumentCount();
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
*
* <pre>
* 0 - STAR, otherwise [63..2 - IrType index | 1..0 - Variance]
* </pre>
*/
long getArgument(int index);
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
boolean hasAbbreviation();
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation abbreviation = 5;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation getAbbreviation();
}
@@ -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 {
/**
* <code>MARKED_NULLABLE = 0;</code>
*/
MARKED_NULLABLE(0, 0),
/**
* <code>NOT_SPECIFIED = 1;</code>
*/
NOT_SPECIFIED(1, 1),
/**
* <code>DEFINITELY_NOT_NULL = 2;</code>
*/
DEFINITELY_NOT_NULL(2, 2),
;
/**
* <code>MARKED_NULLABLE = 0;</code>
*/
public static final int MARKED_NULLABLE_VALUE = 0;
/**
* <code>NOT_SPECIFIED = 1;</code>
*/
public static final int NOT_SPECIFIED_VALUE = 1;
/**
* <code>DEFINITELY_NOT_NULL = 2;</code>
*/
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<IrSimpleTypeNullability>
internalGetValueMap() {
return internalValueMap;
}
private static org.jetbrains.kotlin.protobuf.Internal.EnumLiteMap<IrSimpleTypeNullability>
internalValueMap =
new org.jetbrains.kotlin.protobuf.Internal.EnumLiteMap<IrSimpleTypeNullability>() {
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)
}
@@ -31,13 +31,13 @@ public interface IrSimpleTypeOrBuilder extends
long getClassifier();
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
boolean hasHasQuestionMark();
boolean hasNullability();
/**
* <code>required bool has_question_mark = 3;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability nullability = 3 [default = NOT_SPECIFIED];</code>
*/
boolean getHasQuestionMark();
org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeNullability getNullability();
/**
* <code>repeated int64 argument = 4 [packed = true];</code>
@@ -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;
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
public boolean hasSimple() {
public boolean hasLegacySimple() {
return kindCase_ == 1;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
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;
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
public boolean hasSimple() {
return kindCase_ == 5;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
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_;
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
public boolean hasSimple() {
public boolean hasLegacySimple() {
return kindCase_ == 1;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
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();
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
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;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
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;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
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;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
public Builder clearSimple() {
public Builder clearLegacySimple() {
if (kindCase_ == 1) {
kindCase_ = 0;
kind_ = null;
@@ -787,6 +845,70 @@ public final class IrType extends
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
public boolean hasSimple() {
return kindCase_ == 5;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
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();
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
public Builder setSimple(org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType value) {
if (value == null) {
throw new NullPointerException();
}
kind_ = value;
kindCase_ = 5;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
public Builder setSimple(
org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType.Builder builderForValue) {
kind_ = builderForValue.build();
kindCase_ = 5;
return this;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
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;
}
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
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)
}
@@ -8,13 +8,13 @@ public interface IrTypeOrBuilder extends
org.jetbrains.kotlin.protobuf.MessageLiteOrBuilder {
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
boolean hasSimple();
boolean hasLegacySimple();
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 1;</code>
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy legacySimple = 1;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple();
org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleTypeLegacy getLegacySimple();
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicType dynamic = 2;</code>
@@ -42,4 +42,13 @@ public interface IrTypeOrBuilder extends
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType dnn = 4;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrDefinitelyNotNullType getDnn();
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
boolean hasSimple();
/**
* <code>optional .org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType simple = 5;</code>
*/
org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType getSimple();
}