[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
@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.containingClassLookupTag
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.comparators.FirCallableDeclarationComparator
import org.jetbrains.kotlin.fir.declarations.comparators.FirMemberDeclarationComparator
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
@@ -57,8 +59,8 @@ internal class ClassMemberGenerator(
val allDeclarations = buildList {
addAll(klass.declarations)
if (session.extensionService.declarationGenerators.isNotEmpty()) {
addAll(klass.generatedMembers(session))
addAll(klass.generatedNestedClassifiers(session))
addAll(klass.generatedMembers(session).sortedWith(FirCallableDeclarationComparator))
addAll(klass.generatedNestedClassifiers(session).sortedWith(FirMemberDeclarationComparator))
}
}
@@ -88,6 +88,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@Test
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@Test
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
@@ -88,6 +88,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@Test
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@Test
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
@@ -6,17 +6,22 @@
package org.jetbrains.kotlin.fir.extensions
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirClass
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
fun FirClass.generatedNestedClassifiers(session: FirSession): List<FirDeclaration> {
fun FirClass.generatedNestedClassifiers(session: FirSession): List<FirClassLikeDeclaration> {
val scope = session.declaredMemberScope(this)
val result = mutableListOf<FirDeclaration>()
val result = mutableListOf<FirClassLikeDeclaration>()
for (name in scope.getClassifierNames()) {
scope.processClassifiersByName(name) {
if (it.fir.origin.generated) {
// Plugins can not generate type parameters, so it's safe to cast symbol here
require(it is FirClassLikeSymbol<*>) { "Plugins can not generate type parameters, but had $it" }
result += it.fir
}
}
@@ -24,9 +29,9 @@ fun FirClass.generatedNestedClassifiers(session: FirSession): List<FirDeclaratio
return result
}
fun FirClass.generatedMembers(session: FirSession): List<FirDeclaration> {
fun FirClass.generatedMembers(session: FirSession): List<FirCallableDeclaration> {
val scope = session.declaredMemberScope(this)
val result = mutableListOf<FirDeclaration>()
val result = mutableListOf<FirCallableDeclaration>()
for (name in scope.getCallableNames()) {
scope.processFunctionsByName(name) {
if (it.fir.origin.generated) {
@@ -0,0 +1,84 @@
FILE fqName:test fileName:/declarationOrder.kt
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:test.A
CONSTRUCTOR visibility:public <> () returnType:test.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]'
CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:test.A
VALUE_PARAMETER name:x index:0 type:kotlin.Int
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in test.A'
FUN name:b visibility:public modality:FINAL <> ($this:test.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:test.A
BLOCK_BODY
FUN name:a visibility:public modality:FINAL <> ($this:test.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:test.A
BLOCK_BODY
PROPERTY name:b visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
CONST Int type=kotlin.Int value=1
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:test.A) returnType:kotlin.Int
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:test.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.Int declared in test.A'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: test.A declared in test.A.<get-b>' type=test.A origin=null
PROPERTY name:a visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
CONST Int type=kotlin.Int value=2
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:test.A) returnType:kotlin.Int
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:test.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.Int declared in test.A'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: test.A declared in test.A.<get-a>' type=test.A origin=null
CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:test.A
VALUE_PARAMETER name:x index:0 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in test.A'
PROPERTY name:b visibility:public modality:FINAL [val]
FUN name:<get-b> visibility:public modality:FINAL <> ($this:test.A, $receiver:kotlin.Int) returnType:kotlin.String
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:test.A
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-b> (): kotlin.String declared in test.A'
CONST String type=kotlin.String value="b"
FUN name:b visibility:public modality:FINAL <> ($this:test.A, $receiver:kotlin.String) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:test.A
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
BLOCK_BODY
PROPERTY name:a visibility:public modality:FINAL [val]
FUN name:<get-a> visibility:public modality:FINAL <> ($this:test.A, $receiver:kotlin.Int) returnType:kotlin.String
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:test.A
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.String declared in test.A'
CONST String type=kotlin.String value="a"
FUN name:a visibility:public modality:FINAL <> ($this:test.A, $receiver:kotlin.String) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:test.A
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
BLOCK_BODY
CONSTRUCTOR visibility:public <> (x:kotlin.Double) returnType:test.A
VALUE_PARAMETER name:x index:0 type:kotlin.Double
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in test.A'
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
+19
View File
@@ -0,0 +1,19 @@
// FIR_IDENTICAL
// SKIP_KLIB_TEST
// IGNORE_BACKEND_K1: JS_IR
// Ignore reason: there is a js name clash between function `a()` and property `a`
package test
class A() {
constructor(x: Int) : this()
fun b() {}
fun a() {}
val b: Int = 1
val a: Int = 2
constructor(x: String) : this()
val Int.b: String get() = "b"
fun String.b() {}
val Int.a: String get() = "a"
fun String.a() {}
constructor(x: Double) : this()
}
@@ -0,0 +1,53 @@
package test
class A {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
constructor(x: Int) {
this/*A*/()
}
fun b() {
}
fun a() {
}
val b: Int
field = 1
get
val a: Int
field = 2
get
constructor(x: String) {
this/*A*/()
}
val Int.b: String
get(): String {
return "b"
}
fun String.b() {
}
val Int.a: String
get(): String {
return "a"
}
fun String.a() {
}
constructor(x: Double) {
this/*A*/()
}
}
@@ -88,6 +88,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@Test
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@Test
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
@@ -87,6 +87,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
runTest("compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt");
@@ -88,6 +88,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@Test
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@Test
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
@@ -88,6 +88,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@Test
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@Test
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
@@ -88,6 +88,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
runTest("compiler/testData/ir/irText/classes/companionObject.kt");
}
@Test
@TestMetadata("declarationOrder.kt")
public void testDeclarationOrder() throws Exception {
runTest("compiler/testData/ir/irText/classes/declarationOrder.kt");
}
@Test
@TestMetadata("delegatedGenericImplementation.kt")
public void testDelegatedGenericImplementation() throws Exception {
@@ -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())