Skip to content

Commit 8577f06

Browse files
cypressiousSpace Team
authored andcommitted
[FIR] Don't report EXTENSION_SHADOWED_BY_MEMBER on overrides
#KT-79430 Fixed
1 parent b08aa12 commit 8577f06

File tree

8 files changed

+56
-6
lines changed

8 files changed

+56
-6
lines changed

compiler/fir/analysis-tests/testData/resolve/diagnostics/methodOfAnyImplementedInInterface.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ interface I {
3434
}
3535

3636
interface J : I {
37-
override fun String.<!EXTENSION_SHADOWED_BY_MEMBER!>hashCode<!>(): Int = 1
37+
override fun String.hashCode(): Int = 1
3838

3939
context(string: String)
4040
override fun hashCode(): Int = 1
4141

42-
override fun String.<!EXTENSION_SHADOWED_BY_MEMBER!>toString<!>(): String = ""
42+
override fun String.toString(): String = ""
4343

4444
context(string: String)
4545
override fun toString(): String = ""

compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExtensionShadowedByMemberChecker.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ sealed class FirExtensionShadowedByMemberChecker(kind: MppCheckerKind) : FirCall
4747
declaration.receiverParameter.let { it == null || it.typeRef.coneType.canBeNull(context.session) } ||
4848
declaration.nameOrSpecialName == NO_NAME_PROVIDED ||
4949
// A common pattern, KT-70012
50-
declaration.isActual
50+
declaration.isActual ||
51+
declaration.isOverride
5152
) {
5253
return
5354
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN_PIPELINE_TILL: FRONTEND
2+
package d
3+
4+
class T {
5+
fun baz() = 1
6+
}
7+
8+
fun foo() {
9+
<!WRONG_MODIFIER_TARGET!>public<!> val i = 11
10+
<!WRONG_MODIFIER_TARGET!>abstract<!> val <!VARIABLE_WITH_NO_TYPE_NO_INITIALIZER!>j<!>
11+
<!WRONG_MODIFIER_TARGET!>override<!> fun T.baz() = 2
12+
<!WRONG_MODIFIER_TARGET!>private<!> fun bar() = 2
13+
}
14+
15+
/* GENERATED_FIR_TAGS: classDeclaration, funWithExtensionReceiver, functionDeclaration, integerLiteral, localFunction,
16+
localProperty, override, propertyDeclaration */

compiler/testData/diagnostics/tests/declarationChecks/localDeclarationModifiers.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN_PIPELINE_TILL: FRONTEND
2-
// FIR_IDENTICAL
32
package d
43

54
class T {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN_PIPELINE_TILL: FRONTEND
2+
package d
3+
4+
class T {
5+
fun baz() = 1
6+
}
7+
8+
<!WRONG_MODIFIER_TARGET!>override<!> fun zzz() {}
9+
10+
fun foo(t: T) {
11+
<!WRONG_MODIFIER_TARGET!>override<!> fun T.baz() = 2
12+
13+
// was "Visibility is unknown yet exception"
14+
t.baz()
15+
16+
zzz()
17+
}
18+
19+
/* GENERATED_FIR_TAGS: classDeclaration, funWithExtensionReceiver, functionDeclaration, integerLiteral, localFunction,
20+
override */

compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN_PIPELINE_TILL: FRONTEND
2-
// FIR_IDENTICAL
32
package d
43

54
class T {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN_PIPELINE_TILL: BACKEND
2+
// ISSUE: KT-79430
3+
class Foo {
4+
fun bar() {}
5+
}
6+
7+
interface Extension<T> {
8+
fun T.bar()
9+
}
10+
11+
class FooExtension : Extension<Foo> {
12+
override fun Foo.bar() {}
13+
}
14+
15+
/* GENERATED_FIR_TAGS: classDeclaration, funWithExtensionReceiver, functionDeclaration, interfaceDeclaration,
16+
nullableType, override, typeParameter */

compiler/testData/diagnostics/tests/extensionShadowedByMemberOverride.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN_PIPELINE_TILL: BACKEND
2-
// FIR_IDENTICAL
32
// ISSUE: KT-79430
43
class Foo {
54
fun bar() {}

0 commit comments

Comments
 (0)