KE2: Populate Kotlin type nullability and alias information

This commit is contained in:
Ian Lynagh
2024-11-21 15:21:11 +00:00
parent 7baeea6365
commit 82c41316c6
5 changed files with 38 additions and 22 deletions

View File

@@ -478,12 +478,12 @@ kt_nullable_types(
)
/**
* `id` is the Kotlin type that is the alias called `name` of `kttypeid`.
* That is, it has been defined by `typealias name = kttypeid`.
* `id` is the Kotlin type that is the alias called `classid` of `kttypeid`.
* That is, it has been defined by `typealias classid = kttypeid`.
*/
kt_type_alias(
kt_type_aliases(
unique int id: @kt_type_alias,
string name: string ref,
int classid: @reftype ref,
int kttypeid: @kt_type ref
)

View File

@@ -42,8 +42,10 @@ predicate hasName(Element e, string name) {
or
modifiers(e, name)
or
kt_type_alias(e, name, _)
or
// TODO: An alias declaration might have a name, but the type that
// uses it doesn't
// or
// kt_type_alias(e, name, _)
ktProperties(e, name)
or
e instanceof ErrorType and name = "<CodeQL error type>"

View File

@@ -32,7 +32,9 @@ class KotlinTypeAlias extends KotlinType, @kt_type_alias {
result = "{" + this.getKotlinType().toString() + "}" + this.getName()
}
override string getName() { kt_type_alias(this, result, _) }
override string getName() { result = this.getAliasClass().getName() }
KotlinType getKotlinType() { kt_type_alias(this, _, result) }
Class getAliasClass() { kt_type_aliases(this, result, _) }
KotlinType getKotlinType() { kt_type_aliases(this, _, result) }
}