Revert "Minor: cover negative cases with test +m"
This reverts commit 04a4f9cd
This commit is contained in:
+4
-6
@@ -18,16 +18,14 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class JvmStaticInPrivateCompanionChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
val containingDeclaration = descriptor.containingDeclaration
|
||||
|
||||
if (containingDeclaration !is ClassDescriptor
|
||||
|| !containingDeclaration.isCompanionObject
|
||||
|| !Visibilities.isPrivate(containingDeclaration.visibility.delegate)
|
||||
) return
|
||||
descriptor.containingDeclaration.safeAs<ClassDescriptor>()?.takeIf {
|
||||
it.isCompanionObject && Visibilities.isPrivate(it.visibility.delegate)
|
||||
} ?: return
|
||||
|
||||
val jvmStaticAnnotation = descriptor.annotations.findAnnotation(JVM_STATIC_ANNOTATION_FQ_NAME) ?: return
|
||||
|
||||
val reportTarget = jvmStaticAnnotation.source.safeAs<KotlinSourceElement>()?.psi ?: return
|
||||
val reportTarget = jvmStaticAnnotation.source.safeAs<KotlinSourceElement>()?.psi ?: declaration
|
||||
context.trace.report(JVM_STATIC_IN_PRIVATE_COMPANION.on(reportTarget))
|
||||
}
|
||||
}
|
||||
Vendored
+1
-28
@@ -26,31 +26,4 @@ class WithPrivateCompanion {
|
||||
@JvmStatic
|
||||
fun staticFunction() {}
|
||||
}
|
||||
}
|
||||
|
||||
class WithPublicCompanion {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val staticVal1: Int = 42
|
||||
|
||||
val staticVal2: Int
|
||||
@JvmStatic get() = 42
|
||||
|
||||
@get:JvmStatic
|
||||
val staticVal3: Int = 42
|
||||
|
||||
@JvmStatic
|
||||
var staticVar1: Int = 42
|
||||
|
||||
var staticVar2: Int
|
||||
@JvmStatic get() = 42
|
||||
@JvmStatic set(value) {}
|
||||
|
||||
@get: JvmStatic
|
||||
@set: JvmStatic
|
||||
var staticVar3: Int = 42
|
||||
|
||||
@JvmStatic
|
||||
fun staticFunction() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+1
-28
@@ -26,31 +26,4 @@ class WithPrivateCompanion {
|
||||
<!JVM_STATIC_IN_PRIVATE_COMPANION!>@JvmStatic<!>
|
||||
fun staticFunction() {}
|
||||
}
|
||||
}
|
||||
|
||||
class WithPublicCompanion {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val staticVal1: Int = 42
|
||||
|
||||
val staticVal2: Int
|
||||
@JvmStatic get() = 42
|
||||
|
||||
@get:JvmStatic
|
||||
val staticVal3: Int = 42
|
||||
|
||||
@JvmStatic
|
||||
var staticVar1: Int = 42
|
||||
|
||||
var staticVar2: Int
|
||||
@JvmStatic get() = 42
|
||||
@JvmStatic set(value) {}
|
||||
|
||||
@get: JvmStatic
|
||||
@set: JvmStatic
|
||||
var staticVar3: Int = 42
|
||||
|
||||
@JvmStatic
|
||||
fun staticFunction() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
-21
@@ -20,24 +20,3 @@ public final class WithPrivateCompanion {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public final class WithPublicCompanion {
|
||||
public constructor WithPublicCompanion()
|
||||
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
|
||||
|
||||
public companion object Companion {
|
||||
private constructor Companion()
|
||||
@kotlin.jvm.JvmStatic public final val staticVal1: kotlin.Int = 42
|
||||
@get:kotlin.jvm.JvmStatic public final val staticVal2: kotlin.Int
|
||||
@get:kotlin.jvm.JvmStatic public final val staticVal3: kotlin.Int = 42
|
||||
@kotlin.jvm.JvmStatic public final var staticVar1: kotlin.Int
|
||||
@get:kotlin.jvm.JvmStatic @set:kotlin.jvm.JvmStatic public final var staticVar2: kotlin.Int
|
||||
@get:kotlin.jvm.JvmStatic @set:kotlin.jvm.JvmStatic public final var staticVar3: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@kotlin.jvm.JvmStatic public final fun staticFunction(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user