[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
@@ -0,0 +1,22 @@
FILE: explicitOverrideOfTwoMembers.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface B : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface C : R|A|, R|B| {
public abstract override fun foo(): R|kotlin/Any|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
@@ -0,0 +1,16 @@
// SCOPE_DUMP: C:foo;x
interface A {
fun foo(): Any
val x: Any
}
interface B {
fun foo(): Any
val x: Any
}
interface C : A, B {
override fun foo(): Any
override val x: Any
}
@@ -0,0 +1,8 @@
C:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /B [id: 2]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /B [id: 2]
@@ -0,0 +1,26 @@
FILE: lib.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Int|
public get(): R|kotlin/Int|
public abstract val y: R|kotlin/Int|
public get(): R|kotlin/Int|
}
public abstract interface B : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/String|
public get(): R|kotlin/String|
public abstract val y: R|kotlin/Int|
public get(): R|kotlin/Int|
}
FILE: main.kt
public final fun test(d: R|D|): R|kotlin/Unit| {
lval a: R|kotlin/Int| = R|<local>/d|.R|/C.x|
lval b: R|kotlin/Int| = R|<local>/d|.R|/D.y|
}
@@ -0,0 +1,42 @@
// SCOPE_DUMP: C:foo;x;y;getX, D:x;y;getX, E:x;getX
// FILE: lib.kt
interface A {
fun foo(): Any
val x: Int
val y: Int
}
interface B {
fun foo(): Any
val x: String
val y: Int
}
// FILE: C.java
public abstract class C {
public int x;
private int y;
}
// FILE: D.java
public abstract class D extends C implements A, B {
public abstract Object foo();
public abstract Object getX();
public abstract int getY();
}
// FILE: E.java
public abstract class E implements A, B {
public abstract Object foo();
public abstract Object getX();
}
// FILE: main.kt
fun test(d: D) {
val a = d.x
val b = d.y
}
@@ -0,0 +1,21 @@
C:
[Java]: public open field x: R|kotlin/Int| from Java enhancement scope for /C [id: 0]
[Java]: private open field y: R|kotlin/Int| from Java enhancement scope for /C [id: 0]
D:
[Java]: public open field x: R|kotlin/Int| from Java enhancement scope for /D [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Int| from Java enhancement scope for /D [id: 0]
[Source]: public abstract val x: R|kotlin/Int| from Use site scope of /A [id: 1]
[Source]: public abstract val x: R|kotlin/String| from Use site scope of /B [id: 2]
[Java]: private open field y: R|kotlin/Int| from Java enhancement scope for /D [id: 0]
[Synthetic]: public abstract val y: R|kotlin/Int| from Java enhancement scope for /D [id: 0]
[Source]: public abstract val y: R|kotlin/Int| from Use site scope of /A [id: 1]
[Source]: public abstract val y: R|kotlin/Int| from Use site scope of /B [id: 2]
[Enhancement]: public abstract fun getX(): R|ft<kotlin/Any, kotlin/Any?>| from Java enhancement scope for /D [id: 0]
E:
[IntersectionOverride]: public abstract val x: R|kotlin/Int| from Java enhancement scope for /E [id: 0]
[Source]: public abstract val x: R|kotlin/Int| from Use site scope of /A [id: 1]
[Source]: public abstract val x: R|kotlin/String| from Use site scope of /B [id: 2]
[Enhancement]: public abstract fun getX(): R|ft<kotlin/Any, kotlin/Any?>| from Java enhancement scope for /E [id: 0]
@@ -0,0 +1,24 @@
FILE: B.kt
public abstract class B : R|A| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
private final val foo: R|kotlin/Int| = Int(1)
private get(): R|kotlin/Int|
public open override fun getFoo(): R|kotlin/String| {
^getFoo String(foo)
}
}
FILE: main.kt
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
}
public final fun test(d: R|D|): R|kotlin/Unit| {
R|<local>/d|.R|/B.foo|.R|kotlin/String.length|
}
@@ -0,0 +1,22 @@
// SCOPE_DUMP: A:getFoo, B:getFoo, C:getFoo, D:getFoo
// FILE: A.java
public interface A {
String getFoo();
}
// FILE: B.kt
abstract class B : A {
private val foo: Int = 1
override fun getFoo(): String = "foo"
}
// FILE: C.java
public abstract class C extends B implements A {}
// FILE: main.kt
class D : C()
fun test(d: D) {
d.foo.length
}
@@ -0,0 +1,15 @@
A:
[Enhancement]: public abstract fun getFoo(): R|ft<kotlin/String, kotlin/String?>| from Java enhancement scope for /A [id: 0]
B:
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /B [id: 0]
[Enhancement]: public abstract fun getFoo(): R|ft<kotlin/String, kotlin/String?>| from Java enhancement scope for /A [id: 1]
C:
[Source]: public open override fun getFoo(): R|kotlin/String| from Java enhancement scope for /C [id: 0]
[Enhancement]: public abstract fun getFoo(): R|ft<kotlin/String, kotlin/String?>| from Java enhancement scope for /A [id: 1]
D:
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /D [id: 0]
[Enhancement]: public abstract fun getFoo(): R|ft<kotlin/String, kotlin/String?>| from Java enhancement scope for /A [id: 1]
@@ -0,0 +1,24 @@
FILE: intersectionOverrideOfTwoMembers.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface B : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface C : R|A|, R|B| {
}
public abstract interface D : R|C| {
public abstract override fun foo(): R|kotlin/Any|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
@@ -0,0 +1,18 @@
// SCOPE_DUMP: C:foo;x, D:foo;x
interface A {
fun foo(): Any
val x: Any
}
interface B {
fun foo(): Any
val x: Any
}
interface C : A, B
interface D : C {
override fun foo(): Any
override val x: Any
}
@@ -0,0 +1,18 @@
C:
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /B [id: 2]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /B [id: 2]
D:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /D [id: 0]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /D [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /B [id: 3]
@@ -0,0 +1,24 @@
FILE: intersectionOverrideOfTwoMembers_java.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface B : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface C : R|A|, R|B| {
}
public abstract interface D : R|C| {
public abstract override fun foo(): R|kotlin/Any|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
@@ -0,0 +1,18 @@
// SCOPE_DUMP: C:foo;x, D:foo;x
interface A {
fun foo(): Any
val x: Any
}
interface B {
fun foo(): Any
val x: Any
}
interface C : A, B
interface D : C {
override fun foo(): Any
override val x: Any
}
@@ -0,0 +1,17 @@
C:
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /B [id: 2]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /B [id: 2]
D:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /D [id: 0]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /D [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /B [id: 3]
@@ -0,0 +1,13 @@
FILE: B.kt
public abstract interface B : R|kotlin/Any| {
public abstract val foo: R|kotlin/Int|
public get(): R|kotlin/Int|
}
FILE: main.kt
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
}
@@ -0,0 +1,18 @@
// SCOPE_DUMP: C:foo;getFoo
// FILE: A.java
public abstract class A {
public int getFoo() {
return 42;
}
}
// FILE: B.kt
interface B {
val foo: Int
}
// FILE: C.java
public class C extends A implements B {}
// FILE: main.kt
class D : C()
@@ -0,0 +1,4 @@
C:
[Synthetic]: public open val foo: R|kotlin/Int| from Java enhancement scope for /C [id: 0]
[Source]: public abstract val foo: R|kotlin/Int| from Use site scope of /B [id: 1]
@@ -0,0 +1,24 @@
FILE: A.kt
public open class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public open fun getScope(): R|kotlin/String?| {
^getScope Null(null)
}
public final fun setScope(scope: R|kotlin/String?|): R|A| {
^setScope this@R|/A|
}
protected final var scope: R|kotlin/String?| = Null(null)
protected get(): R|kotlin/String?|
protected set(value: R|kotlin/String?|): R|kotlin/Unit|
}
FILE: main.kt
public final fun test(b: R|B|): R|kotlin/Unit| {
lval s: R|kotlin/String?| = R|<local>/b|.R|/B.getScope|()
R|<local>/b|.R|/A.setScope|(R|<local>/s|)
}
@@ -0,0 +1,23 @@
// FILE: A.kt
open class A {
open fun getScope(): String? = null
fun setScope(scope: String?): A {
return this
}
protected var scope: String? = null
}
// FILE: B.java
public class B extends A {
@java.lang.Override
public String getScope() {
return null;
}
}
// FILE: main.kt
fun test(b: B) {
val s = b.getScope()
b.setScope(s)
}
@@ -0,0 +1,33 @@
FILE: noIntersectionOverrideOfTwoMembers.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface B : R|A| {
public abstract override fun foo(): R|kotlin/Any|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface C : R|A|, R|B| {
}
public abstract interface D : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Int|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface Explicit : R|C|, R|D| {
public abstract override fun foo(): R|kotlin/Int|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface Implicit : R|C|, R|D| {
}
@@ -0,0 +1,25 @@
// SCOPE_DUMP: C:foo;x, Explicit:foo;x, Implicit:foo;x
interface A {
fun foo(): Any
val x: Any
}
interface B : A {
override fun foo(): Any
override val x: Any
}
interface C : A, B
interface D {
fun foo(): Int
val x: Any
}
interface Explicit : C, D {
override fun foo(): Int
override val x: Any
}
interface Implicit : C, D
@@ -0,0 +1,26 @@
C:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
Explicit:
[Source]: public abstract override fun foo(): R|kotlin/Int| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
Implicit:
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[IntersectionOverride]: public abstract override val x: R|kotlin/Any| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
@@ -0,0 +1,33 @@
FILE: noIntersectionOverrideOfTwoMembers_java.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Any|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface B : R|A| {
public abstract override fun foo(): R|kotlin/Any|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface C : R|A|, R|B| {
}
public abstract interface D : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Int|
public abstract val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface Explicit : R|C|, R|D| {
public abstract override fun foo(): R|kotlin/Int|
public abstract override val x: R|kotlin/Any|
public get(): R|kotlin/Any|
}
public abstract interface Implicit : R|C|, R|D| {
}
@@ -0,0 +1,25 @@
// SCOPE_DUMP: C:foo;x, Explicit:foo;x, Implicit:foo;x
interface A {
fun foo(): Any
val x: Any
}
interface B : A {
override fun foo(): Any
override val x: Any
}
interface C : A, B
interface D {
fun foo(): Int
val x: Any
}
interface Explicit : C, D {
override fun foo(): Int
override val x: Any
}
interface Implicit : C, D
@@ -0,0 +1,25 @@
C:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
Explicit:
[Source]: public abstract override fun foo(): R|kotlin/Int| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
Implicit:
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[IntersectionOverride]: public abstract override val x: R|kotlin/Any| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
@@ -0,0 +1,23 @@
FILE: C.kt
public open class C : R|B<kotlin/Any?>| {
public constructor(name: R|kotlin/String|): R|C| {
super<R|kotlin/Any|>()
}
private final var name: R|kotlin/String| = R|<local>/name|
private get(): R|kotlin/String|
private set(value: R|kotlin/String|): R|kotlin/Unit|
public open override fun getName(): R|kotlin/String| {
^getName this@R|/C|.R|/C.name|
}
public open override fun setName(newName: R|kotlin/String|): R|kotlin/Any?| {
^setName Null(null)
}
}
FILE: main.kt
public final fun test(d: R|D|): R|kotlin/Unit| {
lval name: R|kotlin/String| = R|<local>/d|.R|/C.name|
}
@@ -0,0 +1,25 @@
// SCOPE_DUMP: C:getName;setName;name, D:getName;setName;name
// FILE: A.java
public interface A {
String getName();
}
// FILE: B.java
public interface B<T> extends A {
T setName(String newName);
}
// FILE: C.kt
open class C(private var name: String) : B<Any?> {
override fun getName(): String = name
override fun setName(newName: String): Any? = null
}
// FILE: D.java
public class D extends C {}
// FILE: main.kt
fun test(d: D) {
val name = d.name
}
@@ -0,0 +1,14 @@
C:
[Source]: public open override fun getName(): R|kotlin/String| from Use site scope of /C [id: 0]
[Enhancement]: public abstract fun getName(): R|ft<kotlin/String, kotlin/String?>| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
[Source]: public open override fun setName(newName: R|kotlin/String|): R|kotlin/Any?| from Use site scope of /C [id: 0]
[SubstitutionOverride]: public abstract fun setName(newName: R|ft<kotlin/String, kotlin/String?>|): R|kotlin/Any?| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
[Enhancement]: public abstract fun setName(newName: R|ft<kotlin/String, kotlin/String?>|): R|ft<T, T?>| from Java enhancement scope for /B [id: 2]
[Source]: private final var name: R|kotlin/String| = R|<local>/name| from Use site scope of /C [id: 0]
D:
[Source]: public open override fun getName(): R|kotlin/String| from Java enhancement scope for /D [id: 0]
[Enhancement]: public abstract fun getName(): R|ft<kotlin/String, kotlin/String?>| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
[Source]: private final var name: R|kotlin/String| = R|<local>/name| from Java enhancement scope for /D [id: 0]
[Source]: private final var name: R|kotlin/String| = R|<local>/name| from Use site scope of /C [id: 0]
@@ -0,0 +1,41 @@
// SCOPE_DUMP: Some:toByte;byteValue;toShort;shortValue;toInt;intValue;toLong;longValue MyNumber:toByte;byteValue
// FILE: MyBaseNumber.java
public interface MyBaseNumber {
byte byteValue(); // (1)
short shortValue(); // (1)
}
// FILE: MyNumber.java
public interface MyNumber extends MyBaseNumber {
@Override
byte byteValue(); // (2)
@Override
short shortValue(); // (1)
int intValue();
}
// FILE: Some.java
public abstract class Some extends Number implements MyNumber {
@Override
public abstract byte byteValue() // (3)
}
/*
* Some.toByte() (3', renamed) overrides Number.toByte & MyNumber.toByte(2', renamed)
* MyNumber.toByte(2', renamed) overrides ???
*/
fun test(some: Some) {
some.toByte()
some.toShort()
some.toInt()
some.toLong()
some.byteValue()
some.shortValue()
some.intValue()
some.longValue()
}
@@ -0,0 +1,18 @@
Some:
[Enhancement]: public abstract operator fun toByte(): R|kotlin/Byte| from Java enhancement scope for /Some [id: 0]
[Library]: public abstract fun toByte(): R|kotlin/Byte| from Use site scope of kotlin/Number [id: 1]
[RenamedForOverride]: public abstract fun toByte(): R|kotlin/Byte| from Java enhancement scope for /MyNumber [id: 2]
[Enhancement]: public abstract fun byteValue(): R|kotlin/Byte| from Java enhancement scope for /MyBaseNumber [id: 3]
[IntersectionOverride]: public abstract fun toShort(): R|kotlin/Short| from Java enhancement scope for /Some [id: 0]
[Library]: public abstract fun toShort(): R|kotlin/Short| from Use site scope of kotlin/Number [id: 1]
[RenamedForOverride]: public abstract fun toShort(): R|kotlin/Short| from Java enhancement scope for /MyNumber [id: 2]
[Enhancement]: public abstract fun shortValue(): R|kotlin/Short| from Java enhancement scope for /MyBaseNumber [id: 3]
[IntersectionOverride]: public abstract fun toInt(): R|kotlin/Int| from Java enhancement scope for /Some [id: 0]
[Library]: public abstract fun toInt(): R|kotlin/Int| from Use site scope of kotlin/Number [id: 1]
[RenamedForOverride]: public abstract fun toInt(): R|kotlin/Int| from Java enhancement scope for /MyNumber [id: 2]
[Library]: public abstract fun toLong(): R|kotlin/Long| from Java enhancement scope for /Some [id: 0]
MyNumber:
[Enhancement]: public abstract fun byteValue(): R|kotlin/Byte| from Java enhancement scope for /MyNumber [id: 0]
[Enhancement]: public abstract fun byteValue(): R|kotlin/Byte| from Java enhancement scope for /MyBaseNumber [id: 1]
@@ -0,0 +1,11 @@
FILE: main.kt
public final fun test(map: R|SomeMap<kotlin/Int, kotlin/String>|): R|kotlin/Unit| {
R|<local>/map|.R|SubstitutionOverride</SomeMap.containsKey: R|kotlin/Boolean|>|(Int(1))
R|<local>/map|.<Inapplicable(INAPPLICABLE): /SomeMap.containsKey>#(String())
R|<local>/map|.R|SubstitutionOverride</SomeMap.containsValue: R|kotlin/Boolean|>|(String())
R|<local>/map|.<Inapplicable(INAPPLICABLE): /SomeMap.containsValue>#(Int(1))
R|<local>/map|.R|SubstitutionOverride</SomeMap.get: R|kotlin/String?|>|(Int(1))
R|<local>/map|.<Inapplicable(INAPPLICABLE): /SomeMap.get>#(String())
R|<local>/map|.R|SubstitutionOverride</SomeMap.remove: R|kotlin/String?|>|(Int(1))
R|<local>/map|.<Inapplicable(INAPPLICABLE): /SomeMap.remove>#(String())
}
@@ -0,0 +1,42 @@
// SCOPE_DUMP: SomeMap:containsKey;containsValue;get;remove, MyMap:containsKey;containsValue;get
// FILE: MyBaseMap.java
public interface MyBaseMap<K1, V1> {
boolean containsKey(Object key);
}
// FILE: MyMap.java
public interface MyMap<K2, V2> extends MyBaseMap<K2, V2> {
@Override
boolean containsKey(Object key);
boolean containsValue(Object key);
V2 get(K2 key);
}
// FILE: SomeMap.java
import java.util.Map;
public abstract class SomeMap<K3, V3> implements Map<K3, V3>, MyMap<K3, V3> {
@Override
public abstract boolean containsKey(Object key);
@Override
public abstract V3 remove(Object key);
}
// FILE: main.kt
fun test(map: SomeMap<Int, String>) {
map.containsKey(1) // ok
map.containsKey(<!ARGUMENT_TYPE_MISMATCH!>""<!>) // error
map.containsValue("") // ok
map.containsValue(<!ARGUMENT_TYPE_MISMATCH!>1<!>) // error
map.get(1) // ok
map.get(<!ARGUMENT_TYPE_MISMATCH!>""<!>) // error
map.remove(1) // ok
map.remove(<!ARGUMENT_TYPE_MISMATCH!>""<!>) // error
}
@@ -0,0 +1,39 @@
SomeMap:
[Enhancement]: public abstract fun containsKey(key: R|ft<K3, K3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
[SubstitutionOverride]: public abstract fun containsKey(key: R|ft<K3, K3?>|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
[SubstitutionOverride]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 2]
[Library]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
[Library]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
[SubstitutionOverride]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
[Enhancement]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 5]
[SubstitutionOverride]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 6]
[Enhancement]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyBaseMap [id: 7]
[SubstitutionOverride]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 6]
[Enhancement]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyBaseMap [id: 7]
[IntersectionOverride]: public abstract fun containsValue(value: R|ft<V3, V3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
[SubstitutionOverride]: public abstract fun containsValue(value: R|ft<V3, V3?>|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
[SubstitutionOverride]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 2]
[Library]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
[Library]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
[SubstitutionOverride]: public abstract fun containsValue(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
[Enhancement]: public abstract fun containsValue(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 5]
[IntersectionOverride]: public abstract operator fun get(key: R|ft<K3, K3?>|): R|V3?| from Java enhancement scope for /SomeMap [id: 0]
[SubstitutionOverride]: public abstract operator fun get(key: R|ft<K3, K3?>|): R|V3?| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
[SubstitutionOverride]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/MutableMap [id: 2]
[Library]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/Map [id: 3]
[Library]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/Map [id: 3]
[SubstitutionOverride]: public abstract operator fun get(key: R|ft<K3, K3?>|): R|ft<V3, V3?>| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
[Enhancement]: public abstract operator fun get(key: R|ft<K2, K2?>|): R|ft<V2, V2?>| from Java enhancement scope for /MyMap [id: 5]
[Enhancement]: public abstract fun remove(key: R|ft<K3, K3?>|): R|V3?| from Java enhancement scope for /SomeMap [id: 0]
[SubstitutionOverride]: public abstract fun remove(key: R|ft<K3, K3?>|): R|V3?| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
[Library]: public abstract fun remove(key: R|K|): R|V?| from Use site scope of kotlin/collections/MutableMap [id: 2]
[SubstitutionOverride]: public open fun remove(key: R|ft<K3, K3?>|, value: R|ft<V3, V3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
[Library]: public open fun remove(key: R|K|, value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 1]
MyMap:
[Enhancement]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 0]
[SubstitutionOverride]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 1]
[Enhancement]: public abstract fun containsKey(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyBaseMap [id: 2]
[Enhancement]: public abstract fun containsValue(key: R|ft<kotlin/Any, kotlin/Any?>|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 0]
[Enhancement]: public abstract operator fun get(key: R|ft<K2, K2?>|): R|ft<V2, V2?>| from Java enhancement scope for /MyMap [id: 0]
@@ -0,0 +1,23 @@
FILE: main.kt
public abstract class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public open val x: R|kotlin/Int|
public get(): R|kotlin/Int| {
^ Int(1)
}
public open val y: R|kotlin/Int|
public get(): R|kotlin/Int| {
^ Int(2)
}
}
public final class DImpl : R|D| {
public constructor(): R|DImpl| {
super<R|D|>()
}
}
@@ -0,0 +1,28 @@
// SCOPE_DUMP: D:x;getX;y;getY
// FILE: B.java
public abstract class B extends A {
@Override
public int getX() { return 0; }
}
// FILE: C.java
public interface C {
int getX();
int getY();
}
// FILE: D.java
public abstract class D extends B implements C {}
// FILE: main.kt
abstract class A {
open val x: Int
get() = 1
open val y: Int
get() = 2
}
class DImpl : D()
@@ -0,0 +1,8 @@
D:
[Synthetic]: public open val x: R|kotlin/Int| from Java enhancement scope for /D [id: 0]
[Synthetic]: public open val x: R|kotlin/Int| from Java enhancement scope for /B [id: 1]
[Source]: public open val x: R|kotlin/Int| from Use site scope of /A [id: 2]
[Synthetic]: public open val y: R|kotlin/Int| from Java enhancement scope for /D [id: 0]
[Source]: public open val y: R|kotlin/Int| from Java enhancement scope for /B [id: 1]
[Source]: public open val y: R|kotlin/Int| from Use site scope of /A [id: 1]
@@ -0,0 +1,28 @@
// SCOPE_DUMP: Some:toByte;byteValue MyNumber:toByte;byteValue
// -SCOPE_DUMP: Some:toInt;intValue;toByte;byteValue;toLong;longValue
// FILE: MyBaseNumber.java
public interface MyBaseNumber {
byte byteValue(); // (1)
}
// FILE: MyNumber.java
public interface MyNumber extends MyBaseNumber {
@Override
byte byteValue(); // (2)
}
// FILE: Some.java
public abstract class Some extends Number implements MyNumber {
@Override
public abstract byte byteValue() // (3)
}
/*
* Some.toByte() (3', renamed) overrides Number.toByte & MyNumber.toByte(2', renamed)
* MyNumber.toByte(2', renamed) overrides ???
*/
fun test(some: Some) {
some.toByte()
}
@@ -0,0 +1,10 @@
Some:
[Enhancement]: public abstract operator fun toByte(): R|kotlin/Byte| from Java enhancement scope for /Some [id: 0]
[Library]: public abstract fun toByte(): R|kotlin/Byte| from Use site scope of kotlin/Number [id: 1]
[RenamedForOverride]: public abstract fun toByte(): R|kotlin/Byte| from Java enhancement scope for /MyNumber [id: 2]
[Enhancement]: public abstract fun byteValue(): R|kotlin/Byte| from Java enhancement scope for /MyBaseNumber [id: 3]
MyNumber:
[Enhancement]: public abstract fun byteValue(): R|kotlin/Byte| from Java enhancement scope for /MyNumber [id: 0]
[Enhancement]: public abstract fun byteValue(): R|kotlin/Byte| from Java enhancement scope for /MyBaseNumber [id: 1]