No override check in FirClassUseSiteScope, fix nasty substitution bug
This fixes MPP override test (see mppFakeOverride in FirMultiModuleResolveTestGenerated)
This commit is contained in:
+1
-1
@@ -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<ConeKotlinTypeProjection>(typeArguments.size) }
|
||||
var initialized = false
|
||||
|
||||
+1
-1
@@ -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?
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -32,7 +32,7 @@ FILE: simple.kt
|
||||
|
||||
public final function test(): R|kotlin/Unit| {
|
||||
R|/B.foo|()
|
||||
<Ambiguity: bar, [/B.bar, /A.bar]>#()
|
||||
R|/B.bar|()
|
||||
<Ambiguity: buz, [/B.buz, /A.buz]>#()
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ FILE: simpleFakeOverride.kt
|
||||
public constructor(): super<R|A<Some>|>()
|
||||
|
||||
public final function test(): R|kotlin/Unit| {
|
||||
R|FakeOverride</A.foo: R|T|>|(<Unresolved name: Some>#())
|
||||
R|FakeOverride</A.foo: R|Some|>|(<Unresolved name: Some>#())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ expect open class A<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)
|
||||
// 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()
|
||||
}
|
||||
@@ -12,8 +12,12 @@ FILE: common.kt
|
||||
public open class C : R|B| {
|
||||
public constructor(): super<R|B|>()
|
||||
|
||||
public open function bar(arg: R|kotlin/CharSequence|): R|kotlin/String| {
|
||||
return@@@bar <Unresolved name: arg>#.<Unresolved name: toString>#()
|
||||
public open function bar(arg: R|kotlin/String|): R|kotlin/String| {
|
||||
return@@@bar <Unresolved name: arg>#
|
||||
}
|
||||
|
||||
public open function baz(arg: R|kotlin/CharSequence|): R|kotlin/String| {
|
||||
return@@@baz <Unresolved name: arg>#.<Unresolved name: toString>#()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
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() {
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,18 @@ FILE: jvm.kt
|
||||
return@@@bar <Unresolved name: arg>#
|
||||
}
|
||||
|
||||
public open function baz(arg: R|T|): R|T| {
|
||||
return@@@baz <Unresolved name: arg>#
|
||||
}
|
||||
|
||||
}
|
||||
public final class D : R|C| {
|
||||
public constructor(): super<R|C|>()
|
||||
|
||||
public final function test(): R|kotlin/Unit| {
|
||||
R|FakeOverride</A.foo: R|kotlin/Unit|>|(String())
|
||||
<Ambiguity: bar, [/C.bar, /A.bar]>#(String())
|
||||
R|/C.bar|(String())
|
||||
<Ambiguity: baz, [/C.baz, /A.baz]>#(String())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -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()
|
||||
|
||||
@@ -12,7 +12,7 @@ FILE: B.kt
|
||||
|
||||
public final function test(): R|kotlin/Unit| {
|
||||
R|/B.foo|()
|
||||
<Ambiguity: bar, [/B.bar, /A.bar]>#()
|
||||
R|/B.bar|()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user