[FIR] Search expect for actual only in dependsOn dependencies

Before this commit, the expect-actual resolver could find expects in
regular dependencies

Note: The appeared `VIRTUAL_MEMBER_HIDDEN` in
compiler/fir/analysis-tests/testData/resolveWithStdlib/multiModule/FakeOverrides.kt
isn't caused by my change. It's caused by fixing the testData dependency
syntax notation.

The testData improperly used regular dependency syntax notation, while
it should have been using dependsOn

Before:
    Regular dependency syntax notation

    // MODULE: androidMain(commonMain)

After:
    dependsOn dependency syntax notation

    // MODULE: androidMain()()(commonMain)
This commit is contained in:
Nikita Bobko
2024-02-13 17:58:06 +01:00
committed by teamcity
parent e431a96897
commit 4120d6a8aa
15 changed files with 512 additions and 14 deletions
@@ -26,7 +26,64 @@ FILE: common.kt
}
}
Module: m1-jvm
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open actual fun foo(arg: R|T|): R|kotlin/Unit| {
}
public open fun bar(arg: R|T|): R|T| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|T|): R|T| {
^baz R|<local>/arg|
}
}
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|SubstitutionOverride</B.foo: R|kotlin/Unit|>|(String())
this@R|/D|.R|/C.bar|(String())
this@R|/D|.R|SubstitutionOverride</B.baz: R|kotlin/String|>|(String())
}
}
Module: m1-jvm
FILE: common.kt
public open expect class A<T> : R|kotlin/Any| {
public expect constructor<T>(): R|A<T>|
public open expect fun foo(arg: R|T|): R|kotlin/Unit|
}
public open class B : R|A<kotlin/String>| {
public constructor(): R|B| {
super<R|A<kotlin/String>|>()
}
}
public open class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public open fun bar(arg: R|kotlin/String|): R|kotlin/String| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
^baz R|<local>/arg|.R|kotlin/Any.toString|()
}
}
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
@@ -10,11 +10,11 @@ open class B : A<String>() {
// Fake (JVM only): override fun bar(arg: String): String = super.bar(arg)
}
open class C : B() {
open fun bar(arg: String): String = arg
open fun <!VIRTUAL_MEMBER_HIDDEN!>bar<!>(arg: String): String = arg
open fun baz(arg: CharSequence): String = arg.toString()
}
// MODULE: m1-jvm(m1-common)
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual open class A<T> {
@@ -0,0 +1,116 @@
Module: m1-common
FILE: common.kt
public open expect class A<T> : R|kotlin/Any| {
public expect constructor<T>(): R|A<T>|
public open expect fun foo(arg: R|T|): R|kotlin/Unit|
}
public open class B : R|A<kotlin/String>| {
public constructor(): R|B| {
super<R|A<kotlin/String>|>()
}
}
public open class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public open fun bar(arg: R|kotlin/String|): R|kotlin/String| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
^baz R|<local>/arg|.R|kotlin/Any.toString|()
}
}
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open actual fun foo(arg: R|T|): R|kotlin/Unit| {
}
public open fun bar(arg: R|T|): R|T| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|T|): R|T| {
^baz R|<local>/arg|
}
}
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|SubstitutionOverride</B.foo: R|kotlin/Unit|>|(String())
this@R|/D|.R|/C.bar|(String())
this@R|/D|.R|SubstitutionOverride</B.baz: R|kotlin/String|>|(String())
}
}
Module: m1-jvm
FILE: common.kt
public open expect class A<T> : R|kotlin/Any| {
public expect constructor<T>(): R|A<T>|
public open expect fun foo(arg: R|T|): R|kotlin/Unit|
}
public open class B : R|A<kotlin/String>| {
public constructor(): R|B| {
super<R|A<kotlin/String>|>()
}
}
public open class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public open fun bar(arg: R|kotlin/String|): R|kotlin/String| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
^baz R|<local>/arg|.R|kotlin/Any.toString|()
}
}
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open actual fun foo(arg: R|T|): R|kotlin/Unit| {
}
public open fun bar(arg: R|T|): R|T| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|T|): R|T| {
^baz R|<local>/arg|
}
}
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|SubstitutionOverride</B.foo: R|kotlin/Unit|>|(String())
this@R|/D|.R|/C.bar|(String())
this@R|/D|.R|SubstitutionOverride</B.baz: R|kotlin/String|>|(String())
}
}
@@ -0,0 +1,35 @@
// LL_FIR_DIVERGENCE
// I have no idea why the tests diverge. The test was misconfigured (it used regular dependencies instead of `dependsOn` dependencies).
// I fixed the misconfiguration, now it turns out that it has been diverged all the time
// LL_FIR_DIVERGENCE
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
expect open class A<T>() {
open fun foo(arg: T)
}
open class B : A<String>() {
// Fake: override fun foo(arg: String) = super.foo(arg)
// Fake (JVM only): override fun bar(arg: String): String = super.bar(arg)
}
open class C : B() {
open fun bar(arg: String): String = arg
open fun baz(arg: CharSequence): String = arg.toString()
}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual open class A<T> {
actual open fun foo(arg: T) {}
open fun bar(arg: T): T = arg
open fun baz(arg: T): T = arg
}
class D : C() {
fun test() {
foo("")
bar("") // should be resolved to just C.bar
baz("")
}
}
@@ -0,0 +1,116 @@
Module: m1-common
FILE: common.kt
public open expect class A<T> : R|kotlin/Any| {
public expect constructor<T>(): R|A<T>|
public open expect fun foo(arg: R|T|): R|kotlin/Unit|
}
public open class B : R|A<kotlin/String>| {
public constructor(): R|B| {
super<R|A<kotlin/String>|>()
}
}
public open class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public open fun bar(arg: R|kotlin/String|): R|kotlin/String| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
^baz R|<local>/arg|.R|kotlin/Any.toString|()
}
}
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open actual fun foo(arg: R|T|): R|kotlin/Unit| {
}
public open fun bar(arg: R|T|): R|T| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|T|): R|T| {
^baz R|<local>/arg|
}
}
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|SubstitutionOverride</B.foo: R|kotlin/Unit|>|(String())
this@R|/D|.R|/C.bar|(String())
this@R|/D|.R|SubstitutionOverride</B.baz: R|kotlin/String|>|(String())
}
}
Module: m1-jvm
FILE: common.kt
public open expect class A<T> : R|kotlin/Any| {
public expect constructor<T>(): R|A<T>|
public open expect fun foo(arg: R|T|): R|kotlin/Unit|
}
public open class B : R|A<kotlin/String>| {
public constructor(): R|B| {
super<R|A<kotlin/String>|>()
}
}
public open class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public open fun bar(arg: R|kotlin/String|): R|kotlin/String| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
^baz R|<local>/arg|.R|kotlin/Any.toString|()
}
}
FILE: jvm.kt
public open actual class A<T> : R|kotlin/Any| {
public constructor<T>(): R|A<T>| {
super<R|kotlin/Any|>()
}
public open actual fun foo(arg: R|T|): R|kotlin/Unit| {
}
public open fun bar(arg: R|T|): R|T| {
^bar R|<local>/arg|
}
public open fun baz(arg: R|T|): R|T| {
^baz R|<local>/arg|
}
}
public final class D : R|C| {
public constructor(): R|D| {
super<R|C|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|SubstitutionOverride</B.foo: R|kotlin/Unit|>|(String())
this@R|/D|.R|/C.bar|(String())
this@R|/D|.R|SubstitutionOverride</B.baz: R|kotlin/String|>|(String())
}
}
@@ -13,7 +13,61 @@ FILE: common.kt
public get(): R|MyList|
}
Module: m1-jvm
FILE: jvm.kt
public open actual class MyList : R|kotlin/Any| {
public constructor(): R|MyList| {
super<R|kotlin/Any|>()
}
public final actual fun get(i: R|kotlin/Int|): R|kotlin/Int| {
^get R|<local>/i|
}
public final fun set(i: R|kotlin/Int|, v: R|kotlin/Int|): R|kotlin/Unit| {
}
}
public final class DerivedList : R|MyList| {
public constructor(): R|DerivedList| {
super<R|MyList|>()
}
public final fun useMember(): R|kotlin/Unit| {
this@R|/DerivedList|.R|/MyList.get|(Int(1))
this@R|/DerivedList|.R|/MyList.set|(Int(2), Int(3))
}
}
public final fun useList(list: R|MyList|): R|kotlin/Unit| {
R|<local>/list|.R|/MyList.get|(Int(1))
R|<local>/list|.R|/MyList.set|(Int(2), Int(3))
}
public final class DerivedWrapper : R|Wrapper| {
public constructor(): R|DerivedWrapper| {
super<R|Wrapper|>(R|/MyList.MyList|())
}
public final fun use(): R|kotlin/Unit| {
this@R|/DerivedWrapper|.R|/Wrapper.list|.R|/MyList.get|(Int(1))
this@R|/DerivedWrapper|.R|/Wrapper.list|.R|/MyList.set|(Int(2), Int(3))
}
}
Module: m1-jvm
FILE: common.kt
public final expect class MyList : R|kotlin/Any| {
public final expect fun get(i: R|kotlin/Int|): R|kotlin/Int|
}
public open class Wrapper : R|kotlin/Any| {
public constructor(list: R|MyList|): R|Wrapper| {
super<R|kotlin/Any|>()
}
public final val list: R|MyList| = R|<local>/list|
public get(): R|MyList|
}
FILE: jvm.kt
public open actual class MyList : R|kotlin/Any| {
public constructor(): R|MyList| {
@@ -8,7 +8,7 @@ expect class MyList {
open class Wrapper(val list: MyList)
// MODULE: m1-jvm(m1-common)
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual open class MyList {
@@ -15,7 +15,63 @@ FILE: common.kt
}
}
Module: m1-jvm
FILE: jvm.kt
public open actual class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final actual fun foo(): R|kotlin/Unit| {
}
public final fun bar(): R|kotlin/Unit| {
}
public final actual val x: R|kotlin/Int| = Int(42)
public get(): R|kotlin/Int|
}
public final class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/C|.R|/A.foo|()
this@R|/C|.R|/A.bar|()
this@R|/C|.R|/A.x|.R|kotlin/Int.plus|(this@R|/C|.R|/A.x|)
}
}
public final class D : R|A| {
public constructor(): R|D| {
super<R|A|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|/A.foo|()
this@R|/D|.R|/A.bar|()
this@R|/D|.R|/A.x|.R|kotlin/Int.plus|(this@R|/D|.R|/A.x|)
}
}
Module: m1-jvm
FILE: common.kt
public open expect class A : R|kotlin/Any| {
public expect constructor(): R|A|
public final expect fun foo(): R|kotlin/Unit|
public final expect val x: R|kotlin/Int|
public get(): R|kotlin/Int|
}
public open class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
}
FILE: jvm.kt
public open actual class A : R|kotlin/Any| {
public constructor(): R|A| {
@@ -10,7 +10,7 @@ expect open class A() {
open class B : A()
// MODULE: m1-jvm(m1-common)
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual open class A {
@@ -12,7 +12,68 @@ FILE: common.kt
}
}
Module: m1-jvm
FILE: jvm.kt
public abstract class X : R|kotlin/Any| {
public constructor(): R|X| {
super<R|kotlin/Any|>()
}
public final fun bar(): R|kotlin/Unit| {
}
}
public abstract interface Y : R|kotlin/Any| {
public open fun baz(): R|kotlin/Unit| {
}
}
public open actual class A : R|X|, R|Y| {
public constructor(): R|A| {
super<R|X|>()
}
public final actual fun foo(): R|kotlin/Unit| {
}
}
public final class C : R|B| {
public constructor(): R|C| {
super<R|B|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/C|.R|/A.foo|()
this@R|/C|.R|/X.bar|()
this@R|/C|.R|/Y.baz|()
}
}
public final class D : R|A| {
public constructor(): R|D| {
super<R|A|>()
}
public final fun test(): R|kotlin/Unit| {
this@R|/D|.R|/A.foo|()
this@R|/D|.R|/X.bar|()
this@R|/D|.R|/Y.baz|()
}
}
Module: m1-jvm
FILE: common.kt
public open expect class A : R|kotlin/Any| {
public expect constructor(): R|A|
public final expect fun foo(): R|kotlin/Unit|
}
public open class B : R|A| {
public constructor(): R|B| {
super<R|A|>()
}
}
FILE: jvm.kt
public abstract class X : R|kotlin/Any| {
public constructor(): R|X| {
@@ -8,7 +8,7 @@ expect open class A() {
open class B : A()
// MODULE: m1-jvm(m1-common)
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
abstract class X {