mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Merge pull request #10221 from tamasvajk/kotlin-internal
Kotlin: Change `Modifiable::isPublic` to not cover Kotlin `internal` members
This commit is contained in:
@@ -7,7 +7,13 @@ import Element
|
||||
/** A modifier such as `private`, `static` or `abstract`. */
|
||||
class Modifier extends Element, @modifier {
|
||||
/** Gets the element to which this modifier applies. */
|
||||
Element getElement() { hasModifier(result, this) }
|
||||
Element getElement() {
|
||||
hasModifier(result, this) and
|
||||
// Kotlin "internal" elements may also get "public" modifiers, so we want to filter those out
|
||||
not exists(Modifier mod2 |
|
||||
hasModifier(result, mod2) and modifiers(this, "public") and modifiers(mod2, "internal")
|
||||
)
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() { result = "Modifier" }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Java {
|
||||
void javaFun() {
|
||||
new Kotlin().kotlinFun$main();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class Kotlin {
|
||||
internal fun kotlinFun() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
isPublic
|
||||
isInternal
|
||||
| Kotlin.kt:2:11:3:2 | kotlinFun$main |
|
||||
modifiers_methods
|
||||
| file://:0:0:0:0 | final | Kotlin.kt:2:11:3:2 | kotlinFun$main |
|
||||
| file://:0:0:0:0 | internal | Kotlin.kt:2:11:3:2 | kotlinFun$main |
|
||||
#select
|
||||
| Kotlin.kt:2:11:3:2 | kotlinFun$main | final |
|
||||
| Kotlin.kt:2:11:3:2 | kotlinFun$main | internal |
|
||||
@@ -0,0 +1,13 @@
|
||||
import java
|
||||
|
||||
from Method m, string s
|
||||
where m.fromSource() and m.hasModifier(s)
|
||||
select m, s
|
||||
|
||||
query predicate isPublic(Method m) { m.fromSource() and m.isPublic() }
|
||||
|
||||
query predicate isInternal(Method m) { m.fromSource() and m.isInternal() }
|
||||
|
||||
query predicate modifiers_methods(Modifier mo, Method me) {
|
||||
mo.getElement() = me and me.fromSource()
|
||||
}
|
||||
Reference in New Issue
Block a user