[IR] Prevent infinite recursion when rendering bound symbol references

Refactor the renderer, make BoundSymbolReferenceRenderer a static class
to prevent calling RenderIrElementVisitor's methods from it to avoid
infinite recursion in the future.

^KT-52677 Fixed
This commit is contained in:
Sergej Jaskiewicz
2022-11-09 19:05:56 +01:00
committed by Space Team
parent 9fcd185141
commit aa1b18b0c8
20 changed files with 992 additions and 278 deletions
@@ -28037,6 +28037,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
@@ -498,6 +498,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/declarations/kt47527.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@Test
@TestMetadata("localClassWithOverrides.kt")
public void testLocalClassWithOverrides() throws Exception {
@@ -498,6 +498,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex
runTest("compiler/testData/ir/irText/declarations/kt47527.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@Test
@TestMetadata("localClassWithOverrides.kt")
public void testLocalClassWithOverrides() throws Exception {
@@ -21,178 +21,69 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
fun IrElement.render() =
accept(RenderIrElementVisitor(), null)
class RenderIrElementVisitor(private val normalizeNames: Boolean = false, private val verboseErrorTypes: Boolean = true) : IrElementVisitor<String, Nothing?> {
private val nameMap: MutableMap<IrVariableSymbol, String> = mutableMapOf()
private var temporaryIndex: Int = 0
class RenderIrElementVisitor(normalizeNames: Boolean = false, private val verboseErrorTypes: Boolean = true) :
IrElementVisitor<String, Nothing?> {
private val IrVariable.normalizedName: String
get() {
if (!normalizeNames || (origin != IrDeclarationOrigin.IR_TEMPORARY_VARIABLE && origin != IrDeclarationOrigin.FOR_LOOP_ITERATOR))
return name.asString()
private val variableNameData = VariableNameData(normalizeNames)
return nameMap.getOrPut(symbol) { "tmp_${temporaryIndex++}" }
}
fun renderType(type: IrType) = type.render()
fun renderType(type: IrType) = type.renderTypeWithRenderer(this@RenderIrElementVisitor, verboseErrorTypes)
fun renderSymbolReference(symbol: IrSymbol) = symbol.renderReference()
fun renderAsAnnotation(irAnnotation: IrConstructorCall): String =
StringBuilder().also { it.renderAsAnnotation(irAnnotation) }.toString()
private fun StringBuilder.renderAsAnnotation(irAnnotation: IrConstructorCall) {
val annotationClassName = try {
irAnnotation.symbol.owner.parentAsClass.name.asString()
} catch (e: Exception) {
"<unbound>"
}
append(annotationClassName)
if (irAnnotation.typeArgumentsCount != 0) {
(0 until irAnnotation.typeArgumentsCount).joinTo(this, ", ", "<", ">") { i ->
irAnnotation.getTypeArgument(i)?.let { renderType(it) } ?: "null"
}
}
if (irAnnotation.valueArgumentsCount == 0) return
val valueParameterNames = irAnnotation.getValueParameterNamesForDebug()
var first = true
append("(")
for (i in 0 until irAnnotation.valueArgumentsCount) {
if (first) {
first = false
} else {
append(", ")
}
append(valueParameterNames[i])
append(" = ")
renderAsAnnotationArgument(irAnnotation.getValueArgument(i))
}
append(")")
}
private fun StringBuilder.renderAsAnnotationArgument(irElement: IrElement?) {
when (irElement) {
null -> append("<null>")
is IrConstructorCall -> renderAsAnnotation(irElement)
is IrConst<*> -> {
append('\'')
append(irElement.value.toString())
append('\'')
}
is IrVararg -> {
appendListWith(irElement.elements, "[", "]", ", ") {
renderAsAnnotationArgument(it)
}
}
else -> append(irElement.accept(this@RenderIrElementVisitor, null))
}
}
private inline fun buildTrimEnd(fn: StringBuilder.() -> Unit): String =
buildString(fn).trimEnd()
private inline fun <T> T.runTrimEnd(fn: T.() -> String): String =
run(fn).trimEnd()
StringBuilder().also { it.renderAsAnnotation(irAnnotation, this, verboseErrorTypes) }.toString()
private fun IrType.render(): String =
"${renderTypeAnnotations(annotations)}${renderTypeInner()}"
private fun IrType.renderTypeInner() =
when (this) {
is IrDynamicType -> "dynamic"
is IrErrorType -> "IrErrorType(${if (verboseErrorTypes) originalKotlinType else null})"
is IrSimpleType -> buildTrimEnd {
val isDefinitelyNotNullType = classifier is IrTypeParameterSymbol && nullability == SimpleTypeNullability.DEFINITELY_NOT_NULL
if (isDefinitelyNotNullType) append("{")
append(classifier.renderClassifierFqn())
if (arguments.isNotEmpty()) {
append(
arguments.joinToString(prefix = "<", postfix = ">", separator = ", ") {
it.renderTypeArgument()
}
)
}
if (isDefinitelyNotNullType) {
append(" & Any}")
} else if (isMarkedNullable()) {
append('?')
}
abbreviation?.let {
append(it.renderTypeAbbreviation())
}
}
else -> "{${javaClass.simpleName} $this}"
}
private fun IrTypeAbbreviation.renderTypeAbbreviation(): String =
buildString {
append("{ ")
append(renderTypeAnnotations(annotations))
append(typeAlias.renderTypeAliasFqn())
if (arguments.isNotEmpty()) {
append(
arguments.joinToString(prefix = "<", postfix = ">", separator = ", ") {
it.renderTypeArgument()
}
)
}
if (hasQuestionMark) {
append('?')
}
append(" }")
}
private fun IrTypeArgument.renderTypeArgument(): String =
when (this) {
is IrStarProjection -> "*"
is IrTypeProjection -> buildTrimEnd {
append(variance.label)
if (variance != Variance.INVARIANT) append(' ')
append(type.render())
}
else -> "IrTypeArgument[$this]"
}
private fun renderTypeAnnotations(annotations: List<IrConstructorCall>) =
if (annotations.isEmpty())
""
else
annotations.joinToString(prefix = "", postfix = " ", separator = " ") { "@[${renderAsAnnotation(it)}]" }
this.renderTypeWithRenderer(this@RenderIrElementVisitor, verboseErrorTypes)
private fun IrSymbol.renderReference() =
if (isBound)
owner.accept(symbolReferenceRenderer, null)
owner.accept(BoundSymbolReferenceRenderer(variableNameData, verboseErrorTypes), null)
else
"UNBOUND ${javaClass.simpleName}"
private val symbolReferenceRenderer = BoundSymbolReferenceRenderer()
private class BoundSymbolReferenceRenderer(
private val variableNameData: VariableNameData,
private val verboseErrorTypes: Boolean,
) : IrElementVisitor<String, Nothing?> {
private inner class BoundSymbolReferenceRenderer :
IrElementVisitor<String, Nothing?> {
override fun visitElement(element: IrElement, data: Nothing?) = buildTrimEnd {
append('{')
append(element.javaClass.simpleName)
append('}')
if (element is IrDeclaration) {
if (element is IrDeclarationWithName) {
append(element.name)
append(' ')
}
renderDeclaredIn(element)
}
}
override fun visitElement(element: IrElement, data: Nothing?) =
element.accept(this@RenderIrElementVisitor, null)
override fun visitTypeParameter(declaration: IrTypeParameter, data: Nothing?): String =
renderTypeParameter(declaration, null, verboseErrorTypes)
override fun visitClass(declaration: IrClass, data: Nothing?) =
renderClassWithRenderer(declaration, null, verboseErrorTypes)
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?) =
renderEnumEntry(declaration)
override fun visitField(declaration: IrField, data: Nothing?) =
renderField(declaration, null, verboseErrorTypes)
override fun visitVariable(declaration: IrVariable, data: Nothing?) =
buildTrimEnd {
if (declaration.isVar) append("var ") else append("val ")
append(declaration.normalizedName)
append(declaration.normalizedName(variableNameData))
append(": ")
append(declaration.type.render())
append(declaration.type.renderTypeWithRenderer(null, verboseErrorTypes))
append(' ')
append(declaration.renderVariableFlags())
@@ -204,7 +95,7 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
buildTrimEnd {
append(declaration.name.asString())
append(": ")
append(declaration.type.render())
append(declaration.type.renderTypeWithRenderer(null, verboseErrorTypes))
append(' ')
append(declaration.renderValueParameterFlags())
@@ -233,23 +124,23 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
renderTypeParameters(declaration)
appendListWith(declaration.valueParameters, "(", ")", ", ") { valueParameter ->
appendIterableWith(declaration.valueParameters, "(", ")", ", ") { valueParameter ->
val varargElementType = valueParameter.varargElementType
if (varargElementType != null) {
append("vararg ")
append(valueParameter.name.asString())
append(": ")
append(varargElementType.render())
append(varargElementType.renderTypeWithRenderer(null, verboseErrorTypes))
} else {
append(valueParameter.name.asString())
append(": ")
append(valueParameter.type.render())
append(valueParameter.type.renderTypeWithRenderer(null, verboseErrorTypes))
}
}
if (declaration is IrSimpleFunction) {
append(": ")
append(declaration.renderReturnType())
append(declaration.renderReturnType(null, verboseErrorTypes))
}
append(' ')
@@ -263,7 +154,7 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
private fun StringBuilder.renderTypeParameters(declaration: IrTypeParametersContainer) {
if (declaration.typeParameters.isNotEmpty()) {
appendListWith(declaration.typeParameters, "<", ">", ", ") { typeParameter ->
appendIterableWith(declaration.typeParameters, "<", ">", ", ") { typeParameter ->
append(typeParameter.name.asString())
}
append(' ')
@@ -282,10 +173,10 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
val getter = declaration.getter
if (getter != null) {
append(": ")
append(getter.renderReturnType())
append(getter.renderReturnType(null, verboseErrorTypes))
} else declaration.backingField?.type?.let { type ->
append(": ")
append(type.render())
append(type.renderTypeWithRenderer(null, verboseErrorTypes))
}
append(' ')
@@ -297,7 +188,7 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
if (declaration.isVar) append("var ") else append("val ")
append(declaration.name.asString())
append(": ")
append(declaration.type.render())
append(declaration.type.renderTypeWithRenderer(null, verboseErrorTypes))
append(" by (...)")
}
@@ -316,7 +207,7 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
when (parent) {
is IrPackageFragment -> {
val fqn = parent.fqName.asString()
append(if (fqn.isEmpty()) "<root>" else fqn)
append(fqn.ifEmpty { "<root>" })
}
is IrDeclaration -> {
renderParentOfReferencedDeclaration(parent)
@@ -367,43 +258,10 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
"name:$name visibility:$visibility modality:$modality " +
renderTypeParameters() + " " +
renderValueParameterTypes() + " " +
"returnType:${renderReturnType()} " +
"returnType:${renderReturnType(this@RenderIrElementVisitor, verboseErrorTypes)} " +
renderSimpleFunctionFlags()
}
private fun IrFunction.renderReturnType(): String =
safeReturnType?.render() ?: "<Uninitialized>"
private val IrFunction.safeReturnType: IrType?
get() = try {
returnType
} catch (e: ReturnTypeIsNotInitializedException) {
null
}
private fun renderFlagsList(vararg flags: String?) =
flags.filterNotNull().run {
if (isNotEmpty())
joinToString(prefix = "[", postfix = "] ", separator = ",")
else
""
}
private fun IrSimpleFunction.renderSimpleFunctionFlags(): String =
renderFlagsList(
"tailrec".takeIf { isTailrec },
"inline".takeIf { isInline },
"external".takeIf { isExternal },
"suspend".takeIf { isSuspend },
"expect".takeIf { isExpect },
"fake_override".takeIf { isFakeOverride },
"operator".takeIf { isOperator },
"infix".takeIf { isInfix }
)
private fun IrFunction.renderTypeParameters(): String =
typeParameters.joinToString(separator = ", ", prefix = "<", postfix = ">") { it.name.toString() }
private fun IrFunction.renderValueParameterTypes(): String =
ArrayList<String>().apply {
addIfNotNull(dispatchReceiverParameter?.run { "\$this:${type.render()}" })
@@ -417,18 +275,10 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
"visibility:$visibility " +
renderTypeParameters() + " " +
renderValueParameterTypes() + " " +
"returnType:${renderReturnType()} " +
"returnType:${renderReturnType(this@RenderIrElementVisitor, verboseErrorTypes)} " +
renderConstructorFlags()
}
private fun IrConstructor.renderConstructorFlags() =
renderFlagsList(
"inline".takeIf { isInline },
"external".takeIf { isExternal },
"primary".takeIf { isPrimary },
"expect".takeIf { isExpect }
)
override fun visitProperty(declaration: IrProperty, data: Nothing?): String =
declaration.runTrimEnd {
"PROPERTY ${renderOriginIfNonTrivial()}" +
@@ -436,78 +286,25 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
renderPropertyFlags()
}
private fun IrProperty.renderPropertyFlags() =
renderFlagsList(
"external".takeIf { isExternal },
"const".takeIf { isConst },
"lateinit".takeIf { isLateinit },
"delegated".takeIf { isDelegated },
"expect".takeIf { isExpect },
"fake_override".takeIf { isFakeOverride },
if (isVar) "var" else "val"
)
override fun visitField(declaration: IrField, data: Nothing?): String =
declaration.runTrimEnd {
"FIELD ${renderOriginIfNonTrivial()}name:$name type:${type.render()} visibility:$visibility ${renderFieldFlags()}"
}
private fun IrField.renderFieldFlags() =
renderFlagsList(
"final".takeIf { isFinal },
"external".takeIf { isExternal },
"static".takeIf { isStatic },
)
renderField(declaration, this, verboseErrorTypes)
override fun visitClass(declaration: IrClass, data: Nothing?): String =
declaration.runTrimEnd {
"CLASS ${renderOriginIfNonTrivial()}" +
"$kind name:$name modality:$modality visibility:$visibility " +
renderClassFlags() +
"superTypes:[${superTypes.joinToString(separator = "; ") { it.render() }}]"
}
private fun IrClass.renderClassFlags() =
renderFlagsList(
"companion".takeIf { isCompanion },
"inner".takeIf { isInner },
"data".takeIf { isData },
"external".takeIf { isExternal },
"value".takeIf { isValue },
"expect".takeIf { isExpect },
"fun".takeIf { isFun }
)
renderClassWithRenderer(declaration, this, verboseErrorTypes)
override fun visitVariable(declaration: IrVariable, data: Nothing?): String =
declaration.runTrimEnd {
"VAR ${renderOriginIfNonTrivial()}name:$normalizedName type:${type.render()} ${renderVariableFlags()}"
"VAR ${renderOriginIfNonTrivial()}name:${normalizedName(variableNameData)} type:${type.render()} ${renderVariableFlags()}"
}
private fun IrVariable.renderVariableFlags(): String =
renderFlagsList(
"const".takeIf { isConst },
"lateinit".takeIf { isLateinit },
if (isVar) "var" else "val"
)
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?): String =
declaration.runTrimEnd {
"ENUM_ENTRY ${renderOriginIfNonTrivial()}name:$name"
}
renderEnumEntry(declaration)
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?): String =
"ANONYMOUS_INITIALIZER isStatic=${declaration.isStatic}"
override fun visitTypeParameter(declaration: IrTypeParameter, data: Nothing?): String =
declaration.runTrimEnd {
"TYPE_PARAMETER ${renderOriginIfNonTrivial()}" +
"name:$name index:$index variance:$variance " +
"superTypes:[${superTypes.joinToString(separator = "; ") { it.render() }}] " +
"reified:$isReified"
}
renderTypeParameter(declaration, this, verboseErrorTypes)
override fun visitValueParameter(declaration: IrValueParameter, data: Nothing?): String =
declaration.runTrimEnd {
@@ -519,14 +316,6 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
renderValueParameterFlags()
}
private fun IrValueParameter.renderValueParameterFlags(): String =
renderFlagsList(
"vararg".takeIf { varargElementType != null },
"crossinline".takeIf { isCrossinline },
"noinline".takeIf { isNoinline },
"assignable".takeIf { isAssignable }
)
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty, data: Nothing?): String =
declaration.runTrimEnd {
"LOCAL_DELEGATED_PROPERTY ${declaration.renderOriginIfNonTrivial()}" +
@@ -540,14 +329,6 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false, privat
renderTypeAliasFlags()
}
private fun IrTypeAlias.renderTypeAliasFlags(): String =
renderFlagsList(
"actual".takeIf { isActual }
)
private fun IrLocalDelegatedProperty.renderLocalDelegatedPropertyFlags() =
if (isVar) "var" else "val"
override fun visitExpressionBody(body: IrExpressionBody, data: Nothing?): String =
"EXPRESSION_BODY"
@@ -804,7 +585,7 @@ private fun IrDeclaration.renderDeclarationParentFqn(sb: StringBuilder) {
}
}
fun IrType.render() = RenderIrElementVisitor().renderType(this)
fun IrType.render() = renderTypeWithRenderer(RenderIrElementVisitor(), true)
fun IrSimpleType.render() = (this as IrType).render()
@@ -815,19 +596,289 @@ fun IrTypeArgument.render() =
else -> throw AssertionError("Unexpected IrTypeArgument: $this")
}
internal inline fun <T> StringBuilder.appendListWith(
list: List<T>,
internal inline fun <T, Buffer : Appendable> Buffer.appendIterableWith(
iterable: Iterable<T>,
prefix: String,
postfix: String,
separator: String,
renderItem: StringBuilder.(T) -> Unit
renderItem: Buffer.(T) -> Unit
) {
append(prefix)
var isFirst = true
for (item in list) {
for (item in iterable) {
if (!isFirst) append(separator)
renderItem(item)
isFirst = false
}
append(postfix)
}
private inline fun buildTrimEnd(fn: StringBuilder.() -> Unit): String =
buildString(fn).trimEnd()
private inline fun <T> T.runTrimEnd(fn: T.() -> String): String =
run(fn).trimEnd()
private fun renderFlagsList(vararg flags: String?) =
flags.filterNotNull().run {
if (isNotEmpty())
joinToString(prefix = "[", postfix = "] ", separator = ",")
else
""
}
private fun IrClass.renderClassFlags() =
renderFlagsList(
"companion".takeIf { isCompanion },
"inner".takeIf { isInner },
"data".takeIf { isData },
"external".takeIf { isExternal },
"value".takeIf { isValue },
"expect".takeIf { isExpect },
"fun".takeIf { isFun }
)
private fun IrField.renderFieldFlags() =
renderFlagsList(
"final".takeIf { isFinal },
"external".takeIf { isExternal },
"static".takeIf { isStatic },
)
private fun IrSimpleFunction.renderSimpleFunctionFlags(): String =
renderFlagsList(
"tailrec".takeIf { isTailrec },
"inline".takeIf { isInline },
"external".takeIf { isExternal },
"suspend".takeIf { isSuspend },
"expect".takeIf { isExpect },
"fake_override".takeIf { isFakeOverride },
"operator".takeIf { isOperator },
"infix".takeIf { isInfix }
)
private fun IrConstructor.renderConstructorFlags() =
renderFlagsList(
"inline".takeIf { isInline },
"external".takeIf { isExternal },
"primary".takeIf { isPrimary },
"expect".takeIf { isExpect }
)
private fun IrProperty.renderPropertyFlags() =
renderFlagsList(
"external".takeIf { isExternal },
"const".takeIf { isConst },
"lateinit".takeIf { isLateinit },
"delegated".takeIf { isDelegated },
"expect".takeIf { isExpect },
"fake_override".takeIf { isFakeOverride },
if (isVar) "var" else "val"
)
private fun IrVariable.renderVariableFlags(): String =
renderFlagsList(
"const".takeIf { isConst },
"lateinit".takeIf { isLateinit },
if (isVar) "var" else "val"
)
private fun IrValueParameter.renderValueParameterFlags(): String =
renderFlagsList(
"vararg".takeIf { varargElementType != null },
"crossinline".takeIf { isCrossinline },
"noinline".takeIf { isNoinline },
"assignable".takeIf { isAssignable }
)
private fun IrTypeAlias.renderTypeAliasFlags(): String =
renderFlagsList(
"actual".takeIf { isActual }
)
private fun IrFunction.renderTypeParameters(): String =
typeParameters.joinToString(separator = ", ", prefix = "<", postfix = ">") { it.name.toString() }
private val IrFunction.safeReturnType: IrType?
get() = try {
returnType
} catch (e: ReturnTypeIsNotInitializedException) {
null
}
private fun IrLocalDelegatedProperty.renderLocalDelegatedPropertyFlags() =
if (isVar) "var" else "val"
private class VariableNameData(val normalizeNames: Boolean) {
val nameMap: MutableMap<IrVariableSymbol, String> = mutableMapOf()
var temporaryIndex: Int = 0
}
private fun IrVariable.normalizedName(data: VariableNameData): String {
if (data.normalizeNames && (origin == IrDeclarationOrigin.IR_TEMPORARY_VARIABLE || origin == IrDeclarationOrigin.FOR_LOOP_ITERATOR)) {
return data.nameMap.getOrPut(symbol) { "tmp_${data.temporaryIndex++}" }
}
return name.asString()
}
private fun IrFunction.renderReturnType(renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean): String =
safeReturnType?.renderTypeWithRenderer(renderer, verboseErrorTypes) ?: "<Uninitialized>"
private fun IrType.renderTypeWithRenderer(renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean): String =
"${renderTypeAnnotations(annotations, renderer, verboseErrorTypes)}${renderTypeInner(renderer, verboseErrorTypes)}"
private fun IrType.renderTypeInner(renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean) =
when (this) {
is IrDynamicType -> "dynamic"
is IrErrorType -> "IrErrorType(${verboseErrorTypes.ifTrue { originalKotlinType }})"
is IrSimpleType -> buildTrimEnd {
val isDefinitelyNotNullType =
classifier is IrTypeParameterSymbol && nullability == SimpleTypeNullability.DEFINITELY_NOT_NULL
if (isDefinitelyNotNullType) append("{")
append(classifier.renderClassifierFqn())
if (arguments.isNotEmpty()) {
append(
arguments.joinToString(prefix = "<", postfix = ">", separator = ", ") {
it.renderTypeArgument(renderer, verboseErrorTypes)
}
)
}
if (isDefinitelyNotNullType) {
append(" & Any}")
} else if (isMarkedNullable()) {
append('?')
}
abbreviation?.let {
append(it.renderTypeAbbreviation(renderer, verboseErrorTypes))
}
}
else -> "{${javaClass.simpleName} $this}"
}
private fun IrTypeAbbreviation.renderTypeAbbreviation(renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean): String =
buildString {
append("{ ")
append(renderTypeAnnotations(annotations, renderer, verboseErrorTypes))
append(typeAlias.renderTypeAliasFqn())
if (arguments.isNotEmpty()) {
append(
arguments.joinToString(prefix = "<", postfix = ">", separator = ", ") {
it.renderTypeArgument(renderer, verboseErrorTypes)
}
)
}
if (hasQuestionMark) {
append('?')
}
append(" }")
}
private fun IrTypeArgument.renderTypeArgument(renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean): String =
when (this) {
is IrStarProjection -> "*"
is IrTypeProjection -> buildTrimEnd {
append(variance.label)
if (variance != Variance.INVARIANT) append(' ')
append(type.renderTypeWithRenderer(renderer, verboseErrorTypes))
}
else -> "IrTypeArgument[$this]"
}
private fun renderTypeAnnotations(annotations: List<IrConstructorCall>, renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean) =
if (annotations.isEmpty())
""
else
buildString {
appendIterableWith(annotations, prefix = "", postfix = " ", separator = " ") {
append("@[")
renderAsAnnotation(it, renderer, verboseErrorTypes)
append("]")
}
}
private fun StringBuilder.renderAsAnnotation(
irAnnotation: IrConstructorCall,
renderer: RenderIrElementVisitor?,
verboseErrorTypes: Boolean,
) {
val annotationClassName = irAnnotation.symbol.takeIf { it.isBound }?.owner?.parentAsClass?.name?.asString() ?: "<unbound>"
append(annotationClassName)
if (irAnnotation.typeArgumentsCount != 0) {
(0 until irAnnotation.typeArgumentsCount).joinTo(this, ", ", "<", ">") { i ->
irAnnotation.getTypeArgument(i)?.renderTypeWithRenderer(renderer, verboseErrorTypes) ?: "null"
}
}
if (irAnnotation.valueArgumentsCount == 0) return
val valueParameterNames = irAnnotation.getValueParameterNamesForDebug()
appendIterableWith(0 until irAnnotation.valueArgumentsCount, separator = ", ", prefix = "(", postfix = ")") {
append(valueParameterNames[it])
append(" = ")
renderAsAnnotationArgument(irAnnotation.getValueArgument(it), renderer, verboseErrorTypes)
}
}
private fun StringBuilder.renderAsAnnotationArgument(irElement: IrElement?, renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean) {
when (irElement) {
null -> append("<null>")
is IrConstructorCall -> renderAsAnnotation(irElement, renderer, verboseErrorTypes)
is IrConst<*> -> {
append('\'')
append(irElement.value.toString())
append('\'')
}
is IrVararg -> {
appendIterableWith(irElement.elements, prefix = "[", postfix = "]", separator = ", ") {
renderAsAnnotationArgument(it, renderer, verboseErrorTypes)
}
}
else -> if (renderer != null) {
append(irElement.accept(renderer, null))
} else {
append("...")
}
}
}
private fun renderClassWithRenderer(declaration: IrClass, renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean) =
declaration.runTrimEnd {
"CLASS ${renderOriginIfNonTrivial()}" +
"$kind name:$name modality:$modality visibility:$visibility " +
renderClassFlags() +
"superTypes:[${superTypes.joinToString(separator = "; ") { it.renderTypeWithRenderer(renderer, verboseErrorTypes) }}]"
}
private fun renderEnumEntry(declaration: IrEnumEntry) = declaration.runTrimEnd {
"ENUM_ENTRY ${renderOriginIfNonTrivial()}name:$name"
}
private fun renderField(declaration: IrField, renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean) = declaration.runTrimEnd {
"FIELD ${renderOriginIfNonTrivial()}name:$name type:${
type.renderTypeWithRenderer(
renderer,
verboseErrorTypes
)
} visibility:$visibility ${renderFieldFlags()}"
}
private fun renderTypeParameter(declaration: IrTypeParameter, renderer: RenderIrElementVisitor?, verboseErrorTypes: Boolean) =
declaration.runTrimEnd {
"TYPE_PARAMETER ${renderOriginIfNonTrivial()}" +
"name:$name index:$index variance:$variance " +
"superTypes:[${
superTypes.joinToString(separator = "; ") {
it.renderTypeWithRenderer(
renderer, verboseErrorTypes
)
}
}] " +
"reified:$isReified"
}
+26
View File
@@ -0,0 +1,26 @@
// ISSUE: KT-52677
// MODULE: lib
// FILE: lib.kt
@Target(AnnotationTarget.TYPE)
annotation class MySerializable(val c: kotlin.reflect.KClass<*>)
public data class LoginSuccessPacket(val id: Uuid)
public typealias Uuid = @MySerializable(UuidSerializer::class) Uuid1
interface MySerializer<T>
public object UuidSerializer : MySerializer<Uuid>
public class Uuid1 {
fun ok() = "OK"
}
// MODULE: main(lib)
// FILE: main.kt
fun foo(): Uuid { throw RuntimeException() }
fun bar() = foo()
fun box() = LoginSuccessPacket(Uuid()).id.ok()
@@ -0,0 +1,186 @@
FILE fqName:<root> fileName:/kt52677.kt
TYPEALIAS name:Uuid visibility:public expandedType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
CLASS ANNOTATION_CLASS name:MySerializable modality:OPEN visibility:public superTypes:[kotlin.Annotation]
annotations:
Target(allowedTargets = [GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:TYPE' type=kotlin.annotation.AnnotationTarget])
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MySerializable
CONSTRUCTOR visibility:public <> (c:kotlin.reflect.KClass<*>) returnType:<root>.MySerializable [primary]
VALUE_PARAMETER name:c index:0 type:kotlin.reflect.KClass<*>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:MySerializable modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
PROPERTY name:c visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.reflect.KClass<*> visibility:private [final]
EXPRESSION_BODY
GET_VAR 'c: kotlin.reflect.KClass<*> declared in <root>.MySerializable.<init>' type=kotlin.reflect.KClass<*> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.MySerializable) returnType:kotlin.reflect.KClass<*>
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.MySerializable
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.reflect.KClass<*> declared in <root>.MySerializable'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.reflect.KClass<*> visibility:private [final]' type=kotlin.reflect.KClass<*> origin=null
receiver: GET_VAR '<this>: <root>.MySerializable declared in <root>.MySerializable.<get-c>' type=<root>.MySerializable origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:LoginSuccessPacket modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.LoginSuccessPacket
CONSTRUCTOR visibility:public <> (id:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1) returnType:<root>.LoginSuccessPacket [primary]
VALUE_PARAMETER name:id index:0 type:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:LoginSuccessPacket modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:id visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 visibility:private [final]
EXPRESSION_BODY
GET_VAR 'id: @[MySerializable(c = ...)] <root>.Uuid1 declared in <root>.LoginSuccessPacket.<init>' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-id> visibility:public modality:FINAL <> ($this:<root>.LoginSuccessPacket) returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
correspondingProperty: PROPERTY name:id visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-id> (): @[MySerializable(c = ...)] <root>.Uuid1 declared in <root>.LoginSuccessPacket'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.<get-id>' type=<root>.LoginSuccessPacket origin=null
FUN name:component1 visibility:public modality:FINAL <> ($this:<root>.LoginSuccessPacket) returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): @[MySerializable(c = ...)] <root>.Uuid1 [operator] declared in <root>.LoginSuccessPacket'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.component1' type=<root>.LoginSuccessPacket origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.LoginSuccessPacket, id:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1) returnType:<root>.LoginSuccessPacket
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
VALUE_PARAMETER name:id index:0 type:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
EXPRESSION_BODY
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.copy' type=<root>.LoginSuccessPacket origin=null
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun copy (id: @[MySerializable(c = ...)] <root>.Uuid1): <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket'
CONSTRUCTOR_CALL 'public constructor <init> (id: @[MySerializable(c = ...)] <root>.Uuid1) [primary] declared in <root>.LoginSuccessPacket' type=<root>.LoginSuccessPacket origin=null
id: GET_VAR 'id: @[MySerializable(c = ...)] <root>.Uuid1 declared in <root>.LoginSuccessPacket.copy' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.LoginSuccessPacket, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:<this> type:<root>.LoginSuccessPacket
VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any?
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
arg0: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.equals' type=<root>.LoginSuccessPacket origin=null
arg1: GET_VAR 'other: kotlin.Any? declared in <root>.LoginSuccessPacket.equals' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=true
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=<root>.LoginSuccessPacket
GET_VAR 'other: kotlin.Any? declared in <root>.LoginSuccessPacket.equals' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=false
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.LoginSuccessPacket [val]
TYPE_OP type=<root>.LoginSuccessPacket origin=CAST typeOperand=<root>.LoginSuccessPacket
GET_VAR 'other: kotlin.Any? declared in <root>.LoginSuccessPacket.equals' type=kotlin.Any? origin=null
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.equals' type=<root>.LoginSuccessPacket origin=null
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR 'val tmp_0: <root>.LoginSuccessPacket [val] declared in <root>.LoginSuccessPacket.equals' type=<root>.LoginSuccessPacket origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=false
RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=true
FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.LoginSuccessPacket) returnType:kotlin.Int
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.LoginSuccessPacket'
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.hashCode' type=<root>.LoginSuccessPacket origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:<root>.LoginSuccessPacket) returnType:kotlin.String
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.LoginSuccessPacket'
STRING_CONCATENATION type=kotlin.String
CONST String type=kotlin.String value="LoginSuccessPacket("
CONST String type=kotlin.String value="id="
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1 visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.toString' type=<root>.LoginSuccessPacket origin=null
CONST String type=kotlin.String value=")"
CLASS INTERFACE name:MySerializer modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MySerializer<T of <root>.MySerializer>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.UuidSerializer
CONSTRUCTOR visibility:private <> () returnType:<root>.UuidSerializer [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.MySerializer
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.MySerializer
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.MySerializer
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Uuid1 modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Uuid1
CONSTRUCTOR visibility:public <> () returnType:<root>.Uuid1 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Uuid1 modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:foo visibility:public modality:FINAL <> () returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
BLOCK_BODY
THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.RuntimeException' type=java.lang.RuntimeException origin=null
FUN name:bar visibility:public modality:FINAL <> () returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun bar (): @[MySerializable(c = ...)] <root>.Uuid1 declared in <root>'
CALL 'public final fun foo (): @[MySerializable(c = ...)] <root>.Uuid1 declared in <root>' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1 origin=null
@@ -0,0 +1,87 @@
typealias Uuid = @MySerializable(c = UuidSerializer::class) Uuid1
@Target(allowedTargets = [AnnotationTarget.TYPE])
open annotation class MySerializable : Annotation {
constructor(c: KClass<*>) /* primary */ {
super/*Any*/()
/* <init>() */
}
val c: KClass<*>
field = c
get
}
data class LoginSuccessPacket {
constructor(id: @MySerializable(c = UuidSerializer::class) Uuid1) /* primary */ {
super/*Any*/()
/* <init>() */
}
val id: @MySerializable(c = UuidSerializer::class) Uuid1
field = id
get
operator fun component1(): @MySerializable(c = UuidSerializer::class) Uuid1 {
return <this>.#id
}
fun copy(id: @MySerializable(c = UuidSerializer::class) Uuid1 = <this>.#id): LoginSuccessPacket {
return LoginSuccessPacket(id = id)
}
override fun equals(other: Any?): Boolean {
when {
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
}
when {
other !is LoginSuccessPacket -> return false
}
val tmp0_other_with_cast: LoginSuccessPacket = other as LoginSuccessPacket
when {
EQEQ(arg0 = <this>.#id, arg1 = tmp0_other_with_cast.#id).not() -> return false
}
return true
}
override fun hashCode(): Int {
return <this>.#id.hashCode()
}
override fun toString(): String {
return "LoginSuccessPacket(" + "id=" + <this>.#id + ")"
}
}
interface MySerializer<T : Any?> {
}
object UuidSerializer : MySerializer<@MySerializable(c = UuidSerializer::class) Uuid1> {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class Uuid1 {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
fun foo(): @MySerializable(c = UuidSerializer::class) Uuid1 {
throw RuntimeException()
}
fun bar(): @MySerializable(c = UuidSerializer::class) Uuid1 {
return foo()
}
+186
View File
@@ -0,0 +1,186 @@
FILE fqName:<root> fileName:/kt52677.kt
CLASS ANNOTATION_CLASS name:MySerializable modality:OPEN visibility:public superTypes:[kotlin.Annotation]
annotations:
Target(allowedTargets = [GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:TYPE' type=kotlin.annotation.AnnotationTarget])
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MySerializable
CONSTRUCTOR visibility:public <> (c:kotlin.reflect.KClass<*>) returnType:<root>.MySerializable [primary]
VALUE_PARAMETER name:c index:0 type:kotlin.reflect.KClass<*>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:MySerializable modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
PROPERTY name:c visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.reflect.KClass<*> visibility:private [final]
EXPRESSION_BODY
GET_VAR 'c: kotlin.reflect.KClass<*> declared in <root>.MySerializable.<init>' type=kotlin.reflect.KClass<*> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-c> visibility:public modality:FINAL <> ($this:<root>.MySerializable) returnType:kotlin.reflect.KClass<*>
correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.MySerializable
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-c> (): kotlin.reflect.KClass<*> declared in <root>.MySerializable'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.reflect.KClass<*> visibility:private [final]' type=kotlin.reflect.KClass<*> origin=null
receiver: GET_VAR '<this>: <root>.MySerializable declared in <root>.MySerializable.<get-c>' type=<root>.MySerializable origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:LoginSuccessPacket modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.LoginSuccessPacket
CONSTRUCTOR visibility:public <> (id:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }) returnType:<root>.LoginSuccessPacket [primary]
VALUE_PARAMETER name:id index:0 type:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:LoginSuccessPacket modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:id visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]
EXPRESSION_BODY
GET_VAR 'id: @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } declared in <root>.LoginSuccessPacket.<init>' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-id> visibility:public modality:FINAL <> ($this:<root>.LoginSuccessPacket) returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }
correspondingProperty: PROPERTY name:id visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-id> (): @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } declared in <root>.LoginSuccessPacket'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.<get-id>' type=<root>.LoginSuccessPacket origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:<root>.LoginSuccessPacket) returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } [operator] declared in <root>.LoginSuccessPacket'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.component1' type=<root>.LoginSuccessPacket origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:copy visibility:public modality:FINAL <> ($this:<root>.LoginSuccessPacket, id:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }) returnType:<root>.LoginSuccessPacket
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
VALUE_PARAMETER name:id index:0 type:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }
EXPRESSION_BODY
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.copy' type=<root>.LoginSuccessPacket origin=null
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun copy (id: @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }): <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket'
CONSTRUCTOR_CALL 'public constructor <init> (id: @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }) [primary] declared in <root>.LoginSuccessPacket' type=<root>.LoginSuccessPacket origin=null
id: GET_VAR 'id: @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } declared in <root>.LoginSuccessPacket.copy' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:<root>.LoginSuccessPacket) returnType:kotlin.String
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.LoginSuccessPacket'
STRING_CONCATENATION type=kotlin.String
CONST String type=kotlin.String value="LoginSuccessPacket("
CONST String type=kotlin.String value="id="
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.toString' type=<root>.LoginSuccessPacket origin=null
CONST String type=kotlin.String value=")"
FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.LoginSuccessPacket) returnType:kotlin.Int
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.LoginSuccessPacket'
CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Uuid1' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.hashCode' type=<root>.LoginSuccessPacket origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.LoginSuccessPacket, other:kotlin.Any?) returnType:kotlin.Boolean [operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:<root>.LoginSuccessPacket
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
arg0: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.equals' type=<root>.LoginSuccessPacket origin=null
arg1: GET_VAR 'other: kotlin.Any? declared in <root>.LoginSuccessPacket.equals' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=true
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=<root>.LoginSuccessPacket
GET_VAR 'other: kotlin.Any? declared in <root>.LoginSuccessPacket.equals' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=false
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.LoginSuccessPacket [val]
TYPE_OP type=<root>.LoginSuccessPacket origin=CAST typeOperand=<root>.LoginSuccessPacket
GET_VAR 'other: kotlin.Any? declared in <root>.LoginSuccessPacket.equals' type=kotlin.Any? origin=null
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR '<this>: <root>.LoginSuccessPacket declared in <root>.LoginSuccessPacket.equals' type=<root>.LoginSuccessPacket origin=null
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } visibility:private [final]' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
receiver: GET_VAR 'val tmp_0: <root>.LoginSuccessPacket [val] declared in <root>.LoginSuccessPacket.equals' type=<root>.LoginSuccessPacket origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=false
RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in <root>.LoginSuccessPacket'
CONST Boolean type=kotlin.Boolean value=true
TYPEALIAS name:Uuid visibility:public expandedType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1
CLASS INTERFACE name:MySerializer modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MySerializer<T of <root>.MySerializer>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.UuidSerializer
CONSTRUCTOR visibility:private <> () returnType:<root>.UuidSerializer [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.MySerializer
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.MySerializer
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in <root>.MySerializer
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Uuid1 modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Uuid1
CONSTRUCTOR visibility:public <> () returnType:<root>.Uuid1 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Uuid1 modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:foo visibility:public modality:FINAL <> () returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }
BLOCK_BODY
THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.RuntimeException' type=java.lang.RuntimeException origin=null
FUN name:bar visibility:public modality:FINAL <> () returnType:@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid }
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun bar (): @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } declared in <root>'
CALL 'public final fun foo (): @[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid } declared in <root>' type=@[MySerializable(c = CLASS_REFERENCE 'CLASS OBJECT name:UuidSerializer modality:FINAL visibility:public superTypes:[<root>.MySerializer<@[MySerializable(c = ...)] <root>.Uuid1{ <root>.Uuid }>]' type=kotlin.reflect.KClass<<root>.UuidSerializer>)] <root>.Uuid1{ <root>.Uuid } origin=null
+16
View File
@@ -0,0 +1,16 @@
// ISSUE: KT-52677
@Target(AnnotationTarget.TYPE)
annotation class MySerializable(val c: kotlin.reflect.KClass<*>)
public data class LoginSuccessPacket(val id: Uuid)
public typealias Uuid = @MySerializable(UuidSerializer::class) Uuid1
interface MySerializer<T>
public object UuidSerializer : MySerializer<Uuid>
public class Uuid1
fun foo(): Uuid { throw RuntimeException() }
fun bar() = foo()
+87
View File
@@ -0,0 +1,87 @@
@Target(allowedTargets = [AnnotationTarget.TYPE])
open annotation class MySerializable : Annotation {
constructor(c: KClass<*>) /* primary */ {
super/*Any*/()
/* <init>() */
}
val c: KClass<*>
field = c
get
}
data class LoginSuccessPacket {
constructor(id: @MySerializable(c = UuidSerializer::class) Uuid1) /* primary */ {
super/*Any*/()
/* <init>() */
}
val id: @MySerializable(c = UuidSerializer::class) Uuid1
field = id
get
operator fun component1(): @MySerializable(c = UuidSerializer::class) Uuid1 {
return <this>.#id
}
fun copy(id: @MySerializable(c = UuidSerializer::class) Uuid1 = <this>.#id): LoginSuccessPacket {
return LoginSuccessPacket(id = id)
}
override fun toString(): String {
return "LoginSuccessPacket(" + "id=" + <this>.#id + ")"
}
override fun hashCode(): Int {
return <this>.#id.hashCode()
}
override operator fun equals(other: Any?): Boolean {
when {
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
}
when {
other !is LoginSuccessPacket -> return false
}
val tmp0_other_with_cast: LoginSuccessPacket = other as LoginSuccessPacket
when {
EQEQ(arg0 = <this>.#id, arg1 = tmp0_other_with_cast.#id).not() -> return false
}
return true
}
}
typealias Uuid = @MySerializable(c = UuidSerializer::class) Uuid1
interface MySerializer<T : Any?> {
}
object UuidSerializer : MySerializer<@MySerializable(c = UuidSerializer::class) Uuid1> {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class Uuid1 {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
fun foo(): @MySerializable(c = UuidSerializer::class) Uuid1 {
throw RuntimeException()
}
fun bar(): @MySerializable(c = UuidSerializer::class) Uuid1 {
return foo()
}
@@ -27179,6 +27179,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
@@ -28037,6 +28037,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
@@ -498,6 +498,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
runTest("compiler/testData/ir/irText/declarations/kt47527.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@Test
@TestMetadata("localClassWithOverrides.kt")
public void testLocalClassWithOverrides() throws Exception {
@@ -22917,6 +22917,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
runTest("compiler/testData/codegen/box/ir/lambdaWithLoop.kt");
@@ -383,6 +383,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
runTest("compiler/testData/ir/irText/declarations/kt47527.kt");
}
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@TestMetadata("localClassWithOverrides.kt")
public void testLocalClassWithOverrides() throws Exception {
runTest("compiler/testData/ir/irText/declarations/localClassWithOverrides.kt");
@@ -21013,6 +21013,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
@@ -21031,6 +21031,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
@@ -21031,6 +21031,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
@@ -18670,6 +18670,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {
runTest("compiler/testData/codegen/box/ir/lambdaWithLoop.kt");
@@ -23746,6 +23746,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/ir/kt41765.kt");
}
@Test
@TestMetadata("kt52677.kt")
public void testKt52677() throws Exception {
runTest("compiler/testData/codegen/box/ir/kt52677.kt");
}
@Test
@TestMetadata("lambdaWithLoop.kt")
public void testLambdaWithLoop() throws Exception {