[FIR] Rework resolution of declaration statuses

There is introduced algorithm of resolution with jumps: before
  resolution of some class we resolve all status of members of its
  supertypes, so we can properly determine inherited visibility
  and modifiers
This commit is contained in:
Dmitriy Novozhilov
2020-09-28 15:30:51 +03:00
parent 0b8116dff0
commit bf1a00c73a
35 changed files with 858 additions and 180 deletions
@@ -0,0 +1,15 @@
interface Common {
fun <T, R> foo(value: T, producer: (T) -> R): R
}
class C : B, A {
override fun <T, R> foo(value: T, producer: (T) -> R): R = null!!
}
interface A : Common {
override fun <T, R> foo(value: T, producer: (T) -> R): R = null!!
}
interface B : Common {
override fun <T, R> foo(value: T, producer: (T) -> R) = producer(value)
}
@@ -0,0 +1,27 @@
FILE: intersectionOverrideWithImplicitTypes.kt
public abstract interface Common : R|kotlin/Any| {
public abstract fun <T, R> foo(value: R|T|, producer: R|(T) -> R|): R|R|
}
public final class C : R|B|, R|A| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}
public final override fun <T, R> foo(value: R|T|, producer: R|(T) -> R|): R|R| {
^foo Null(null)!!
}
}
public abstract interface A : R|Common| {
public open override fun <T, R> foo(value: R|T|, producer: R|(T) -> R|): R|R| {
^foo Null(null)!!
}
}
public abstract interface B : R|Common| {
public open override fun <T, R> foo(value: R|T|, producer: R|(T) -> R|): R|R| {
^foo R|<local>/producer|.R|FakeOverride<kotlin/Function1.invoke: R|R|>|(R|<local>/value|)
}
}
@@ -0,0 +1,18 @@
// FILE: C.kt
class C : B() {
override fun foo() {}
}
// FILE: B.java
public class B extends A {
@java.lang.Override
public void foo() {}
}
// FILE: A.kt
abstract class A {
abstract fun foo()
}
@@ -0,0 +1,19 @@
FILE: C.kt
public final class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public final override fun foo(): R|kotlin/Unit| {
}
}
FILE: A.kt
public abstract class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public abstract fun foo(): R|kotlin/Unit|
}
@@ -0,0 +1,23 @@
// ISSUE: KT-38656
// FILE: B.kt
class B : A() {
override fun foo(s: String): String = ""
fun testProtected(): String {
return this foo "hello"
}
}
// FILE: A.kt
abstract class A {
protected abstract infix fun foo(s: String): String
}
// FILE: main.kt
fun test(b: B): String {
return b <!HIDDEN!>foo<!> "hello" // should be an error
}
@@ -0,0 +1,28 @@
FILE: B.kt
public final class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
protected final override infix fun foo(s: R|kotlin/String|): R|kotlin/String| {
^foo String()
}
public final fun testProtected(): R|kotlin/String| {
^testProtected this@R|/B|.R|/B.foo|(String(hello))
}
}
FILE: A.kt
public abstract class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
protected abstract infix fun foo(s: R|kotlin/String|): R|kotlin/String|
}
FILE: main.kt
public final fun test(b: R|B|): R|kotlin/String| {
^test R|<local>/b|.<HIDDEN: /B.foo is invisible>#(String(hello))
}