diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index a94c609dadb..cbd6f335af2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -37,7 +37,7 @@ class FirClassSubstitutionScope( } private fun ConeKotlinType.substitute(): ConeKotlinType? { - if (this is ConeTypeParameterType) return substitution[this] + if (this is ConeTypeParameterType) return substitution[lookupTag] val newArguments by lazy { arrayOfNulls(typeArguments.size) } var initialized = false diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt index 9676e66a35c..ed295305a6e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteScope.kt @@ -72,7 +72,7 @@ class FirClassUseSiteScope( val self = (this as AbstractFirBasedSymbol<*>).fir as FirCallableMember val overriding = seen.firstOrNull { val member = (it as AbstractFirBasedSymbol<*>).fir as FirCallableMember - member.isOverride && self.modality != Modality.FINAL + self.modality != Modality.FINAL && sameReceivers(member.receiverTypeRef, self.receiverTypeRef) && similarFunctionsOrBothProperties(member, self) } // TODO: two or more overrides for one fun? diff --git a/compiler/fir/resolve/testData/resolve/overrides/simple.kt b/compiler/fir/resolve/testData/resolve/overrides/simple.kt index 63db053a3be..74f6740c812 100644 --- a/compiler/fir/resolve/testData/resolve/overrides/simple.kt +++ b/compiler/fir/resolve/testData/resolve/overrides/simple.kt @@ -8,7 +8,7 @@ open class A { class B : A() { override fun foo(): B = this - fun bar(): B = this // Ambiguity, no override here + fun bar(): B = this // Ambiguity, no override here (really it's just "missing override" and no ambiguity) override fun buz(p: B): B = this //No override as B A fun test() { diff --git a/compiler/fir/resolve/testData/resolve/overrides/simple.txt b/compiler/fir/resolve/testData/resolve/overrides/simple.txt index 6037f3522cb..b6f7da53fea 100644 --- a/compiler/fir/resolve/testData/resolve/overrides/simple.txt +++ b/compiler/fir/resolve/testData/resolve/overrides/simple.txt @@ -32,7 +32,7 @@ FILE: simple.kt public final function test(): R|kotlin/Unit| { R|/B.foo|() - #() + R|/B.bar|() #() } diff --git a/compiler/fir/resolve/testData/resolve/overrides/simpleFakeOverride.txt b/compiler/fir/resolve/testData/resolve/overrides/simpleFakeOverride.txt index 725e3ef3029..3c0605669f5 100644 --- a/compiler/fir/resolve/testData/resolve/overrides/simpleFakeOverride.txt +++ b/compiler/fir/resolve/testData/resolve/overrides/simpleFakeOverride.txt @@ -15,7 +15,7 @@ FILE: simpleFakeOverride.kt public constructor(): super|>() public final function test(): R|kotlin/Unit| { - R|FakeOverride|(#()) + R|FakeOverride|(#()) } } diff --git a/idea/testData/fir/multiModule/mppFakeOverrides/common/common.kt b/idea/testData/fir/multiModule/mppFakeOverrides/common/common.kt index 1f896a60583..3f3afd1fbee 100644 --- a/idea/testData/fir/multiModule/mppFakeOverrides/common/common.kt +++ b/idea/testData/fir/multiModule/mppFakeOverrides/common/common.kt @@ -3,8 +3,9 @@ expect open class A() { } open class B : A() { // Fake: override fun foo(arg: String) = super.foo(arg) - // Fake (JVM only) (?): override fun bar(arg: String): String = super.bar(arg) + // Fake (JVM only): override fun bar(arg: String): String = super.bar(arg) } open class C : B() { - open fun bar(arg: CharSequence): String = arg.toString() + open fun bar(arg: String): String = arg + open fun baz(arg: CharSequence): String = arg.toString() } \ No newline at end of file diff --git a/idea/testData/fir/multiModule/mppFakeOverrides/common/common.txt b/idea/testData/fir/multiModule/mppFakeOverrides/common/common.txt index 1f6466c07e4..5389d453191 100644 --- a/idea/testData/fir/multiModule/mppFakeOverrides/common/common.txt +++ b/idea/testData/fir/multiModule/mppFakeOverrides/common/common.txt @@ -12,8 +12,12 @@ FILE: common.kt public open class C : R|B| { public constructor(): super() - public open function bar(arg: R|kotlin/CharSequence|): R|kotlin/String| { - return@@@bar #.#() + public open function bar(arg: R|kotlin/String|): R|kotlin/String| { + return@@@bar # + } + + public open function baz(arg: R|kotlin/CharSequence|): R|kotlin/String| { + return@@@baz #.#() } } diff --git a/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.kt b/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.kt index 68cfec4a931..54da557b799 100644 --- a/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.kt +++ b/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.kt @@ -1,11 +1,12 @@ actual open class A { actual open fun foo(arg: T) {} open fun bar(arg: T): T = arg + open fun baz(arg: T): T = arg } class D : C() { - // Fake: override fun bar(arg: CharSequence): String = super.bar(arg) fun test() { foo("") - bar("") + bar("") // should be resolved to just C.bar + baz("") // ambiguity (we have C.bar with CharSequence argument and fake override of A.bar with String argument) } } \ No newline at end of file diff --git a/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.txt b/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.txt index e2fa8e18717..c257c9e5905 100644 --- a/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.txt +++ b/idea/testData/fir/multiModule/mppFakeOverrides/jvm/jvm.txt @@ -9,13 +9,18 @@ FILE: jvm.kt return@@@bar # } + public open function baz(arg: R|T|): R|T| { + return@@@baz # + } + } public final class D : R|C| { public constructor(): super() public final function test(): R|kotlin/Unit| { R|FakeOverride|(String()) - #(String()) + R|/C.bar|(String()) + #(String()) } } diff --git a/idea/testData/fir/multiModule/overrideWithJava/jvm/B.kt b/idea/testData/fir/multiModule/overrideWithJava/jvm/B.kt index 897fbd4c8c6..1e8254e92c0 100644 --- a/idea/testData/fir/multiModule/overrideWithJava/jvm/B.kt +++ b/idea/testData/fir/multiModule/overrideWithJava/jvm/B.kt @@ -1,6 +1,6 @@ class B : A() { override fun foo(): B = this - fun bar(): B = this // Ambiguity, no override here + fun bar(): B = this // Here we should have "missing override" but no ambiguity fun test() { foo() diff --git a/idea/testData/fir/multiModule/overrideWithJava/jvm/B.txt b/idea/testData/fir/multiModule/overrideWithJava/jvm/B.txt index cdad2d7fc14..ec5ad410d76 100644 --- a/idea/testData/fir/multiModule/overrideWithJava/jvm/B.txt +++ b/idea/testData/fir/multiModule/overrideWithJava/jvm/B.txt @@ -12,7 +12,7 @@ FILE: B.kt public final function test(): R|kotlin/Unit| { R|/B.foo|() - #() + R|/B.bar|() } }