Skip to content

Commit 25fcae1

Browse files
committed
Java: Make some types more specific
Where we used to use RefType, we now use ClassOrInterface.
1 parent 9fbff1b commit 25fcae1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

java/ql/lib/semmle/code/java/Generics.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import Type
3838
*
3939
* For example, `X` in `class X<T> { }`.
4040
*/
41-
class GenericType extends RefType {
41+
class GenericType extends ClassOrInterface {
4242
GenericType() { typeVars(_, _, _, _, this) }
4343

4444
/**
@@ -139,7 +139,7 @@ abstract class BoundedType extends RefType, @boundedtype {
139139
*/
140140
class TypeVariable extends BoundedType, @typevariable {
141141
/** Gets the generic type that is parameterized by this type parameter, if any. */
142-
RefType getGenericType() { typeVars(this, _, _, _, result) }
142+
GenericType getGenericType() { typeVars(this, _, _, _, result) }
143143

144144
/** Gets the generic callable that is parameterized by this type parameter, if any. */
145145
GenericCallable getGenericCallable() { typeVars(this, _, _, _, result) }
@@ -321,7 +321,7 @@ class TypeBound extends @typebound {
321321
* For example, `List<Number>` is a parameterization of
322322
* the generic type `List<E>`, where `E` is a type parameter.
323323
*/
324-
class ParameterizedType extends RefType {
324+
class ParameterizedType extends ClassOrInterface {
325325
ParameterizedType() {
326326
typeArgs(_, _, this) or
327327
typeVars(_, _, _, _, this)
@@ -367,7 +367,7 @@ class ParameterizedType extends RefType {
367367
}
368368

369369
/** Holds if this type originates from source code. */
370-
override predicate fromSource() { typeVars(_, _, _, _, this) and RefType.super.fromSource() }
370+
override predicate fromSource() { typeVars(_, _, _, _, this) and ClassOrInterface.super.fromSource() }
371371

372372
override string getAPrimaryQlClass() { result = "ParameterizedType" }
373373
}

java/ql/lib/semmle/code/java/Import.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ImportType extends Import {
2525
ImportType() { imports(this, _, _, 1) }
2626

2727
/** Gets the imported type. */
28-
RefType getImportedType() { imports(this, result, _, _) }
28+
ClassOrInterface getImportedType() { imports(this, result, _, _) }
2929

3030
override string toString() { result = "import " + this.getImportedType().toString() }
3131

@@ -44,7 +44,7 @@ class ImportOnDemandFromType extends Import {
4444
ImportOnDemandFromType() { imports(this, _, _, 2) }
4545

4646
/** Gets the type from which accessible nested types are imported. */
47-
RefType getTypeHoldingImport() { imports(this, result, _, _) }
47+
ClassOrInterface getTypeHoldingImport() { imports(this, result, _, _) }
4848

4949
/** Gets an imported type. */
5050
NestedType getAnImport() { result.getEnclosingType() = this.getTypeHoldingImport() }
@@ -87,7 +87,7 @@ class ImportStaticOnDemand extends Import {
8787
ImportStaticOnDemand() { imports(this, _, _, 4) }
8888

8989
/** Gets the type from which accessible static members are imported. */
90-
RefType getTypeHoldingImport() { imports(this, result, _, _) }
90+
ClassOrInterface getTypeHoldingImport() { imports(this, result, _, _) }
9191

9292
/** Gets an imported type. */
9393
NestedType getATypeImport() { result.getEnclosingType() = this.getTypeHoldingImport() }
@@ -118,7 +118,7 @@ class ImportStaticTypeMember extends Import {
118118
ImportStaticTypeMember() { imports(this, _, _, 5) }
119119

120120
/** Gets the type from which static members with a given name are imported. */
121-
RefType getTypeHoldingImport() { imports(this, result, _, _) }
121+
ClassOrInterface getTypeHoldingImport() { imports(this, result, _, _) }
122122

123123
/** Gets the name of the imported member(s). */
124124
override string getName() { imports(this, _, result, _) }

0 commit comments

Comments
 (0)