Do not check visibility of enum entries in explicit api mode

Although they're instances of DeclarationDescriptorWithVisibility,
they can't have visibilities

#KT-37040 Fixed
This commit is contained in:
Leonid Startsev
2020-03-06 18:41:18 +03:00
parent 753d4b3cbd
commit 5d73550b48
2 changed files with 10 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -21,6 +21,7 @@ class ExplicitApiDeclarationChecker : DeclarationChecker {
if (state == ExplicitApiMode.DISABLED) return
if (descriptor !is DeclarationDescriptorWithVisibility) return
if (descriptor is ClassDescriptor && descriptor.kind == ClassKind.ENUM_ENTRY) return // Enum entries does not have visibilities
if (!descriptor.isEffectivelyPublicApi) return
checkVisibilityModifier(state, declaration, descriptor, context)
@@ -39,6 +39,11 @@ public data class FooData(val i: Int, val s: String)
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>data class FooData2<!>(val i: Int, val s: String)
public class WithNested {
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>class Nested<!> {}
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>inner class Inner<!> {}
}
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>
class Nested<!> {}
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>
inner class Inner<!> {}
}
<!NO_EXPLICIT_VISIBILITY_IN_API_MODE!>enum class Foo<!> { A, B }
public enum class Bar { A, B }