[FIR] Check conflicting overloads via scopes

Scopes may return private symbols from
supertypes, they should not clash with
symbols from the current class.

For example, see:
`FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.FakeOverride#testPrivateFakeOverrides1`

Lombok shouldn't generate functions if the
user has defined explicit ones.

In K1 generated functions are not really
added to the declared members scope.

^KT-61243 Fixed
This commit is contained in:
Nikolay Lunyak
2023-09-20 16:52:32 +03:00
committed by Space Team
parent 973248f432
commit 4e58715760
24 changed files with 278 additions and 129 deletions
@@ -0,0 +1,55 @@
open class Final {
fun foo() {}
val bar: Int = 0
var qux: Int = 0
}
open class Derived : Final()
interface IFoo {
fun foo()
}
class CFoo : IFoo {
override fun foo() {}
}
interface IBar {
val bar: Int
}
class CBar : IBar {
override val bar: Int get() = 0
}
interface IQux {
val qux: Int
}
class CQux : IQux {
override val qux: Int get() = 0
}
interface IBarT<T> {
val bar: T
}
class CBarT<T> : IBarT<T> {
override val bar: T get() = null!!
}
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION!>class <!CONFLICTING_OVERLOADS, CONFLICTING_OVERLOADS!>Test1<!><!> : Final(), IFoo by CFoo()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION!>class <!REDECLARATION, REDECLARATION!>Test2<!><!> : Final(), IBar by CBar()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION, VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION!>class <!REDECLARATION, REDECLARATION!>Test3<!><!> : Final(), IQux by CQux()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION!>class <!CONFLICTING_OVERLOADS, CONFLICTING_OVERLOADS!>Test4<!><!> : Derived(), IFoo by CFoo()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION!>class <!REDECLARATION, REDECLARATION!>Test5<!><!> : Derived(), IBar by CBar()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION, VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION!>class <!REDECLARATION, REDECLARATION!>Test6<!><!> : Derived(), IQux by CQux()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION!>class <!REDECLARATION, REDECLARATION!>Test7<!><!> : Final(), IBarT<Int> by CBarT<Int>()
<!OVERRIDING_FINAL_MEMBER_BY_DELEGATION!>class <!REDECLARATION, REDECLARATION!>Test8<!><!> : Final(), IBarT<Int> by <!TYPE_MISMATCH!>CBar()<!>
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
open class Final {
fun foo() {}
val bar: Int = 0
@@ -1,3 +1,5 @@
enum class A {
name
enum class <!REDECLARATION, REDECLARATION!>A<!> {
<!REDECLARATION!>name<!>,
<!REDECLARATION!>ordinal<!>,
<!DEPRECATED_DECLARATION_OF_ENUM_ENTRY!>entries,<!>
}
@@ -1,3 +1,5 @@
enum class A {
<!REDECLARATION!>name<!>
<!REDECLARATION!>name<!>,
<!REDECLARATION!>ordinal<!>,
<!DEPRECATED_DECLARATION_OF_ENUM_ENTRY!>entries,<!>
}
@@ -3,6 +3,10 @@ package
public final enum class A : kotlin.Enum<A> {
enum entry name
enum entry ordinal
enum entry entries
private constructor A()
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
@@ -1,14 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY
class C(val x: Int)
<!CONFLICTING_OVERLOADS!>typealias CC = C<!>
<!CONFLICTING_OVERLOADS!>fun CC(x: Int)<!> = x
class Outer {
class C(val x: Int)
typealias CC = C
fun CC(x: Int) = x
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY
class C(val x: Int)
@@ -1,14 +0,0 @@
// ISSUE: KT-57100
// WITH_STDLIB
interface C07I01{
fun some() {}
}
interface C07I02{
suspend fun some() {}
}
class C07C01: C07I01, C07I02 {
override fun some() {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// ISSUE: KT-57100
// WITH_STDLIB
@@ -10,5 +11,5 @@ interface C07I02{
}
class C07C01: C07I01, C07I02 {
<!CONFLICTING_OVERLOADS!>override fun some()<!> {}
override fun some() {}
}