Skip to content

Commit 3513bb8

Browse files
committed
Kotlin: Change Modifiable::isPublic to not cover Kotlin internal members
1 parent d9086e6 commit 3513bb8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

java/ql/lib/semmle/code/java/Modifier.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ abstract class Modifiable extends Element {
4646
// TODO: `isSealed()` conflicts with `ClassOrInterface.isSealed()`. What name do we want to use here?
4747
predicate isSealedKotlin() { this.hasModifier("sealed") }
4848

49-
/** Holds if this element has a `public` modifier or is implicitly public. */
50-
predicate isPublic() { this.hasModifier("public") }
49+
/**
50+
* Holds if this element has a `public` modifier or is implicitly public.
51+
* Kotlin `internal` members, which are `public` in JVM Bytecode, are not considered `public`.
52+
*/
53+
predicate isPublic() { this.hasModifier("public") and not this.isInternal() }
5154

5255
/** Holds if this element has a `protected` modifier. */
5356
predicate isProtected() { this.hasModifier("protected") }

java/ql/test/kotlin/library-tests/java_and_kotlin_internal/visibility.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
isPublic
2-
| Kotlin.kt:2:11:3:2 | kotlinFun$main |
32
isInternal
43
| Kotlin.kt:2:11:3:2 | kotlinFun$main |
54
#select

0 commit comments

Comments
 (0)