[FIR] Ignore fake functions in FirExposedVisibilityDeclarationChecker ^KT-51229 Fixed

This commit is contained in:
Ivan Kochurkin
2022-02-10 16:14:21 +03:00
committed by teamcity
parent 73b45a1254
commit 6a3b7a9f91
4 changed files with 52 additions and 3 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
import org.jetbrains.kotlin.KtFakeSourceElementKind
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
@@ -101,8 +102,11 @@ object FirExposedVisibilityDeclarationChecker : FirBasicDeclarationChecker() {
}
private fun checkFunction(declaration: FirFunction, reporter: DiagnosticReporter, context: CheckerContext) {
var functionVisibility = (declaration as FirMemberDeclaration).effectiveVisibility
if (declaration.source?.kind is KtFakeSourceElementKind) {
return
}
var functionVisibility = (declaration as FirMemberDeclaration).effectiveVisibility
if (declaration is FirConstructor && declaration.isFromSealedClass) {
functionVisibility = EffectiveVisibility.PrivateInClass
}
@@ -1,4 +1,4 @@
// ISSUE: KT-45043
// ISSUE: KT-45043, KT-51229
// DIAGNOSTICS: -UNUSED_PARAMETER
private class Bar
@@ -14,3 +14,11 @@ abstract class AbstractFoo(
<!EXPOSED_PARAMETER_TYPE!>private val y: Bar<!>,
<!EXPOSED_PARAMETER_TYPE!>z: Bar<!>
)
internal sealed class A {
protected abstract val b: B?
protected data class B(val s: String)
internal data class C private constructor(override val b: B?) : A() {
constructor() : this(null)
}
}
@@ -1,4 +1,4 @@
// ISSUE: KT-45043
// ISSUE: KT-45043, KT-51229
// DIAGNOSTICS: -UNUSED_PARAMETER
private class Bar
@@ -14,3 +14,11 @@ abstract class AbstractFoo(
<!EXPOSED_PARAMETER_TYPE!>private val y: Bar<!>,
<!EXPOSED_PARAMETER_TYPE!>z: Bar<!>
)
internal sealed class A {
protected abstract val b: B?
protected data class B(val s: String)
internal data class C private constructor(override val b: B?) : A() {
constructor() : this(null)
}
}
@@ -1,5 +1,34 @@
package
internal sealed class A {
protected constructor A()
protected abstract val b: A.B?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
protected final data class B {
public constructor B(/*0*/ s: kotlin.String)
public final val s: kotlin.String
public final operator /*synthesized*/ fun component1(): kotlin.String
public final /*synthesized*/ fun copy(/*0*/ s: kotlin.String = ...): A.B
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
internal final data class C : A {
public constructor C()
private constructor C(/*0*/ b: A.B?)
protected open override /*1*/ val b: A.B?
protected final operator /*synthesized*/ fun component1(): A.B?
public final /*synthesized*/ fun copy(/*0*/ b: A.B? = ...): A.C
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
}
public abstract class AbstractFoo {
public constructor AbstractFoo(/*0*/ x: Bar, /*1*/ y: Bar, /*2*/ z: Bar)
public final val x: Bar