diff --git a/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt b/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt index fa5013f7616..1d8efaabbf3 100644 --- a/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt +++ b/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt @@ -16,13 +16,13 @@ package org.jetbrains.kotlin.allopen -import org.jetbrains.annotations.TestOnly import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.extensions.AnnotationBasedExtension import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.KtCallableDeclaration import org.jetbrains.kotlin.psi.KtModifierListOwner import org.jetbrains.kotlin.resolve.BindingContext @@ -48,6 +48,10 @@ abstract class AbstractAllOpenDeclarationAttributeAltererExtension : Declaration return null } + if (modifierListOwner.hasModifier(KtTokens.PRIVATE_KEYWORD) && modifierListOwner is KtCallableDeclaration) { + return null + } + val descriptor = declaration as? ClassDescriptor ?: containingDeclaration ?: return null if (descriptor.hasSpecialAnnotation(modifierListOwner)) { return if (modifierListOwner.hasModifier(KtTokens.FINAL_KEYWORD)) diff --git a/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt new file mode 100644 index 00000000000..33668e5fcbb --- /dev/null +++ b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt @@ -0,0 +1,16 @@ +annotation class AllOpen + +@AllOpen +private class Test { + fun publicMethod() {} + val publicProp: String = "" + + protected fun protectedMethod() {} + protected val protectedProp: String = "" + + private fun privateMethod() {} + private val privateProp: String = "" + + internal fun internalMethod() {} + internal val internalProp: String = "" +} \ No newline at end of file diff --git a/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt new file mode 100644 index 00000000000..bf60c617304 --- /dev/null +++ b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt @@ -0,0 +1,20 @@ +@java.lang.annotation.Retention +@kotlin.Metadata +public annotation class AllOpen + +@AllOpen +@kotlin.Metadata +class Test { + private final @org.jetbrains.annotations.NotNull field internalProp: java.lang.String + private final field privateProp: java.lang.String + private final @org.jetbrains.annotations.NotNull field protectedProp: java.lang.String + private final @org.jetbrains.annotations.NotNull field publicProp: java.lang.String + public method (): void + public @org.jetbrains.annotations.NotNull method getInternalProp$test_module(): java.lang.String + protected @org.jetbrains.annotations.NotNull method getProtectedProp(): java.lang.String + public @org.jetbrains.annotations.NotNull method getPublicProp(): java.lang.String + public method internalMethod$test_module(): void + private final method privateMethod(): void + protected method protectedMethod(): void + public method publicMethod(): void +} diff --git a/plugins/plugins-tests/tests/org/jetbrains/kotlin/allopen/BytecodeListingTestForAllOpenGenerated.java b/plugins/plugins-tests/tests/org/jetbrains/kotlin/allopen/BytecodeListingTestForAllOpenGenerated.java index 53dd0112bad..ca197c4c6a5 100644 --- a/plugins/plugins-tests/tests/org/jetbrains/kotlin/allopen/BytecodeListingTestForAllOpenGenerated.java +++ b/plugins/plugins-tests/tests/org/jetbrains/kotlin/allopen/BytecodeListingTestForAllOpenGenerated.java @@ -78,6 +78,12 @@ public class BytecodeListingTestForAllOpenGenerated extends AbstractBytecodeList doTest(fileName); } + @TestMetadata("privateMembers.kt") + public void testPrivateMembers() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt"); + doTest(fileName); + } + @TestMetadata("sealed.kt") public void testSealed() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("plugins/allopen/allopen-cli/testData/bytecodeListing/sealed.kt");