[IRFakeOverrides] Convert lazy callables overriddens during f/o building

Unfortunately, it's not enough to know direct overriddens
to correctly build fake overrides. This mean, that we need to know
whole overridden tree during the process of building.

It happens automatically for normal classes, but not for lazy classes,
as their overriddens are built separatly.

This commit enforces correct overrddens for lazy classes in hierarhies
at the point, where they should be normally computed.

^KT-65236
This commit is contained in:
Pavel Kunyavskiy
2024-01-30 09:50:51 +01:00
committed by Space Team
parent caa6918031
commit c0152ccf0f
17 changed files with 620 additions and 4 deletions
@@ -19,15 +19,19 @@ import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.backend.jvm.Fir2IrJvmSpecialAnnotationSymbolProvider
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass
import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.ir.IrBuiltIns
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.KtDiagnosticReporterWithImplicitIrBasedContext
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyDeclarationBase
import org.jetbrains.kotlin.ir.overrides.IrFakeOverrideBuilder
import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
import org.jetbrains.kotlin.ir.types.getClass
import org.jetbrains.kotlin.ir.util.KotlinMangler
@@ -117,7 +121,8 @@ fun FirResult.convertToIrAndActualize(
// actualization separately. This should go away, after useIrFakeOverrideBuilder becomes
// always enabled
irActualizer?.actualizeClassifiers()
components.fakeOverrideBuilder.buildForAll(allIrModules)
val temporaryResolver = SpecialFakeOverrideSymbolsResolver(emptyMap())
components.fakeOverrideBuilder.buildForAll(allIrModules, temporaryResolver)
}
val expectActualMap = irActualizer?.actualizeCallablesAndMergeModules() ?: emptyMap()
if (components.configuration.useIrFakeOverrideBuilder) {
@@ -132,15 +137,58 @@ fun FirResult.convertToIrAndActualize(
return Fir2IrActualizedResult(irModuleFragment, components, pluginContext, actualizationResult)
}
private fun IrFakeOverrideBuilder.buildForAll(modules: List<IrModuleFragment>) {
private fun resolveOverridenSymbolsInLazyClass(
clazz: Fir2IrLazyClass,
resolver: SpecialFakeOverrideSymbolsResolver
) {
/*
* Eventually, we should be able to process lazy classes with the same code.
*
* Now we can't do this, because overriding by Java function is not supported correctly in IR builder.
* In most cases, nothing need to be done for lazy classes. For other cases, it is
* caller responsibility to handle them.
*
* Super-classes already have processed fake overrides at this moment.
* Also, all Fir2IrLazyClass super-classes are always platform classes,
* so it's valid to process it with empty expect-actual mapping.
*
* But this is still a hack, and should be removed within KT-64352
*/
@OptIn(UnsafeDuringIrConstructionAPI::class)
for (declaration in clazz.declarations) {
when (declaration) {
is IrSimpleFunction -> {
declaration.overriddenSymbols = declaration.overriddenSymbols.map { resolver.getReferencedSimpleFunction(it) }
}
is IrProperty -> {
declaration.overriddenSymbols = declaration.overriddenSymbols.map { resolver.getReferencedProperty(it) }
declaration.getter?.let { getter ->
getter.overriddenSymbols = getter.overriddenSymbols.map { resolver.getReferencedSimpleFunction(it) }
}
declaration.setter?.let { setter ->
setter.overriddenSymbols = setter.overriddenSymbols.map { resolver.getReferencedSimpleFunction(it) }
}
}
}
}
}
private fun IrFakeOverrideBuilder.buildForAll(
modules: List<IrModuleFragment>,
resolver: SpecialFakeOverrideSymbolsResolver
) {
val builtFakeOverridesClasses = mutableSetOf<IrClass>()
fun buildFakeOverrides(clazz: IrClass) {
if (clazz is IrLazyDeclarationBase) return
if (!builtFakeOverridesClasses.add(clazz)) return
for (c in clazz.superTypes) {
c.getClass()?.let { buildFakeOverrides(it) }
}
buildFakeOverridesForClass(clazz, false)
if (clazz is IrLazyDeclarationBase) {
resolveOverridenSymbolsInLazyClass(clazz as Fir2IrLazyClass, resolver)
} else {
buildFakeOverridesForClass(clazz, false)
}
}
class ClassVisitor : IrElementVisitorVoid {
@@ -468,6 +468,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt");
}
@Test
@TestMetadata("fakeOverrideModality.kt")
public void testFakeOverrideModality() throws Exception {
runTest("compiler/testData/ir/irText/declarations/fakeOverrideModality.kt");
}
@Test
@TestMetadata("fakeOverrides.kt")
public void testFakeOverrides() throws Exception {
@@ -540,6 +546,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@Test
@TestMetadata("kt65236.kt")
public void testKt65236() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt65236.kt");
}
@Test
@TestMetadata("kt65432.kt")
public void testKt65432() throws Exception {
@@ -468,6 +468,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt");
}
@Test
@TestMetadata("fakeOverrideModality.kt")
public void testFakeOverrideModality() throws Exception {
runTest("compiler/testData/ir/irText/declarations/fakeOverrideModality.kt");
}
@Test
@TestMetadata("fakeOverrides.kt")
public void testFakeOverrides() throws Exception {
@@ -540,6 +546,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest {
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@Test
@TestMetadata("kt65236.kt")
public void testKt65236() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt65236.kt");
}
@Test
@TestMetadata("kt65432.kt")
public void testKt65432() throws Exception {
@@ -1,6 +1,11 @@
// NATIVE error: static cache is broken: ld.gold invocation reported errors. Please try to disable compiler caches and rerun the build.
// DONT_TARGET_EXACT_BACKEND: NATIVE
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
// KT-65416
// IGNORE_BACKEND_K2: WASM
// MODULE: lib
// FILE: 2.kt
abstract class A {
@@ -1,6 +1,10 @@
// NATIVE error: static cache is broken: ld.gold invocation reported errors. Please try to disable compiler caches and rerun the build.
// DONT_TARGET_EXACT_BACKEND: NATIVE
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
// KT-65416
// IGNORE_BACKEND_K2: WASM
// MODULE: lib
// FILE: 2.kt
abstract class A {
@@ -1,6 +1,11 @@
// NATIVE error: static cache is broken: ld.gold invocation reported errors. Please try to disable compiler caches and rerun the build.
// DONT_TARGET_EXACT_BACKEND: NATIVE
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
// KT-65416
// IGNORE_BACKEND_K2: WASM
// MODULE: lib
// FILE: 2.kt
abstract class A {
@@ -1,6 +1,11 @@
// NATIVE error: static cache is broken: ld.gold invocation reported errors. Please try to disable compiler caches and rerun the build.
// DONT_TARGET_EXACT_BACKEND: NATIVE
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
// KT-65416
// IGNORE_BACKEND_K2: WASM
// MODULE: lib
// FILE: 2.kt
abstract class A {
@@ -1,6 +1,10 @@
// NATIVE error: static cache is broken: ld.gold invocation reported errors. Please try to disable compiler caches and rerun the build.
// DONT_TARGET_EXACT_BACKEND: NATIVE
// IGNORE_BACKEND: JS_IR, JS_IR_ES6
// KT-65416
// IGNORE_BACKEND_K2: WASM
// MODULE: lib
// FILE: 2.kt
abstract class A {
@@ -0,0 +1,104 @@
FILE fqName:<root> fileName:/fakeOverrideModality.kt
CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Base
CONSTRUCTOR visibility:public <> () returnType:<root>.Base [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:OPEN 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 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:Child modality:FINAL visibility:public superTypes:[<root>.Base]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Child
CONSTRUCTOR visibility:public <> () returnType:<root>.Child [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Base'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Child modality:FINAL visibility:public superTypes:[<root>.Base]'
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 declared in <root>.Base
$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 <root>.Base
$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 <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.I) returnType:<root>.Base
$this: VALUE_PARAMETER name:<this> type:<root>.I
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 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:J modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.J
CONSTRUCTOR visibility:public <> () returnType:<root>.J [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:J modality:ABSTRACT visibility:public superTypes:[kotlin.Any]'
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.J) returnType:<root>.Child
$this: VALUE_PARAMETER name:<this> type:<root>.J
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 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:ABSTRACT visibility:public superTypes:[<root>.I; <root>.J]
$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> () declared in <root>.J'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:ABSTRACT visibility:public superTypes:[<root>.I; <root>.J]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.J) returnType:<root>.Child [fake_override]
overridden:
public abstract fun foo (): <root>.Base declared in <root>.I
public abstract fun foo (): <root>.Child declared in <root>.J
$this: VALUE_PARAMETER name:<this> type:<root>.J
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 declared in <root>.I
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.J
$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 <root>.I
public open fun hashCode (): kotlin.Int declared in <root>.J
$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 <root>.I
public open fun toString (): kotlin.String declared in <root>.J
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -0,0 +1,16 @@
// FIR_IDENTICAL
// ENABLE_IR_FAKE_OVERRIDE_GENERATION
// TARGET_BACKEND: JVM
open class Base
class Child: Base()
interface I {
fun foo(): Base
}
abstract class J {
abstract fun foo(): Child
}
abstract class A : I, J()
@@ -0,0 +1,42 @@
open class Base {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class Child : Base {
constructor() /* primary */ {
super/*Base*/()
/* <init>() */
}
}
interface I {
abstract fun foo(): Base
}
abstract class J {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
abstract fun foo(): Child
}
abstract class A : I, J {
constructor() /* primary */ {
super/*J*/()
/* <init>() */
}
}
@@ -0,0 +1,71 @@
// CHECK:
// Mangled name: A
// Public signature: /A|null[0]
abstract class A : J, I {
// CHECK:
// Mangled name: A#<init>(){}
// Public signature: /A.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
// CHECK JVM_IR:
// Mangled name: A#foo(){}Child
// Public signature: /A.foo|8517421086584195144[0]
// Public signature debug description: foo(){}Child
abstract /* fake */ override fun foo(): Child
}
// CHECK:
// Mangled name: Base
// Public signature: /Base|null[0]
open class Base {
// CHECK:
// Mangled name: Base#<init>(){}
// Public signature: /Base.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: Child
// Public signature: /Child|null[0]
class Child : Base {
// CHECK:
// Mangled name: Child#<init>(){}
// Public signature: /Child.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: J
// Public signature: /J|null[0]
abstract class J {
// CHECK:
// Mangled name: J#<init>(){}
// Public signature: /J.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
// CHECK JVM_IR:
// Mangled name: J#foo(){}Child
// Public signature: /J.foo|8517421086584195144[0]
// Public signature debug description: foo(){}Child
abstract fun foo(): Child
}
// CHECK:
// Mangled name: I
// Public signature: /I|null[0]
interface I {
// CHECK JVM_IR:
// Mangled name: I#foo(){}Base
// Public signature: /I.foo|-5590126600799232132[0]
// Public signature debug description: foo(){}Base
abstract fun foo(): Base
}
+117
View File
@@ -0,0 +1,117 @@
FILE fqName:<root> fileName:/E.kt
CLASS INTERFACE name:II modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.II
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.II) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.II
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 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 INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[<root>.II]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I
FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:<root>.II) returnType:kotlin.Unit [fake_override]
overridden:
public open fun foo (): kotlin.Unit declared in <root>.II
$this: VALUE_PARAMETER name:<this> type:<root>.II
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 declared in <root>.II
$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 <root>.II
$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 <root>.II
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:C modality:ABSTRACT visibility:public superTypes:[<root>.I]
$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> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:ABSTRACT visibility:public superTypes:[<root>.I]'
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.C) returnType:kotlin.Unit
overridden:
public open fun foo (): kotlin.Unit declared in <root>.I
$this: VALUE_PARAMETER name:<this> type:<root>.C
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 declared in <root>.I
$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 <root>.I
$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 <root>.I
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:D modality:ABSTRACT visibility:public superTypes:[<root>.C; <root>.J]
$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> () declared in <root>.C'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:ABSTRACT visibility:public superTypes:[<root>.C; <root>.J]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.C) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.C
public open fun foo (): kotlin.Unit declared in <root>.J
$this: VALUE_PARAMETER name:<this> type:<root>.C
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 declared in <root>.C
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.J
$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 <root>.C
public open fun hashCode (): kotlin.Int declared in <root>.J
$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 <root>.C
public open fun toString (): kotlin.String declared in <root>.J
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:E modality:FINAL visibility:public superTypes:[<root>.D]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.E
CONSTRUCTOR visibility:public <> () returnType:<root>.E [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.D'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:E modality:FINAL visibility:public superTypes:[<root>.D]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.E) returnType:kotlin.Unit
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.D
$this: VALUE_PARAMETER name:<this> type:<root>.E
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 declared in <root>.D
$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 <root>.D
$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 <root>.D
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:foo visibility:public modality:FINAL <> (x:<root>.I) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:<root>.I
BLOCK_BODY
CALL 'public open fun foo (): kotlin.Unit declared in <root>.I' type=kotlin.Unit origin=null
$this: GET_VAR 'x: <root>.I declared in <root>.foo' type=<root>.I origin=null
+32
View File
@@ -0,0 +1,32 @@
// FIR_IDENTICAL
// ENABLE_IR_FAKE_OVERRIDE_GENERATION
// TARGET_BACKEND: JVM
// FILE: J.java
interface J extends I {
}
// FILE: E.kt
interface II {
fun foo() {}
}
interface I : II {
}
abstract class C: I {
override abstract fun foo()
}
abstract class D : C(), J {}
class E : D() {
override fun foo() {}
}
fun foo(x : I) {
x.foo()
}
+44
View File
@@ -0,0 +1,44 @@
interface II {
fun foo() {
}
}
interface I : II {
}
abstract class C : I {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
abstract override fun foo()
}
abstract class D : C, J {
constructor() /* primary */ {
super/*C*/()
/* <init>() */
}
}
class E : D {
constructor() /* primary */ {
super/*D*/()
/* <init>() */
}
override fun foo() {
}
}
fun foo(x: I) {
x.foo()
}
@@ -0,0 +1,83 @@
// CHECK:
// Mangled name: C
// Public signature: /C|null[0]
abstract class C : I {
// CHECK:
// Mangled name: C#<init>(){}
// Public signature: /C.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
// CHECK:
// Mangled name: C#foo(){}
// Public signature: /C.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
abstract override fun foo(): Unit
}
// CHECK:
// Mangled name: D
// Public signature: /D|null[0]
abstract class D : C, J {
// CHECK:
// Mangled name: D#<init>(){}
// Public signature: /D.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
// CHECK:
// Mangled name: D#foo(){}
// Public signature: /D.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
abstract /* fake */ override fun foo(): Unit
}
// CHECK:
// Mangled name: E
// Public signature: /E|null[0]
class E : D {
// CHECK:
// Mangled name: E#<init>(){}
// Public signature: /E.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
// CHECK:
// Mangled name: E#foo(){}
// Public signature: /E.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
override fun foo(): Unit
}
// CHECK:
// Mangled name: I
// Public signature: /I|null[0]
interface I : II {
// CHECK:
// Mangled name: I#foo(){}
// Public signature: /I.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
/* fake */ override fun foo(): Unit
}
// CHECK:
// Mangled name: II
// Public signature: /II|null[0]
interface II {
// CHECK:
// Mangled name: II#foo(){}
// Public signature: /II.foo|-1041209573719867811[0]
// Public signature debug description: foo(){}
fun foo(): Unit
}
// CHECK:
// Mangled name: #foo(I){}
// Public signature: /foo|-4109751996049019888[0]
// Public signature debug description: foo(I){}
fun foo(x: I): Unit
@@ -468,6 +468,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt");
}
@Test
@TestMetadata("fakeOverrideModality.kt")
public void testFakeOverrideModality() throws Exception {
runTest("compiler/testData/ir/irText/declarations/fakeOverrideModality.kt");
}
@Test
@TestMetadata("fakeOverrides.kt")
public void testFakeOverrides() throws Exception {
@@ -540,6 +546,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest
runTest("compiler/testData/ir/irText/declarations/kt52677.kt");
}
@Test
@TestMetadata("kt65236.kt")
public void testKt65236() throws Exception {
runTest("compiler/testData/ir/irText/declarations/kt65236.kt");
}
@Test
@TestMetadata("kt65432.kt")
public void testKt65432() throws Exception {