[FIR2IR] Make all source sets friends for IrFakeOverrideBuilder

^KT-63644
This commit is contained in:
Pavel Kunyavskiy
2023-12-04 16:34:49 +01:00
committed by Space Team
parent 60d77fbb90
commit 8e047e6d8a
13 changed files with 319 additions and 4 deletions
@@ -0,0 +1,198 @@
FILE fqName:<root> fileName:/common.kt
CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]
$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 kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]'
FUN name:foo1 visibility:internal modality:OPEN <> ($this:<root>.A) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal open fun foo1 (): kotlin.String declared in <root>.A'
CONST String type=kotlin.String value="A::foo1"
FUN name:foo2 visibility:internal modality:OPEN <> ($this:<root>.A) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal open fun foo2 (): kotlin.String declared in <root>.A'
CONST String type=kotlin.String value="A::foo2"
FUN name:foo3 visibility:internal modality:OPEN <> ($this:<root>.A) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.A
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal open fun foo3 (): kotlin.String declared in <root>.A'
CONST String type=kotlin.String value="A::foo3"
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:C modality:OPEN visibility:public superTypes:[<root>.B]
$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 <root>.B'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:OPEN visibility:public superTypes:[<root>.B]'
FUN name:foo1 visibility:internal modality:OPEN <> ($this:<root>.C) returnType:kotlin.String
overridden:
internal open fun foo1 (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.C
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal open fun foo1 (): kotlin.String declared in <root>.C'
CONST String type=kotlin.String value="C::foo1"
FUN FAKE_OVERRIDE name:foo2 visibility:internal modality:OPEN <> ($this:<root>.B) returnType:kotlin.String [fake_override]
overridden:
internal open fun foo2 (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.B
FUN FAKE_OVERRIDE name:foo3 visibility:internal modality:OPEN <> ($this:<root>.A) returnType:kotlin.String [fake_override]
overridden:
internal open fun foo3 (): kotlin.String declared in <root>.B
$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>.B
$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>.B
$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>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FILE fqName:<root> fileName:/main.kt
CLASS CLASS name:B modality:OPEN visibility:public superTypes:[<root>.A]
$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> () declared in <root>.A'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public superTypes:[<root>.A]'
FUN name:foo1 visibility:internal modality:OPEN <> ($this:<root>.B) returnType:kotlin.String
overridden:
internal open fun foo1 (): kotlin.String declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.B
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal open fun foo1 (): kotlin.String declared in <root>.B'
CONST String type=kotlin.String value="B::foo1"
FUN name:foo2 visibility:internal modality:OPEN <> ($this:<root>.B) returnType:kotlin.String
overridden:
internal open fun foo2 (): kotlin.String declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.B
BLOCK_BODY
RETURN type=kotlin.Nothing from='internal open fun foo2 (): kotlin.String declared in <root>.B'
CONST String type=kotlin.String value="B::foo2"
FUN FAKE_OVERRIDE name:foo3 visibility:internal modality:OPEN <> ($this:<root>.A) returnType:kotlin.String [fake_override]
overridden:
internal open fun foo3 (): kotlin.String 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
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
VAR name:a type:<root>.A [val]
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A' type=<root>.A origin=null
VAR name:b type:<root>.A [val]
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.B' type=<root>.B origin=null
VAR name:c type:<root>.A [val]
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.C' type=<root>.C origin=null
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo1 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val a: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="A::foo1"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail A.1"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo2 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val a: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="A::foo2"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail A.2"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo3 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val a: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="A::foo3"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail A.3"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo1 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val b: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="B::foo1"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail B.1"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo2 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val b: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="B::foo2"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail B.2"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo3 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val b: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="A::foo3"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail B.3"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo1 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val c: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="C::foo1"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail C.1"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo2 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val c: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="B::foo2"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail C.2"
WHEN type=kotlin.Unit origin=IF
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: CALL 'internal open fun foo3 (): kotlin.String declared in <root>.A' type=kotlin.String origin=null
$this: GET_VAR 'val c: <root>.A declared in <root>.box' type=<root>.A origin=null
arg1: CONST String type=kotlin.String value="A::foo3"
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="Fail C.3"
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="OK"
@@ -0,0 +1,47 @@
// LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS, JS_IR, JS_IR_ES6, WASM
// DUMP_IR
// MODULE: common
// FILE: common.kt
open class A {
internal open fun foo1() = "A::foo1"
internal open fun foo2() = "A::foo2"
internal open fun foo3() = "A::foo3"
}
expect open class B() : A {
internal override fun foo1(): String
internal override fun foo2(): String
}
open class C : B() {
internal override fun foo1() = "C::foo1"
}
// MODULE: main()()(common)
// FILE: main.kt
actual open class B actual constructor() : A() {
internal actual override fun foo1() = "B::foo1"
internal actual override fun foo2() = "B::foo2"
}
fun box() : String {
val a: A = A()
val b: A = B()
val c: A = C()
if (a.foo1() != "A::foo1") return "Fail A.1"
if (a.foo2() != "A::foo2") return "Fail A.2"
if (a.foo3() != "A::foo3") return "Fail A.3"
if (b.foo1() != "B::foo1") return "Fail B.1"
if (b.foo2() != "B::foo2") return "Fail B.2"
if (b.foo3() != "A::foo3") return "Fail B.3"
if (c.foo1() != "C::foo1") return "Fail C.1"
if (c.foo2() != "B::foo2") return "Fail C.2"
if (c.foo3() != "A::foo3") return "Fail C.3"
return "OK"
}