[FIR2IR] Generate IR declarations in classes in strict order

Order is following:
- declared declarations in declaration (in source) order
- generated declarations in sorted order
This commit is contained in:
Dmitriy Novozhilov
2023-03-13 11:57:27 +02:00
committed by Space Team
parent c961c15729
commit 839026b6fe
15 changed files with 467 additions and 22 deletions
@@ -0,0 +1,221 @@
FILE fqName:<root> fileName:/serializer.kt
CLASS OBJECT name:FirstSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
CoreSerializer
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.FirstSerializer
CONSTRUCTOR visibility:private <> () returnType:<root>.FirstSerializer [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:FirstSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:bFunction visibility:public modality:FINAL <> ($this:<root>.FirstSerializer) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
BLOCK_BODY
FUN name:aFunction visibility:public modality:FINAL <> ($this:<root>.FirstSerializer) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
BLOCK_BODY
PROPERTY name:bProp visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:bProp type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
CONST Int type=kotlin.Int value=1
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-bProp> visibility:public modality:FINAL <> ($this:<root>.FirstSerializer) returnType:kotlin.Int
correspondingProperty: PROPERTY name:bProp visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-bProp> (): kotlin.Int declared in <root>.FirstSerializer'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bProp type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.FirstSerializer declared in <root>.FirstSerializer.<get-bProp>' type=<root>.FirstSerializer origin=null
PROPERTY name:aProp visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:aProp type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
CONST Int type=kotlin.Int value=2
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-aProp> visibility:public modality:FINAL <> ($this:<root>.FirstSerializer) returnType:kotlin.Int
correspondingProperty: PROPERTY name:aProp visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-aProp> (): kotlin.Int declared in <root>.FirstSerializer'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aProp type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.FirstSerializer declared in <root>.FirstSerializer.<get-aProp>' type=<root>.FirstSerializer origin=null
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeA visibility:public modality:FINAL <> ($this:<root>.FirstSerializer, x:<root>.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.A
BLOCK_BODY
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeB visibility:public modality:FINAL <> ($this:<root>.FirstSerializer, x:<root>.B) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.B
BLOCK_BODY
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeC visibility:public modality:FINAL <> ($this:<root>.FirstSerializer, x:<root>.C) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.C
BLOCK_BODY
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeD visibility:public modality:FINAL <> ($this:<root>.FirstSerializer, x:<root>.D) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.FirstSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.D
BLOCK_BODY
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:SecondSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
CoreSerializer
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.SecondSerializer
CONSTRUCTOR visibility:private <> () returnType:<root>.SecondSerializer [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:SecondSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeA visibility:public modality:FINAL <> ($this:<root>.SecondSerializer, x:<root>.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.SecondSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.A
BLOCK_BODY
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeB visibility:public modality:FINAL <> ($this:<root>.SecondSerializer, x:<root>.B) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.SecondSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.B
BLOCK_BODY
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeC visibility:public modality:FINAL <> ($this:<root>.SecondSerializer, x:<root>.C) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.SecondSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.C
BLOCK_BODY
FUN GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:serializeD visibility:public modality:FINAL <> ($this:<root>.SecondSerializer, x:<root>.D) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.SecondSerializer
VALUE_PARAMETER GENERATED[org.jetbrains.kotlin.fir.plugin.generators.MembersOfSerializerGenerator.Key] name:x index:0 type:<root>.D
BLOCK_BODY
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 CLASS name:D modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
MySerializable
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D 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
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
MySerializable
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C 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
CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
MySerializable
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
CONSTRUCTOR visibility:public <> () returnType:<root>.B [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B 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
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
annotations:
MySerializable
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A 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:testFirstSerializer visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun serializeA (x: <root>.A): kotlin.Unit declared in <root>.FirstSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:FirstSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.FirstSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null
CALL 'public final fun serializeB (x: <root>.B): kotlin.Unit declared in <root>.FirstSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:FirstSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.FirstSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.B' type=<root>.B origin=null
CALL 'public final fun serializeC (x: <root>.C): kotlin.Unit declared in <root>.FirstSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:FirstSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.FirstSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
CALL 'public final fun serializeD (x: <root>.D): kotlin.Unit declared in <root>.FirstSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:FirstSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.FirstSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
FUN name:testSecondSerializer visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun serializeA (x: <root>.A): kotlin.Unit declared in <root>.SecondSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:SecondSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.SecondSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null
CALL 'public final fun serializeB (x: <root>.B): kotlin.Unit declared in <root>.SecondSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:SecondSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.SecondSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.B' type=<root>.B origin=null
CALL 'public final fun serializeC (x: <root>.C): kotlin.Unit declared in <root>.SecondSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:SecondSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.SecondSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
CALL 'public final fun serializeD (x: <root>.D): kotlin.Unit declared in <root>.SecondSerializer' type=kotlin.Unit origin=null
$this: GET_OBJECT 'CLASS OBJECT name:SecondSerializer modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.SecondSerializer
x: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
CALL 'public final fun testFirstSerializer (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
CALL 'public final fun testSecondSerializer (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="OK"
+22 -10
View File
@@ -4,6 +4,18 @@ FILE: serializer.kt
super<R|kotlin/Any|>()
}
public final fun bFunction(): R|kotlin/Unit| {
}
public final fun aFunction(): R|kotlin/Unit| {
}
public final val bProp: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public final val aProp: R|kotlin/Int| = Int(2)
public get(): R|kotlin/Int|
public final fun serializeA(x: R|A|): R|kotlin/Unit| {
}
@@ -35,14 +47,8 @@ FILE: serializer.kt
}
}
@R|org/jetbrains/kotlin/fir/plugin/MySerializable|() public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
@R|org/jetbrains/kotlin/fir/plugin/MySerializable|() public final class B : R|kotlin/Any| {
public constructor(): R|B| {
@R|org/jetbrains/kotlin/fir/plugin/MySerializable|() public final class D : R|kotlin/Any| {
public constructor(): R|D| {
super<R|kotlin/Any|>()
}
@@ -53,8 +59,14 @@ FILE: serializer.kt
}
}
@R|org/jetbrains/kotlin/fir/plugin/MySerializable|() public final class D : R|kotlin/Any| {
public constructor(): R|D| {
@R|org/jetbrains/kotlin/fir/plugin/MySerializable|() public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
}
@R|org/jetbrains/kotlin/fir/plugin/MySerializable|() public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
+14 -6
View File
@@ -1,23 +1,31 @@
// DUMP_IR
import org.jetbrains.kotlin.fir.plugin.CoreSerializer
import org.jetbrains.kotlin.fir.plugin.MySerializable
@CoreSerializer
object FirstSerializer
object FirstSerializer {
fun bFunction() {}
fun aFunction() {}
val bProp = 1
val aProp = 2
}
@CoreSerializer
object SecondSerializer
@MySerializable
class A
@MySerializable
class B
class D
@MySerializable
class C
@MySerializable
class D
class B
@MySerializable
class A
fun testFirstSerializer() {
FirstSerializer.serializeA(A())