[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
@@ -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"