@@ -7,7 +7,13 @@ import Element
7
7
/** A modifier such as `private`, `static` or `abstract`. */
8
8
class Modifier extends Element , @modifier {
9
9
/** 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
+ }
11
17
12
18
override string getAPrimaryQlClass ( ) { result = "Modifier" }
13
19
}
@@ -25,7 +31,15 @@ abstract class Modifiable extends Element {
25
31
* abstract, so `isAbstract()` will hold for them even if `hasModifier("abstract")`
26
32
* does not.
27
33
*/
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
+ }
29
43
30
44
/** Holds if this element has no modifier. */
31
45
predicate hasNoModifier ( ) { not hasModifier ( this , _) }
@@ -46,11 +60,8 @@ abstract class Modifiable extends Element {
46
60
// TODO: `isSealed()` conflicts with `ClassOrInterface.isSealed()`. What name do we want to use here?
47
61
predicate isSealedKotlin ( ) { this .hasModifier ( "sealed" ) }
48
62
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" ) }
54
65
55
66
/** Holds if this element has a `protected` modifier. */
56
67
predicate isProtected ( ) { this .hasModifier ( "protected" ) }
0 commit comments