Kotlin: Extract type parameter modifiers (reified, in, out)

This commit is contained in:
Tamas Vajk
2022-10-04 14:23:57 +02:00
parent 7ac9c1e832
commit 9eea6d4193
6 changed files with 51 additions and 14 deletions

View File

@@ -137,7 +137,7 @@ abstract class BoundedType extends RefType, @boundedtype {
* For example, `T` is a type parameter in
* `class X<T> { }` and in `<T> void m() { }`.
*/
class TypeVariable extends BoundedType, @typevariable {
class TypeVariable extends BoundedType, Modifiable, @typevariable {
/** Gets the generic type that is parameterized by this type parameter, if any. */
GenericType getGenericType() { typeVars(this, _, _, _, result) }

View File

@@ -96,4 +96,13 @@ abstract class Modifiable extends Element {
/** Holds if this element has a `lateinit` modifier. */
predicate isLateinit() { this.hasModifier("lateinit") }
/** Holds if this element has a `reified` modifier. */
predicate isReified() { this.hasModifier("reified") }
/** Holds if this element has an `in` modifier. */
predicate isIn() { this.hasModifier("in") }
/** Holds if this element has an `out` modifier. */
predicate isOut() { this.hasModifier("out") }
}