[FIR2IR] Properly calculate overridden symbols for lazy declarations

This change affects only mode with IR f/o generator

The old way of overridden computation with fir2ir f/o generator relied
  on the fact that fir2ir generator creates IR for all f/o and fills
  its caches. But with IR f/o generator enabled, we don't call fir2ir
  generator, so some caches are missing. And for this mode it's enough
  to acquire the symbol using the original declaration symbol and the
  lookup tag of the corresponding supertype

Relates to KT-64202
This commit is contained in:
Dmitriy Novozhilov
2023-12-06 12:10:48 +02:00
committed by Space Team
parent dcd3f3b155
commit 97cf62e291
17 changed files with 439 additions and 16 deletions
@@ -19190,6 +19190,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -19190,6 +19190,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -8,10 +8,7 @@ package org.jetbrains.kotlin.fir.backend.generators
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.allowsToHaveFakeOverride
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
import org.jetbrains.kotlin.fir.declarations.utils.isStatic
import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.resolve.defaultType
import org.jetbrains.kotlin.fir.resolve.isRealOwnerOf
import org.jetbrains.kotlin.fir.resolve.toFirRegularClass
@@ -25,6 +22,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.types.typeContext
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.types.*
@@ -219,6 +217,46 @@ class FakeOverrideGenerator(
baseFunctionSymbols[fakeOverride.symbol] = baseFirSymbolsForFakeOverride
}
internal fun computeBaseSymbolsWithContainingClass(
klass: FirClass,
originalFunction: FirNamedFunctionSymbol,
): List<Pair<FirNamedFunctionSymbol, ConeClassLikeLookupTag>> {
return computeBaseSymbolsWithContainingClass(klass, originalFunction, FirTypeScope::getDirectOverriddenFunctions)
}
internal fun computeBaseSymbolsWithContainingClass(
klass: FirClass,
originalFunction: FirPropertySymbol,
): List<Pair<FirPropertySymbol, ConeClassLikeLookupTag>> {
return computeBaseSymbolsWithContainingClass(klass, originalFunction, FirTypeScope::getDirectOverriddenProperties)
}
private inline fun <reified S : FirCallableSymbol<*>> computeBaseSymbolsWithContainingClass(
klass: FirClass,
originalSymbol: S,
directOverridden: FirTypeScope.(S) -> List<S>,
): List<Pair<S, ConeClassLikeLookupTag>> {
val scope = klass.unsubstitutedScope()
val classLookupTag = klass.symbol.toLookupTag()
val overriddenFirSymbols = computeBaseSymbols(originalSymbol, directOverridden, scope, classLookupTag)
val superTypes = klass.superConeTypes
val typeContext = session.typeContext
return overriddenFirSymbols.flatMap { symbol ->
with(typeContext) {
val symbolDispatchReceiver = symbol.containingClassLookupTag() ?: return@flatMap emptyList()
superTypes.mapNotNull { superType ->
val compatibleType = superType.anySuperTypeConstructor {
it.typeConstructor() == symbolDispatchReceiver
}
if (!compatibleType) {
return@mapNotNull null
}
symbol to superType.lookupTag
}
}
}
}
internal fun calcBaseSymbolsForFakeOverrideProperty(
klass: FirClass,
fakeOverride: IrProperty,
@@ -169,7 +169,7 @@ class Fir2IrLazyProperty(
override var getter: IrSimpleFunction? = Fir2IrLazyPropertyAccessor(
components, startOffset, endOffset,
origin =when {
origin = when {
origin == IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB -> origin
fir.delegate != null -> IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR
origin == IrDeclarationOrigin.FAKE_OVERRIDE -> origin
@@ -214,17 +214,34 @@ class Fir2IrLazyProperty(
}
override var overriddenSymbols: List<IrPropertySymbol> by lazyVar(lock) {
if (containingClass == null) return@lazyVar emptyList()
when (configuration.useIrFakeOverrideBuilder) {
true -> computeOverriddenSymbolsForIrFakeOverrideGenerator()
false -> computeOverriddenUsingFir2IrFakeOverrideGenerator()
}
}
// TODO: drop this function after migration to IR f/o generator will be complete (KT-64202)
private fun computeOverriddenUsingFir2IrFakeOverrideGenerator(): List<IrPropertySymbol> {
if (containingClass == null) return emptyList()
if (isFakeOverride && parent is Fir2IrLazyClass) {
fakeOverrideGenerator.calcBaseSymbolsForFakeOverrideProperty(
containingClass, this, fir.symbol
)
fakeOverrideGenerator.getOverriddenSymbolsForFakeOverride(this)?.let {
assert(!it.contains(symbol)) { "Cannot add function $symbol to its own overriddenSymbols" }
return@lazyVar it
return it
}
}
fir.generateOverriddenPropertySymbols(containingClass)
return fir.generateOverriddenPropertySymbols(containingClass)
}
private fun computeOverriddenSymbolsForIrFakeOverrideGenerator(): List<IrPropertySymbol> {
if (containingClass == null || parent !is Fir2IrLazyClass) return emptyList()
val baseFunctionWithDispatchReceiverTag =
fakeOverrideGenerator.computeBaseSymbolsWithContainingClass(containingClass, fir.symbol)
return baseFunctionWithDispatchReceiverTag.map { (symbol, dispatchReceiverLookupTag) ->
declarationStorage.getIrPropertySymbol(symbol, dispatchReceiverLookupTag) as IrPropertySymbol
}
}
override var metadata: MetadataSource?
@@ -113,10 +113,27 @@ class Fir2IrLazyPropertyAccessor(
if (firParentClass == null) return@lazyVar emptyList()
// If property accessor is created then corresponding property is definitely created too
@OptIn(UnsafeDuringIrConstructionAPI::class)
correspondingPropertySymbol!!.owner.overriddenSymbols.mapNotNull {
when (isSetter) {
false -> declarationStorage.findGetterOfProperty(it)
true -> declarationStorage.findSetterOfProperty(it)
val correspondingProperty = correspondingPropertySymbol!!.owner
correspondingProperty.overriddenSymbols.mapNotNull {
/*
* Calculation of overridden symbols for lazy accessor may be called
* 1. during fir2ir transformation
* 2. somewhere in the backend, after fake-overrides were built
*
* In the first case declarationStorage knows about all symbols, so we always can search for accessor symbol in it
* But in the second case property symbols for fake-overrides are replaced with real one (in f/o generator) and
* declarationStorage has no information about it. But at this point all symbols are already bound. So we can
* just access the corresponding accessor using owner of the symbol
*/
when {
it.isBound -> @OptIn(UnsafeDuringIrConstructionAPI::class) when (isSetter) {
false -> it.owner.getter?.symbol
true -> it.owner.setter?.symbol
}
else -> when (isSetter) {
false -> declarationStorage.findGetterOfProperty(it)
true -> declarationStorage.findSetterOfProperty(it)
}
}
}
}
@@ -30,7 +30,7 @@ class Fir2IrLazySimpleFunction(
endOffset: Int,
origin: IrDeclarationOrigin,
override val fir: FirSimpleFunction,
firParent: FirRegularClass?,
private val firParent: FirRegularClass?,
symbol: IrSimpleFunctionSymbol,
parent: IrDeclarationParent,
isFakeOverride: Boolean
@@ -93,17 +93,34 @@ class Fir2IrLazySimpleFunction(
}
override var overriddenSymbols: List<IrSimpleFunctionSymbol> by lazyVar(lock) {
if (firParent == null) return@lazyVar emptyList()
when (configuration.useIrFakeOverrideBuilder) {
true -> computeOverriddenSymbolsForIrFakeOverrideGenerator()
false -> computeOverriddenUsingFir2IrFakeOverrideGenerator()
}
}
// TODO: drop this function after migration to IR f/o generator will be complete (KT-64202)
private fun computeOverriddenUsingFir2IrFakeOverrideGenerator(): List<IrSimpleFunctionSymbol> {
if (firParent == null) return emptyList()
if (isFakeOverride && parent is Fir2IrLazyClass) {
fakeOverrideGenerator.calcBaseSymbolsForFakeOverrideFunction(
firParent, this, fir.symbol
)
fakeOverrideGenerator.getOverriddenSymbolsForFakeOverride(this)?.let {
assert(!it.contains(symbol)) { "Cannot add function $symbol to its own overriddenSymbols" }
return@lazyVar it
return it
}
}
fir.generateOverriddenFunctionSymbols(firParent)
return fir.generateOverriddenFunctionSymbols(firParent)
}
private fun computeOverriddenSymbolsForIrFakeOverrideGenerator(): List<IrSimpleFunctionSymbol> {
if (firParent == null || parent !is Fir2IrLazyClass) return emptyList()
val baseFunctionWithDispatchReceiverTag =
fakeOverrideGenerator.computeBaseSymbolsWithContainingClass(firParent, fir.symbol)
return baseFunctionWithDispatchReceiverTag.map { (symbol, dispatchReceiverLookupTag) ->
declarationStorage.getIrFunctionSymbol(symbol, dispatchReceiverLookupTag) as IrSimpleFunctionSymbol
}
}
override val initialSignatureFunction: IrFunction? by lazy {
@@ -19119,6 +19119,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -19119,6 +19119,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -19119,6 +19119,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -0,0 +1,32 @@
CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB INTERFACE name:JavaInterface modality:ABSTRACT visibility:public [fun] superTypes:[<root>.B; <root>.C; <root>.D]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.JavaInterface
FUN IR_EXTERNAL_JAVA_DECLARATION_STUB name:foo visibility:public modality:ABSTRACT <> ($this:<root>.JavaInterface) returnType:kotlin.Unit
overridden:
public abstract fun foo (): kotlin.Unit [fake_override] declared in <root>.B
public abstract fun foo (): kotlin.Unit [fake_override] declared in <root>.C
$this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name:<this> type:<root>.JavaInterface
FUN IR_EXTERNAL_JAVA_DECLARATION_STUB name:bar visibility:public modality:ABSTRACT <> ($this:<root>.JavaInterface) returnType:kotlin.Unit
overridden:
public abstract fun bar (): kotlin.Unit [fake_override] declared in <root>.B
public abstract fun bar (): kotlin.Unit [fake_override] declared in <root>.C
public abstract fun bar (): kotlin.Unit declared in <root>.D
$this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name:<this> type:<root>.JavaInterface
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>.B
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.C
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.D
$this: VALUE_PARAMETER FAKE_OVERRIDE 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>.B
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.C
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.D
$this: VALUE_PARAMETER FAKE_OVERRIDE 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>.B
public open fun toString (): kotlin.String [fake_override] declared in <root>.C
public open fun toString (): kotlin.String [fake_override] declared in <root>.D
$this: VALUE_PARAMETER FAKE_OVERRIDE name:<this> type:kotlin.Any
@@ -0,0 +1,32 @@
CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB INTERFACE name:JavaInterface modality:ABSTRACT visibility:public superTypes:[<root>.B; <root>.C; <root>.D]
$this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name:<this> type:<root>.JavaInterface
FUN IR_EXTERNAL_JAVA_DECLARATION_STUB name:bar visibility:public modality:ABSTRACT <> ($this:<root>.JavaInterface) returnType:kotlin.Unit
overridden:
public abstract fun bar (): kotlin.Unit [fake_override] declared in <root>.B
public abstract fun bar (): kotlin.Unit [fake_override] declared in <root>.C
public abstract fun bar (): kotlin.Unit declared in <root>.D
$this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name:<this> type:<root>.JavaInterface
FUN IR_EXTERNAL_JAVA_DECLARATION_STUB name:foo visibility:public modality:ABSTRACT <> ($this:<root>.JavaInterface) returnType:kotlin.Unit
overridden:
public abstract fun foo (): kotlin.Unit [fake_override] declared in <root>.B
public abstract fun foo (): kotlin.Unit [fake_override] declared in <root>.C
$this: VALUE_PARAMETER IR_EXTERNAL_JAVA_DECLARATION_STUB name:<this> type:<root>.JavaInterface
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>.B
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.C
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.D
$this: VALUE_PARAMETER FAKE_OVERRIDE name:<this> type:kotlin.Any
VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB 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>.B
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.C
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.D
$this: VALUE_PARAMETER FAKE_OVERRIDE 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>.B
public open fun toString (): kotlin.String [fake_override] declared in <root>.C
public open fun toString (): kotlin.String [fake_override] declared in <root>.D
$this: VALUE_PARAMETER FAKE_OVERRIDE name:<this> type:kotlin.Any
@@ -0,0 +1,95 @@
FILE fqName:<root> fileName:/base.kt
CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.A
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.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 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:B modality:ABSTRACT visibility:public superTypes:[<root>.A]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.A
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun bar (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.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 declared in <root>.A
$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>.A
$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>.A
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:C modality:ABSTRACT visibility:public superTypes:[<root>.A]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.A
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun bar (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.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 declared in <root>.A
$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>.A
$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>.A
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:D modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.D) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.D
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
FILE fqName:<root> fileName:/main.kt
FUN name:test visibility:public modality:FINAL <> (x:<root>.JavaInterface) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:<root>.JavaInterface
BLOCK_BODY
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.JavaInterface' type=kotlin.Unit origin=null
$this: GET_VAR 'x: <root>.JavaInterface declared in <root>.test' type=<root>.JavaInterface origin=null
CALL 'public abstract fun bar (): kotlin.Unit declared in <root>.JavaInterface' type=kotlin.Unit origin=null
$this: GET_VAR 'x: <root>.JavaInterface declared in <root>.test' type=<root>.JavaInterface origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="OK"
@@ -0,0 +1,95 @@
FILE fqName:<root> fileName:/base.kt
CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.A
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.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 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:B modality:ABSTRACT visibility:public superTypes:[<root>.A]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.A
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun bar (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.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 declared in <root>.A
$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>.A
$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>.A
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:C modality:ABSTRACT visibility:public superTypes:[<root>.A]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.A
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun bar (): kotlin.Unit declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.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 declared in <root>.A
$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>.A
$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>.A
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:D modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.D) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.D
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
FILE fqName:<root> fileName:/main.kt
FUN name:test visibility:public modality:FINAL <> (x:<root>.JavaInterface) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:<root>.JavaInterface
BLOCK_BODY
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.JavaInterface' type=kotlin.Unit origin=null
$this: GET_VAR 'x: <root>.JavaInterface declared in <root>.test' type=<root>.JavaInterface origin=null
CALL 'public abstract fun bar (): kotlin.Unit declared in <root>.JavaInterface' type=kotlin.Unit origin=null
$this: GET_VAR 'x: <root>.JavaInterface declared in <root>.test' type=<root>.JavaInterface origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="OK"
@@ -0,0 +1,33 @@
// TARGET_BACKEND: JVM_IR
// DUMP_IR
// DUMP_EXTERNAL_CLASS: JavaInterface
// FILE: base.kt
interface A {
fun foo()
fun bar()
}
interface B : A
interface C : A
interface D {
fun bar()
}
// FILE: JavaInterface.java
public interface JavaInterface extends B, C, D {
public void foo();
public void bar();
}
// FILE: main.kt
fun test(x: JavaInterface) {
x.foo()
x.bar()
}
fun box(): String = "OK"
@@ -19119,6 +19119,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -19119,6 +19119,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@Test
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
@@ -15901,6 +15901,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fakeOverride"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("complexOverriddensInLazyFunctions.kt")
public void testComplexOverriddensInLazyFunctions() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/complexOverriddensInLazyFunctions.kt");
}
@TestMetadata("diamondFunction.kt")
public void testDiamondFunction() throws Exception {
runTest("compiler/testData/codegen/box/fakeOverride/diamondFunction.kt");