[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:
Dmitriy Novozhilov
2022-01-13 18:22:42 +03:00
parent 17916d4a63
commit c80cfb0fdb
82 changed files with 2564 additions and 636 deletions
@@ -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'