@@ -7,7 +7,13 @@ import Element
77/** A modifier such as `private`, `static` or `abstract`. */
88class Modifier extends Element , @modifier {
99 /** Gets the element to which this modifier applies. */
10- Element getElement ( ) { hasModifier ( result , this ) }
10+ Element getElement ( ) {
11+ hasModifier ( result , this ) and
12+ // Kotlin "internal" elements may also get "public" modifiers, so we want to filter those out
13+ not exists ( Modifier mod2 |
14+ hasModifier ( result , mod2 ) and modifiers ( this , "public" ) and modifiers ( mod2 , "internal" )
15+ )
16+ }
1117
1218 override string getAPrimaryQlClass ( ) { result = "Modifier" }
1319}
@@ -25,7 +31,15 @@ abstract class Modifiable extends Element {
2531 * abstract, so `isAbstract()` will hold for them even if `hasModifier("abstract")`
2632 * does not.
2733 */
28- predicate hasModifier ( string m ) { modifiers ( this .getAModifier ( ) , m ) }
34+ predicate hasModifier ( string m ) {
35+ exists ( Modifier mod | mod = this .getAModifier ( ) |
36+ modifiers ( mod , m ) and
37+ // Kotlin "internal" elements may also get "public" modifiers, so we want to filter those out
38+ not exists ( Modifier mod2 |
39+ hasModifier ( this , mod2 ) and modifiers ( mod , "public" ) and modifiers ( mod2 , "internal" )
40+ )
41+ )
42+ }
2943
3044 /** Holds if this element has no modifier. */
3145 predicate hasNoModifier ( ) { not hasModifier ( this , _) }
@@ -46,11 +60,8 @@ abstract class Modifiable extends Element {
4660 // TODO: `isSealed()` conflicts with `ClassOrInterface.isSealed()`. What name do we want to use here?
4761 predicate isSealedKotlin ( ) { this .hasModifier ( "sealed" ) }
4862
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 ( ) }
63+ /** Holds if this element has a `public` modifier or is implicitly public. */
64+ predicate isPublic ( ) { this .hasModifier ( "public" ) }
5465
5566 /** Holds if this element has a `protected` modifier. */
5667 predicate isProtected ( ) { this .hasModifier ( "protected" ) }
0 commit comments