Merge pull request #10221 from tamasvajk/kotlin-internal

Kotlin: Change `Modifiable::isPublic` to not cover Kotlin `internal` members
This commit is contained in:
Ian Lynagh
2022-09-02 11:51:56 +01:00
committed by GitHub
5 changed files with 38 additions and 1 deletions

View File

@@ -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" }
}

View File

@@ -0,0 +1,5 @@
public class Java {
void javaFun() {
new Kotlin().kotlinFun$main();
}
}

View File

@@ -0,0 +1,4 @@
public class Kotlin {
internal fun kotlinFun() {
}
}

View File

@@ -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 |

View File

@@ -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()
}