[FIR] Add support for JVM_STATIC_ON_NON_PUBLIC_MEMBER diagnostic
This commit is contained in:
+1
@@ -24,6 +24,7 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
||||
val OVERRIDE_CANNOT_BE_STATIC by error<PsiElement>()
|
||||
val JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION by error<PsiElement>(PositioningStrategy.DECLARATION_SIGNATURE)
|
||||
val JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION by error<PsiElement>(PositioningStrategy.DECLARATION_SIGNATURE)
|
||||
val JVM_STATIC_ON_NON_PUBLIC_MEMBER by error<PsiElement>(PositioningStrategy.DECLARATION_SIGNATURE)
|
||||
|
||||
val INAPPLICABLE_JVM_NAME by error<PsiElement>()
|
||||
val ILLEGAL_JVM_NAME by error<PsiElement>()
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ object FirJvmErrors {
|
||||
val OVERRIDE_CANNOT_BE_STATIC by error0<PsiElement>()
|
||||
val JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION by error0<PsiElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
|
||||
val JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION by error0<PsiElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
|
||||
val JVM_STATIC_ON_NON_PUBLIC_MEMBER by error0<PsiElement>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
|
||||
val INAPPLICABLE_JVM_NAME by error0<PsiElement>()
|
||||
val ILLEGAL_JVM_NAME by error0<PsiElement>()
|
||||
|
||||
|
||||
+140
-34
@@ -7,21 +7,25 @@ package org.jetbrains.kotlin.fir.analysis.jvm.checkers.declaration
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.isInterface
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.classKind
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirBasicDeclarationChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isCompanion
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isOverride
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.languageVersionSettings
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
@@ -34,16 +38,87 @@ object FirJvmStaticChecker : FirBasicDeclarationChecker() {
|
||||
return
|
||||
}
|
||||
|
||||
checkOverrideCannotBeStatic(declaration, context, reporter)
|
||||
checkStaticNotInProperObject(declaration, context, reporter)
|
||||
}
|
||||
|
||||
private fun checkStaticNotInProperObject(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (declaration !is FirCallableDeclaration) {
|
||||
if (declaration !is FirAnnotatedDeclaration) {
|
||||
return
|
||||
}
|
||||
|
||||
val containingClassSymbol = declaration.getContainingClassSymbol(context.session) ?: return
|
||||
if (declaration !is FirMemberDeclaration) {
|
||||
return
|
||||
}
|
||||
|
||||
val annotatedParts = declaration.getAnnotatedParts()
|
||||
|
||||
checkOverrideCannotBeStatic(declaration, context, reporter, annotatedParts)
|
||||
checkStaticNotInProperObject(context, reporter, annotatedParts)
|
||||
checkStaticNonPublic(declaration, context, reporter, annotatedParts)
|
||||
}
|
||||
|
||||
private fun checkStaticNonPublic(
|
||||
declaration: FirMemberDeclaration,
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter,
|
||||
annotatedParts: List<FirAnnotatedDeclaration>,
|
||||
) {
|
||||
val containingClassSymbol = context.getContainerAt(0) ?: return
|
||||
var shouldCheck = false
|
||||
|
||||
if (containingClassSymbol.classKind != ClassKind.OBJECT) {
|
||||
shouldCheck = true
|
||||
} else {
|
||||
if (context.containerIsInterface(1)) {
|
||||
shouldCheck = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldCheck) {
|
||||
return
|
||||
}
|
||||
|
||||
val minVisibility = declaration.getMinimumVisibility()
|
||||
|
||||
if (minVisibility == Visibilities.Public) {
|
||||
return
|
||||
}
|
||||
|
||||
annotatedParts.forEach {
|
||||
reporter.reportOn(it.source, FirJvmErrors.JVM_STATIC_ON_NON_PUBLIC_MEMBER, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirMemberDeclaration.getMinimumVisibility() = when (this) {
|
||||
is FirProperty -> getMinimumVisibility()
|
||||
else -> this.visibility
|
||||
}
|
||||
|
||||
private fun FirProperty.getMinimumVisibility(): Visibility {
|
||||
var minVisibility = visibility
|
||||
|
||||
getter?.let {
|
||||
minVisibility = chooseMostSpecific(minVisibility, it.visibility)
|
||||
}
|
||||
|
||||
setter?.let {
|
||||
minVisibility = chooseMostSpecific(minVisibility, it.visibility)
|
||||
}
|
||||
|
||||
return minVisibility
|
||||
}
|
||||
|
||||
private fun chooseMostSpecific(a: Visibility, b: Visibility): Visibility {
|
||||
val difference = a.compareTo(b) ?: return a
|
||||
return if (difference > 0) {
|
||||
b
|
||||
} else {
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkStaticNotInProperObject(
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter,
|
||||
annotatedParts: List<FirAnnotatedDeclaration>,
|
||||
) {
|
||||
val containingClassSymbol = context.getContainerAt(0) ?: return
|
||||
val supportJvmStaticInInterface = context.session.languageVersionSettings.supportsFeature(LanguageFeature.JvmStaticInInterface)
|
||||
|
||||
val properDiagnostic = if (supportJvmStaticInInterface) {
|
||||
@@ -56,51 +131,73 @@ object FirJvmStaticChecker : FirBasicDeclarationChecker() {
|
||||
|
||||
if (containingClassSymbol.classKind != ClassKind.OBJECT) {
|
||||
shouldReport = true
|
||||
} else {
|
||||
val declaringClassSymbol = containingClassSymbol.getContainingClassSymbol(context.session) ?: return
|
||||
|
||||
if (declaringClassSymbol.classKind?.isInterface == true && !supportJvmStaticInInterface) {
|
||||
shouldReport = true
|
||||
}
|
||||
} else if (
|
||||
containingClassSymbol is FirRegularClassSymbol &&
|
||||
containingClassSymbol.isCompanion &&
|
||||
context.containerIsInterface(1) &&
|
||||
!supportJvmStaticInInterface
|
||||
) {
|
||||
shouldReport = true
|
||||
}
|
||||
|
||||
if (!shouldReport) {
|
||||
return
|
||||
}
|
||||
|
||||
declaration.reportOnProperParts {
|
||||
if (it.hasAnnotationNamedAs(StandardClassIds.JvmStatic)) {
|
||||
reporter.reportOn(it.source, properDiagnostic, context)
|
||||
}
|
||||
annotatedParts.forEach {
|
||||
reporter.reportOn(it.source, properDiagnostic, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkOverrideCannotBeStatic(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
if (declaration !is FirCallableDeclaration) {
|
||||
private fun checkOverrideCannotBeStatic(
|
||||
declaration: FirMemberDeclaration,
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter,
|
||||
annotatedParts: List<FirAnnotatedDeclaration>,
|
||||
) {
|
||||
if (!declaration.isOverride || !context.containerIsNonCompanionObject(0)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!declaration.isOverride || !declaration.isContainerNonCompanionObject(context)) {
|
||||
return
|
||||
}
|
||||
|
||||
declaration.reportOnProperParts {
|
||||
if (it.hasAnnotationNamedAs(StandardClassIds.JvmStatic)) {
|
||||
reporter.reportOn(it.source, FirJvmErrors.OVERRIDE_CANNOT_BE_STATIC, context)
|
||||
}
|
||||
annotatedParts.forEach {
|
||||
reporter.reportOn(it.source, FirJvmErrors.OVERRIDE_CANNOT_BE_STATIC, context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirAnnotatedDeclaration.reportOnProperParts(report: (FirAnnotatedDeclaration) -> Unit) {
|
||||
private fun FirAnnotatedDeclaration.getAnnotatedParts(): List<FirAnnotatedDeclaration> {
|
||||
return getReportableParts().filter {
|
||||
it.hasAnnotationNamedAs(StandardClassIds.JvmStatic)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirAnnotatedDeclaration.getReportableParts(): List<FirAnnotatedDeclaration> {
|
||||
val parts = mutableListOf(this)
|
||||
|
||||
if (this is FirProperty) {
|
||||
// the setter is visited separately
|
||||
this.getter?.let(report)
|
||||
fun takeIfNecessary(it: FirPropertyAccessor) {
|
||||
if (it.visibility.compatibleAndLesser(this.visibility)) {
|
||||
parts.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
this.getter?.let(::takeIfNecessary)
|
||||
this.setter?.let(::takeIfNecessary)
|
||||
}
|
||||
report(this)
|
||||
|
||||
return parts
|
||||
}
|
||||
|
||||
private fun FirDeclaration.isContainerNonCompanionObject(context: CheckerContext): Boolean {
|
||||
val containingClassSymbol = this.getContainingClassSymbol(context.session) ?: return false
|
||||
private fun Visibility.compatibleAndLesser(other: Visibility): Boolean {
|
||||
val difference = this.compareTo(other) ?: return false
|
||||
return difference <= 0
|
||||
}
|
||||
|
||||
private fun CheckerContext.containerIsInterface(outerLevel: Int): Boolean {
|
||||
return this.getContainerAt(outerLevel)?.classKind?.isInterface == true
|
||||
}
|
||||
|
||||
private fun CheckerContext.containerIsNonCompanionObject(outerLevel: Int): Boolean {
|
||||
val containingClassSymbol = this.getContainerAt(outerLevel) ?: return false
|
||||
|
||||
@OptIn(SymbolInternals::class)
|
||||
val containingClass = containingClassSymbol.fir.safeAs<FirRegularClass>() ?: return false
|
||||
@@ -108,6 +205,15 @@ object FirJvmStaticChecker : FirBasicDeclarationChecker() {
|
||||
return containingClass.classKind == ClassKind.OBJECT && !containingClass.isCompanion
|
||||
}
|
||||
|
||||
private fun CheckerContext.getContainerAt(outerLevel: Int): FirClassLikeSymbol<*>? {
|
||||
val last = this.containingDeclarations.asReversed().getOrNull(outerLevel)
|
||||
return if (last is FirClassLikeDeclaration) {
|
||||
last.symbol
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirAnnotatedDeclaration.hasAnnotationNamedAs(classId: ClassId): Boolean {
|
||||
return findAnnotation(classId.shortClassName) != null
|
||||
}
|
||||
|
||||
+5
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_RECORD
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_STATIC_ON_NON_PUBLIC_MEMBER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.LOCAL_JVM_RECORD
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NON_DATA_CLASS_JVM_RECORD
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NON_FINAL_JVM_RECORD
|
||||
@@ -108,6 +109,10 @@ object FirJvmDefaultErrorMessages {
|
||||
JVM_STATIC_NOT_IN_OBJECT_OR_COMPANION,
|
||||
"Only members in named objects and companion objects can be annotated with '@JvmStatic'"
|
||||
)
|
||||
map.put(
|
||||
JVM_STATIC_ON_NON_PUBLIC_MEMBER,
|
||||
"Only public members in interface companion objects can be annotated with '@JvmStatic'"
|
||||
)
|
||||
|
||||
map.put(INAPPLICABLE_JVM_NAME, "'@JvmName' annotation is not applicable to this declaration")
|
||||
map.put(ILLEGAL_JVM_NAME, "Illegal JVM name")
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class A {
|
||||
|
||||
interface B {
|
||||
companion object {
|
||||
@JvmStatic fun a1() {
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic fun a1()<!> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+25
-25
@@ -2,60 +2,60 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
interface B {
|
||||
companion object {
|
||||
@JvmStatic fun a1() {
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic fun a1()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic private fun a2() {
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic private fun a2()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic protected fun a3() {
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic protected fun a3()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic internal fun a4() {
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic internal fun a4()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic external fun a5()
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic external fun a5()<!>
|
||||
|
||||
@JvmStatic
|
||||
var foo = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic
|
||||
var foo<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
var foo1 = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
var foo1<!> = 1
|
||||
protected set
|
||||
|
||||
@JvmStatic
|
||||
var foo2 = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
var foo2<!> = 1
|
||||
private set
|
||||
|
||||
@JvmStatic
|
||||
private var foo3 = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
private var foo3<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
protected var foo4 = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
protected var foo4<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
protected var foo5 = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
protected var foo5<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
val foo6 = 1
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic
|
||||
val foo6<!> = 1
|
||||
|
||||
val foo7 = 1
|
||||
@JvmStatic get
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic get<!>
|
||||
|
||||
private var foo8 = 1
|
||||
@JvmStatic <!SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY!>public<!> set
|
||||
|
||||
public var foo9 = 1
|
||||
@JvmStatic private set
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION, JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic private set<!>
|
||||
|
||||
@JvmStatic
|
||||
val foo10: Int external get
|
||||
<!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic
|
||||
val foo10: Int<!> external get
|
||||
|
||||
val foo11: Int @JvmStatic external get
|
||||
val foo11: Int <!JVM_STATIC_NOT_IN_OBJECT_OR_CLASS_COMPANION!>@JvmStatic external get<!>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -8,15 +8,15 @@ interface B {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic private fun a2() {
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic private fun a2()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic protected fun a3() {
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic protected fun a3()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic internal fun a4() {
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic internal fun a4()<!> {
|
||||
|
||||
}
|
||||
|
||||
@@ -25,22 +25,22 @@ interface B {
|
||||
@JvmStatic
|
||||
var foo = 1
|
||||
|
||||
@JvmStatic
|
||||
var foo1 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
var foo1<!> = 1
|
||||
protected set
|
||||
|
||||
@JvmStatic
|
||||
var foo2 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
var foo2<!> = 1
|
||||
private set
|
||||
|
||||
@JvmStatic
|
||||
private var foo3 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
private var foo3<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
protected var foo4 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
protected var foo4<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
protected var foo5 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
protected var foo5<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
val foo6 = 1
|
||||
@@ -52,7 +52,7 @@ interface B {
|
||||
@JvmStatic <!SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY!>public<!> set
|
||||
|
||||
public var foo9 = 1
|
||||
@JvmStatic private set
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic private set<!>
|
||||
|
||||
@JvmStatic
|
||||
val foo10: Int external get
|
||||
@@ -60,4 +60,4 @@ interface B {
|
||||
val foo11: Int @JvmStatic external get
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -7,15 +7,15 @@ interface B {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic private fun a2() {
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic private fun a2()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic protected fun a3() {
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic protected fun a3()<!> {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic internal fun a4() {
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic internal fun a4()<!> {
|
||||
|
||||
}
|
||||
|
||||
@@ -24,22 +24,22 @@ interface B {
|
||||
@JvmStatic
|
||||
var foo = 1
|
||||
|
||||
@JvmStatic
|
||||
var foo1 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
var foo1<!> = 1
|
||||
protected set
|
||||
|
||||
@JvmStatic
|
||||
var foo2 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
var foo2<!> = 1
|
||||
private set
|
||||
|
||||
@JvmStatic
|
||||
private var foo3 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
private var foo3<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
protected var foo4 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
protected var foo4<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
protected var foo5 = 1
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic
|
||||
protected var foo5<!> = 1
|
||||
|
||||
@JvmStatic
|
||||
val foo6 = 1
|
||||
@@ -51,7 +51,7 @@ interface B {
|
||||
@JvmStatic <!SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY!>public<!> set
|
||||
|
||||
public var foo9 = 1
|
||||
@JvmStatic private set
|
||||
<!JVM_STATIC_ON_NON_PUBLIC_MEMBER!>@JvmStatic private set<!>
|
||||
|
||||
@JvmStatic
|
||||
val foo10: Int external get
|
||||
@@ -59,4 +59,4 @@ interface B {
|
||||
val foo11: Int @JvmStatic external get
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -3682,6 +3682,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.JVM_STATIC_ON_NON_PUBLIC_MEMBER) { firDiagnostic ->
|
||||
JvmStaticOnNonPublicMemberImpl(
|
||||
firDiagnostic as FirPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.INAPPLICABLE_JVM_NAME) { firDiagnostic ->
|
||||
InapplicableJvmNameImpl(
|
||||
firDiagnostic as FirPsiDiagnostic,
|
||||
|
||||
+4
@@ -2562,6 +2562,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = JvmStaticNotInObjectOrCompanion::class
|
||||
}
|
||||
|
||||
abstract class JvmStaticOnNonPublicMember : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = JvmStaticOnNonPublicMember::class
|
||||
}
|
||||
|
||||
abstract class InapplicableJvmName : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = InapplicableJvmName::class
|
||||
}
|
||||
|
||||
+7
@@ -4159,6 +4159,13 @@ internal class JvmStaticNotInObjectOrCompanionImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class JvmStaticOnNonPublicMemberImpl(
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.JvmStaticOnNonPublicMember(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class InapplicableJvmNameImpl(
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
override val token: ValidityToken,
|
||||
|
||||
Reference in New Issue
Block a user