[FIR2IR] Properly handle intersection types in interface delegation

The changes to the irText test data result in the fact that we
now unconditionally unwrap substitution overrides of delegation targets
whereas before we built an unsubstituted scope of the type we delegate
to. If we delegate to a class A : B<C>, the unsubstituted scope of
A can still contain substitution overrides for inherited generic methods
from B<T> that we didn't unwrap before but do unwrap now.

#KT-57899 Fixed
This commit is contained in:
Kirill Rakhman
2023-04-12 14:54:53 +02:00
committed by Space Team
parent cda7dc4a3a
commit e80b4c530d
33 changed files with 793 additions and 67 deletions
@@ -0,0 +1,149 @@
FILE fqName:<root> fileName:/delegationToIntersectionType.kt
FUN name:select visibility:public modality:FINAL <T> (a:T of <root>.select, b:T of <root>.select) returnType:T of <root>.select
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:a index:0 type:T of <root>.select
VALUE_PARAMETER name:b index:1 type:T of <root>.select
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun select <T> (a: T of <root>.select, b: T of <root>.select): T of <root>.select declared in <root>'
GET_VAR 'a: T of <root>.select declared in <root>.select' type=T of <root>.select origin=null
CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER 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 [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.B) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.B
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.A; <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> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.C
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.C'
CONST String type=kotlin.String value="OK"
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>.A
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] 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 [fake_override] declared in <root>.A
public open fun hashCode (): kotlin.Int [fake_override] 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 [fake_override] declared in <root>.A
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.D) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.D
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.D'
CONST String type=kotlin.String value="FAIL"
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>.A
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] 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 [fake_override] declared in <root>.A
public open fun hashCode (): kotlin.Int [fake_override] 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 [fake_override] declared in <root>.A
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test visibility:public modality:FINAL <> (c:<root>.C, d:<root>.D) returnType:kotlin.String
VALUE_PARAMETER name:c index:0 type:<root>.C
VALUE_PARAMETER name:d index:1 type:<root>.D
BLOCK_BODY
VAR name:intersection type:<root>.A [val]
CALL 'public final fun select <T> (a: T of <root>.select, b: T of <root>.select): T of <root>.select declared in <root>' type=<root>.A origin=null
<T>: <root>.A
a: GET_VAR 'c: <root>.C declared in <root>.test' type=<root>.C origin=null
b: GET_VAR 'd: <root>.D declared in <root>.test' type=<root>.D origin=null
RETURN type=kotlin.Nothing from='public final fun test (c: <root>.C, d: <root>.D): kotlin.String declared in <root>'
CALL 'public open fun foo (): kotlin.String declared in <root>.test.<no name provided>' type=kotlin.String origin=null
$this: BLOCK type=<root>.test.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.test.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.B]'
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.test.<no name provided>) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.test.<no name provided>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.test.<no name provided>'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.B' type=kotlin.String origin=null
$this: TYPE_OP type=<root>.B origin=IMPLICIT_CAST typeOperand=<root>.B
GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.A visibility:private [final]' type=<root>.A origin=null
receiver: GET_VAR '<this>: <root>.test.<no name provided> declared in <root>.test.<no name provided>.foo' type=<root>.test.<no name provided> origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.A visibility:private [final]
EXPRESSION_BODY
GET_VAR 'val intersection: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
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
$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 [fake_override] 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 [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.test.<no name provided>' type=<root>.test.<no name provided> origin=OBJECT_LITERAL
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>'
CALL 'public final fun test (c: <root>.C, d: <root>.D): kotlin.String declared in <root>' type=kotlin.String origin=null
c: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
d: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
@@ -0,0 +1,149 @@
FILE fqName:<root> fileName:/delegationToIntersectionType.kt
FUN name:select visibility:public modality:FINAL <T> (a:T of <root>.select, b:T of <root>.select) returnType:T of <root>.select
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:a index:0 type:T of <root>.select
VALUE_PARAMETER name:b index:1 type:T of <root>.select
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun select <T> (a: T of <root>.select, b: T of <root>.select): T of <root>.select declared in <root>'
GET_VAR 'a: T of <root>.select declared in <root>.select' type=T of <root>.select origin=null
CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER 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 [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.B) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.B
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.A; <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> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.C
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.C'
CONST String type=kotlin.String value="OK"
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>.A
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] 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 [fake_override] declared in <root>.A
public open fun hashCode (): kotlin.Int [fake_override] 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 [fake_override] declared in <root>.A
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.D) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.D
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.D'
CONST String type=kotlin.String value="FAIL"
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>.A
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] 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 [fake_override] declared in <root>.A
public open fun hashCode (): kotlin.Int [fake_override] 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 [fake_override] declared in <root>.A
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test visibility:public modality:FINAL <> (c:<root>.C, d:<root>.D) returnType:kotlin.String
VALUE_PARAMETER name:c index:0 type:<root>.C
VALUE_PARAMETER name:d index:1 type:<root>.D
BLOCK_BODY
VAR name:intersection type:kotlin.Any [val]
CALL 'public final fun select <T> (a: T of <root>.select, b: T of <root>.select): T of <root>.select declared in <root>' type=kotlin.Any origin=null
<T>: kotlin.Any
a: GET_VAR 'c: <root>.C declared in <root>.test' type=<root>.C origin=null
b: GET_VAR 'd: <root>.D declared in <root>.test' type=<root>.D origin=null
RETURN type=kotlin.Nothing from='public final fun test (c: <root>.C, d: <root>.D): kotlin.String declared in <root>'
CALL 'public open fun foo (): kotlin.String declared in <root>.test.<no name provided>' type=kotlin.String origin=null
$this: BLOCK type=<root>.test.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.test.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.B]'
FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final]
EXPRESSION_BODY
GET_VAR 'val intersection: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.test.<no name provided>) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.test.<no name provided>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.test.<no name provided>'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.B' type=kotlin.String origin=null
$this: TYPE_OP type=<root>.B origin=IMPLICIT_CAST typeOperand=<root>.B
GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
receiver: GET_VAR '<this>: <root>.test.<no name provided> declared in <root>.test.<no name provided>.foo' type=<root>.test.<no name provided> origin=null
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
$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 [fake_override] 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 [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.test.<no name provided>' type=<root>.test.<no name provided> origin=OBJECT_LITERAL
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>'
CALL 'public final fun test (c: <root>.C, d: <root>.D): kotlin.String declared in <root>' type=kotlin.String origin=null
c: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
d: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
@@ -0,0 +1,21 @@
// DUMP_IR
fun <T> select(a: T, b: T) : T = a
interface A
interface B {
fun foo(): String
}
class C : A, B {
override fun foo() = "OK"
}
class D : A, B {
override fun foo() = "FAIL"
}
fun test(c: C, d: D): String {
val intersection = select(c, d)
return object: B by intersection {}.foo()
}
fun box() = test(C(), D())
@@ -0,0 +1,154 @@
FILE fqName:<root> fileName:/delegationToIntersectionType2.kt
FUN name:select visibility:public modality:FINAL <T> (a:T of <root>.select, b:T of <root>.select) returnType:T of <root>.select
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
VALUE_PARAMETER name:a index:0 type:T of <root>.select
VALUE_PARAMETER name:b index:1 type:T of <root>.select
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun select <T> (a: T of <root>.select, b: T of <root>.select): T of <root>.select declared in <root>'
GET_VAR 'a: T of <root>.select declared in <root>.select' type=T of <root>.select origin=null
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.Any
$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 [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.B) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.B
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.A; <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> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.Any declared in <root>.A
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.C
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.C'
CONST String type=kotlin.String value="OK"
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>.A
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] 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 [fake_override] declared in <root>.A
public open fun hashCode (): kotlin.Int [fake_override] 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 [fake_override] declared in <root>.A
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.A; <root>.B]'
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.D) returnType:kotlin.String
overridden:
public abstract fun foo (): kotlin.Any declared in <root>.A
public abstract fun foo (): kotlin.String declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:<root>.D
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.D'
CONST String type=kotlin.String value="FAIL"
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>.A
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] 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 [fake_override] declared in <root>.A
public open fun hashCode (): kotlin.Int [fake_override] 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 [fake_override] declared in <root>.A
public open fun toString (): kotlin.String [fake_override] declared in <root>.B
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test visibility:public modality:FINAL <> (c:<root>.C, d:<root>.D) returnType:kotlin.String
VALUE_PARAMETER name:c index:0 type:<root>.C
VALUE_PARAMETER name:d index:1 type:<root>.D
BLOCK_BODY
VAR name:intersection type:<root>.A [val]
CALL 'public final fun select <T> (a: T of <root>.select, b: T of <root>.select): T of <root>.select declared in <root>' type=<root>.A origin=null
<T>: <root>.A
a: GET_VAR 'c: <root>.C declared in <root>.test' type=<root>.C origin=null
b: GET_VAR 'd: <root>.D declared in <root>.test' type=<root>.D origin=null
RETURN type=kotlin.Nothing from='public final fun test (c: <root>.C, d: <root>.D): kotlin.String declared in <root>'
CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null
$this: CALL 'public open fun foo (): kotlin.Any declared in <root>.test.<no name provided>' type=kotlin.Any origin=null
$this: BLOCK type=<root>.test.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.A]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.test.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.A]'
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.test.<no name provided>) returnType:kotlin.Any
overridden:
public abstract fun foo (): kotlin.Any declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:<root>.test.<no name provided>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.Any declared in <root>.test.<no name provided>'
CALL 'public abstract fun foo (): kotlin.String declared in <root>.B' type=kotlin.String origin=null
$this: TYPE_OP type=<root>.B origin=IMPLICIT_CAST typeOperand=<root>.B
GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.A visibility:private [final]' type=<root>.A origin=null
receiver: GET_VAR '<this>: <root>.test.<no name provided> declared in <root>.test.<no name provided>.foo' type=<root>.test.<no name provided> origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.A visibility:private [final]
EXPRESSION_BODY
GET_VAR 'val intersection: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
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>.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 [fake_override] 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 [fake_override] declared in <root>.A
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.test.<no name provided>' type=<root>.test.<no name provided> origin=OBJECT_LITERAL
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>'
CALL 'public final fun test (c: <root>.C, d: <root>.D): kotlin.String declared in <root>' type=kotlin.String origin=null
c: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
d: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.D' type=<root>.D origin=null
@@ -0,0 +1,26 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K1: ANY
// DUMP_IR
// K1_STATUS: java.lang.AssertionError: There is still an unbound symbol after generation of IR module <main>
fun <T> select(a: T, b: T) : T = a
interface A {
fun foo(): Any
}
interface B {
fun foo(): String
}
class C : A, B {
override fun foo() = "OK"
}
class D : A, B {
override fun foo() = "FAIL"
}
fun test(c: C, d: D): String {
val intersection = select(c, d)
return object: A by intersection {}.foo().toString()
}
fun box() = test(C(), D())
@@ -0,0 +1,12 @@
interface DosFileAttributeView {
fun bar(): String
}
fun <V> foo(view: V): DosFileAttributeView {
view as DosFileAttributeView
return object : DosFileAttributeView by view {}
}
fun box() = foo(object : DosFileAttributeView {
override fun bar() = "OK"
}).bar()
@@ -203,7 +203,7 @@ FILE fqName:<root> fileName:/delegatedPropertyWithMultipleOverriddens_generics.k
$this: VALUE_PARAMETER name:<this> type:<root>.MC
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.MC'
CALL 'public open fun foo (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=kotlin.String origin=null
CALL 'public open fun foo (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=E6 of <root>.MyArrayList origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.MyArrayList<kotlin.String> visibility:private [final]' type=<root>.MyArrayList<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.MC declared in <root>.MC.foo' type=<root>.MC origin=null
PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val]
@@ -216,7 +216,7 @@ FILE fqName:<root> fileName:/delegatedPropertyWithMultipleOverriddens_generics.k
$this: VALUE_PARAMETER name:<this> type:<root>.MC
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-bar> (): kotlin.String declared in <root>.MC'
CALL 'public open fun <get-bar> (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=kotlin.String origin=null
CALL 'public open fun <get-bar> (): E6 of <root>.MyArrayList declared in <root>.MyArrayList' type=E6 of <root>.MyArrayList origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.MyArrayList<kotlin.String> visibility:private [final]' type=<root>.MyArrayList<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.MC declared in <root>.MC.<get-bar>' type=<root>.MC origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.MyArrayList<kotlin.String> visibility:private [final]