[FIR] Replace single supertype scope with list of scopes of supertypes in use site scopes
This big refactoring is needed to cleanup building of overrides
mappings and prevent creating redundant intersection overrides in
cases when there is no need in them:
```kotlin
interface A {
fun foo()
}
interface B {
fun foo()
}
interface C : A, B {
override fun foo()
}
```
Before this refactoring there was next override tree:
C.foo
intersection override (A.foo, B.foo)
A.foo
B.foo
Also this commit fixes special mapping of overrides in jvm scopes
for declarations which have kotlin builtins in supertypes with
special java mapping rules (collections, for example)
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
FILE fqName:<root> fileName:/kt45853.kt
|
||||
CLASS CLASS name:A modality:ABSTRACT 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> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any]'
|
||||
PROPERTY name:a visibility:public modality:ABSTRACT [val]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:ABSTRACT <> ($this:<root>.A) returnType:<root>.A?
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:ABSTRACT [val]
|
||||
$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 CLASS name:B modality:FINAL visibility:public superTypes:[<root>.AX]
|
||||
$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> () [primary] declared in <root>.AX'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[<root>.AX]'
|
||||
FUN name:getA visibility:public modality:FINAL <> ($this:<root>.B) returnType:<root>.X?
|
||||
overridden:
|
||||
public abstract fun getA (): @[FlexibleNullability] <root>.X? [fake_override] declared in <root>.AX
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.B
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun getA (): <root>.X? declared in <root>.B'
|
||||
CALL 'public open fun <get-a> (): @[FlexibleNullability] <root>.AX? declared in <root>.AX' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:AX modality:ABSTRACT visibility:public superTypes:[<root>.A; <root>.X]' type=@[FlexibleNullability] <root>.AX? origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.B declared in <root>.B.getA' type=<root>.B origin=null
|
||||
PROPERTY FAKE_OVERRIDE name:a visibility:public modality:OPEN [fake_override,val]
|
||||
overridden:
|
||||
public open a: @[FlexibleNullability] <root>.AX? [val]
|
||||
FUN FAKE_OVERRIDE name:<get-a> visibility:public modality:OPEN <> ($this:<root>.AX) returnType:@[FlexibleNullability] <root>.AX? [fake_override]
|
||||
annotations:
|
||||
Override
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:a visibility:public modality:OPEN [fake_override,val]
|
||||
overridden:
|
||||
public open fun <get-a> (): @[FlexibleNullability] <root>.AX? declared in <root>.AX
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.AX
|
||||
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>.AX
|
||||
$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>.AX
|
||||
$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>.AX
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
@@ -1,5 +1,4 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// SKIP_KT_DUMP
|
||||
// DUMP_EXTERNAL_CLASS: X
|
||||
// DUMP_EXTERNAL_CLASS: AX
|
||||
@@ -9,8 +8,6 @@ abstract class A {
|
||||
abstract val a: A?
|
||||
}
|
||||
|
||||
//Fir doesn't treat B.getA as an override, because it is not return-type compatible with AX.getA
|
||||
// Which might be correct behaivour. So disable fir till KT-46042
|
||||
class B() : AX() {
|
||||
override fun getA(): X? = super.a
|
||||
}
|
||||
|
||||
+12
@@ -9,6 +9,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:add visibility:public modality:OPEN <> ($this:<root>.Impl, element:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun add (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun add (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:element index:0 type:@[FlexibleNullability] kotlin.String?
|
||||
BLOCK_BODY
|
||||
@@ -20,6 +21,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:addAll visibility:public modality:OPEN <> ($this:<root>.Impl, elements:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun addAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun addAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>
|
||||
BLOCK_BODY
|
||||
@@ -31,6 +33,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:clear visibility:public modality:OPEN <> ($this:<root>.Impl) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun clear (): kotlin.Unit [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun clear (): kotlin.Unit [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun clear (): kotlin.Unit [fake_override] declared in <root>.Foo.B' type=kotlin.Unit origin=null
|
||||
@@ -39,6 +42,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:iterator visibility:public modality:OPEN <> ($this:<root>.Impl) returnType:kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [operator]
|
||||
overridden:
|
||||
public abstract fun iterator (): kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [fake_override,operator] declared in <root>.Foo.A
|
||||
public abstract fun iterator (): kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [fake_override,operator] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun iterator (): kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [operator] declared in <root>.Impl'
|
||||
@@ -48,6 +52,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:remove visibility:public modality:OPEN <> ($this:<root>.Impl, element:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun remove (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun remove (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:element index:0 type:@[FlexibleNullability] kotlin.String?
|
||||
BLOCK_BODY
|
||||
@@ -59,6 +64,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:removeAll visibility:public modality:OPEN <> ($this:<root>.Impl, elements:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun removeAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun removeAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>
|
||||
BLOCK_BODY
|
||||
@@ -70,6 +76,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:retainAll visibility:public modality:OPEN <> ($this:<root>.Impl, elements:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun retainAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun retainAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>
|
||||
BLOCK_BODY
|
||||
@@ -81,6 +88,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:contains visibility:public modality:OPEN <> ($this:<root>.Impl, element:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Boolean [operator]
|
||||
overridden:
|
||||
public abstract fun contains (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override,operator] declared in <root>.Foo.A
|
||||
public abstract fun contains (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override,operator] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:element index:0 type:@[FlexibleNullability] kotlin.String?
|
||||
BLOCK_BODY
|
||||
@@ -92,6 +100,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:containsAll visibility:public modality:OPEN <> ($this:<root>.Impl, elements:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun containsAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun containsAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>
|
||||
BLOCK_BODY
|
||||
@@ -103,6 +112,7 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
FUN DELEGATED_MEMBER name:isEmpty visibility:public modality:OPEN <> ($this:<root>.Impl) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun isEmpty (): kotlin.Boolean declared in <root>.Impl'
|
||||
@@ -112,10 +122,12 @@ FILE fqName:<root> fileName:/DelegationAndInheritanceFromJava.kt
|
||||
PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val]
|
||||
overridden:
|
||||
public abstract size: kotlin.Int [fake_override,val]
|
||||
public abstract size: kotlin.Int [fake_override,val]
|
||||
FUN DELEGATED_MEMBER name:<get-size> visibility:public modality:OPEN <> ($this:<root>.Impl) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val]
|
||||
overridden:
|
||||
public abstract fun <get-size> (): kotlin.Int [fake_override] declared in <root>.Foo.A
|
||||
public abstract fun <get-size> (): kotlin.Int [fake_override] declared in <root>.Foo.B
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun <get-size> (): kotlin.Int declared in <root>.Impl'
|
||||
|
||||
@@ -154,6 +154,7 @@ FILE fqName:<root> fileName:/ImplicitReceiverStack.kt
|
||||
FUN name:iterator visibility:public modality:FINAL <> ($this:<root>.PersistentImplicitReceiverStack) returnType:kotlin.collections.Iterator<<root>.ImplicitReceiverValue<*>> [operator]
|
||||
overridden:
|
||||
public abstract fun iterator (): kotlin.collections.Iterator<<root>.ImplicitReceiverValue<*>> [fake_override,operator] declared in <root>.ImplicitReceiverStack
|
||||
public abstract fun iterator (): kotlin.collections.Iterator<T of kotlin.collections.Iterable> [operator] declared in kotlin.collections.Iterable
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.PersistentImplicitReceiverStack
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun iterator (): kotlin.collections.Iterator<<root>.ImplicitReceiverValue<*>> [operator] declared in <root>.PersistentImplicitReceiverStack'
|
||||
|
||||
@@ -378,9 +378,9 @@ FILE fqName:<root> fileName:/MultiList.kt
|
||||
public open fun sort (p0: @[FlexibleNullability] java.util.Comparator<in @[FlexibleNullability] E of java.util.ArrayList?>?): kotlin.Unit declared in java.util.ArrayList
|
||||
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
|
||||
VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.Comparator<in @[FlexibleNullability] <root>.Some<T of <root>.SomeList>?>?
|
||||
FUN FAKE_OVERRIDE name:removeAt visibility:public modality:OPEN <> ($this:java.util.ArrayList<E of java.util.ArrayList>, p0:kotlin.Int) returnType:@[EnhancedNullability] <root>.Some<T of <root>.SomeList> [fake_override]
|
||||
FUN FAKE_OVERRIDE name:removeAt visibility:public modality:OPEN <> ($this:java.util.ArrayList<E of java.util.ArrayList>, p0:kotlin.Int) returnType:@[EnhancedNullability] <root>.Some<T of <root>.SomeList> [fake_override,operator]
|
||||
overridden:
|
||||
public open fun removeAt (p0: kotlin.Int): @[EnhancedNullability] E of java.util.ArrayList declared in java.util.ArrayList
|
||||
public open fun removeAt (p0: kotlin.Int): @[EnhancedNullability] E of java.util.ArrayList [operator] declared in java.util.ArrayList
|
||||
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
|
||||
CLASS CLASS name:FinalList modality:FINAL visibility:public superTypes:[<root>.SomeList<kotlin.String>]
|
||||
@@ -572,8 +572,8 @@ FILE fqName:<root> fileName:/MultiList.kt
|
||||
public open fun sort (p0: @[FlexibleNullability] java.util.Comparator<in @[FlexibleNullability] <root>.Some<T of <root>.SomeList>?>?): kotlin.Unit [fake_override] declared in <root>.SomeList
|
||||
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
|
||||
VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.Comparator<in @[FlexibleNullability] <root>.Some<kotlin.String>?>?
|
||||
FUN FAKE_OVERRIDE name:removeAt visibility:public modality:OPEN <> ($this:java.util.ArrayList<E of java.util.ArrayList>, p0:kotlin.Int) returnType:@[EnhancedNullability] <root>.Some<kotlin.String> [fake_override]
|
||||
FUN FAKE_OVERRIDE name:removeAt visibility:public modality:OPEN <> ($this:java.util.ArrayList<E of java.util.ArrayList>, p0:kotlin.Int) returnType:@[EnhancedNullability] <root>.Some<kotlin.String> [fake_override,operator]
|
||||
overridden:
|
||||
public open fun removeAt (p0: kotlin.Int): @[EnhancedNullability] <root>.Some<T of <root>.SomeList> [fake_override] declared in <root>.SomeList
|
||||
public open fun removeAt (p0: kotlin.Int): @[EnhancedNullability] <root>.Some<T of <root>.SomeList> [fake_override,operator] declared in <root>.SomeList
|
||||
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<E of java.util.ArrayList>
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
|
||||
|
||||
Reference in New Issue
Block a user