K2: don't allow to override isHiddenToOvercomeSignatureClash to match K1

Related to KT-64846
This commit is contained in:
Mikhail Glukhikh
2024-01-26 14:06:27 +01:00
committed by Space Team
parent 3b164e560c
commit 8f9614c1fb
6 changed files with 21 additions and 17 deletions
@@ -110,6 +110,7 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO
fun isOverriddenFunction(overrideCandidate: FirSimpleFunction, baseDeclaration: FirSimpleFunction, ignoreVisibility: Boolean): Boolean {
if (overrideCandidate.valueParameters.size != baseDeclaration.valueParameters.size) return false
if (overrideCandidate.isSuspend != baseDeclaration.isSuspend) return false
if (baseDeclaration.isHiddenToOvercomeSignatureClash == true) return false
val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false
@@ -22,5 +22,5 @@ abstract class KA : A() {
fun foo(a: A, ka: KA) {
a.get(0)
ka.<!UNRESOLVED_REFERENCE!>get<!>(0)
ka.get(0)
}
@@ -1,6 +1,6 @@
KA:
[Source]: public open override operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Use site scope of /KA [id: 0]
[Enhancement]: public open operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Java enhancement scope for /A [id: 1]
[Enhancement]: /* hidden due to clash */ public open operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Java enhancement scope for /A [id: 2]
[Library]: public abstract operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Use site scope of kotlin/CharSequence [id: 3]
[Enhancement]: /* hidden due to clash */ public open operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Use site scope of /KA [id: 0]
[Enhancement]: /* hidden due to clash */ public open operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Java enhancement scope for /A [id: 0]
[Library]: public abstract operator fun get(index: R|kotlin/Int|): R|kotlin/Char| from Use site scope of kotlin/CharSequence [id: 1]
@@ -18,8 +18,8 @@ fun foo(a: A, ka: KA) {
"" in a
<!ARGUMENT_TYPE_MISMATCH!>1<!> in a
ka.<!UNRESOLVED_REFERENCE!>contains<!>("")
ka.<!UNRESOLVED_REFERENCE!>contains<!>(1)
"" <!UNRESOLVED_REFERENCE!>in<!> ka
1 <!UNRESOLVED_REFERENCE!>in<!> ka
ka.contains("")
ka.contains(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
"" in ka
<!ARGUMENT_TYPE_MISMATCH!>1<!> in ka
}
@@ -5,8 +5,9 @@ KA:
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableCollection [id: 3]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/Collection] for type kotlin/collections/MutableCollection<E> [id: 3]
[Library]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Collection [id: 4]
[Enhancement]: /* hidden due to clash */ public open operator fun contains(x: R|kotlin/String!|): R|kotlin/Boolean| from Java enhancement scope for /A [id: 5]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|kotlin/String!|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableCollection] for type A [id: 2]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableCollection [id: 3]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/Collection] for type kotlin/collections/MutableCollection<E> [id: 3]
[Library]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Collection [id: 4]
[Enhancement]: /* hidden due to clash */ public open operator fun contains(x: R|kotlin/String!|): R|kotlin/Boolean| from Use site scope of /KA [id: 0]
[Enhancement]: /* hidden due to clash */ public open operator fun contains(x: R|kotlin/String!|): R|kotlin/Boolean| from Java enhancement scope for /A [id: 0]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|kotlin/String!|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableCollection] for type A [id: 1]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableCollection [id: 2]
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/Collection] for type kotlin/collections/MutableCollection<E> [id: 2]
[Library]: public abstract operator fun contains(element: R|E|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Collection [id: 3]
@@ -1,6 +1,8 @@
Y2:
[Source]: public open override operator fun removeAt(index: R|kotlin/Int|): R|kotlin/String| from Use site scope of /Y2 [id: 0]
[Source]: public open override fun removeAt(index: R|kotlin/Int|): R|kotlin/String| from Use site scope of /Y2 [id: 0]
[Enhancement]: public open fun removeAt(index: R|kotlin/Int|): R|kotlin/String!| from Java enhancement scope for /X [id: 1]
[Enhancement]: /* hidden due to clash */ public open operator fun removeAt(index: R|kotlin/Int|): R|kotlin/String!| from Java enhancement scope for /X [id: 2]
[SubstitutionOverride(DeclarationSite)]: public abstract fun removeAt(index: R|kotlin/Int|): R|kotlin/String!| from Substitution scope for [Use site scope of kotlin/collections/MutableList] for type X [id: 3]
[Library]: public abstract fun removeAt(index: R|kotlin/Int|): R|E| from Use site scope of kotlin/collections/MutableList [id: 4]
[Enhancement]: /* hidden due to clash */ public open operator fun removeAt(index: R|kotlin/Int|): R|kotlin/String!| from Use site scope of /Y2 [id: 0]
[Enhancement]: /* hidden due to clash */ public open operator fun removeAt(index: R|kotlin/Int|): R|kotlin/String!| from Java enhancement scope for /X [id: 0]
[SubstitutionOverride(DeclarationSite)]: public abstract fun removeAt(index: R|kotlin/Int|): R|kotlin/String!| from Substitution scope for [Use site scope of kotlin/collections/MutableList] for type X [id: 1]
[Library]: public abstract fun removeAt(index: R|kotlin/Int|): R|E| from Use site scope of kotlin/collections/MutableList [id: 2]