@@ -640,7 +640,7 @@ class FieldDecl extends TFieldDecl, AstNode {
640
640
/**
641
641
* A type reference, such as `DataFlow::Node`.
642
642
*/
643
- class TypeExpr extends TType , AstNode {
643
+ class TypeExpr extends TType , TypeRef {
644
644
QL:: TypeExpr type ;
645
645
646
646
TypeExpr ( ) { this = TType ( type ) }
@@ -677,10 +677,14 @@ class TypeExpr extends TType, AstNode {
677
677
*/
678
678
ModuleExpr getModule ( ) { toQL ( result ) = type .getQualifier ( ) }
679
679
680
- /**
681
- * Gets the type that this type reference refers to.
682
- */
683
- Type getResolvedType ( ) { resolveTypeExpr ( this , result ) }
680
+ /** Gets the type that this type reference refers to. */
681
+ override Type getResolvedType ( ) {
682
+ // resolve type
683
+ resolveTypeExpr ( this , result )
684
+ or
685
+ // if it resolves to a module
686
+ exists ( FileOrModule mod | resolveModuleRef ( this , mod ) | result = mod .toType ( ) )
687
+ }
684
688
685
689
override AstNode getAChild ( string pred ) {
686
690
result = super .getAChild ( pred )
@@ -713,7 +717,7 @@ class Module extends TModule, ModuleDeclaration {
713
717
}
714
718
715
719
/** Gets a ref to the module that this module implements. */
716
- ModuleParameterRef getImplements ( int i ) { toQL ( result ) = mod .getImplements ( i ) .getTypeExpr ( ) }
720
+ TypeExpr getImplements ( int i ) { toQL ( result ) = mod .getImplements ( i ) .getTypeExpr ( ) }
717
721
718
722
/** Gets the module expression that this module is an alias for, if any. */
719
723
ModuleExpr getAlias ( ) { toQL ( result ) = mod .getAFieldOrChild ( ) .( QL:: ModuleAliasBody ) .getChild ( ) }
@@ -1111,18 +1115,18 @@ class InlineCast extends TInlineCast, Expr {
1111
1115
}
1112
1116
}
1113
1117
1114
- /** An entity that resolves to a module. */
1115
- class ModuleRef extends AstNode , TModuleRef {
1116
- /** Gets the module that this entity resolves to. */
1117
- FileOrModule getResolvedModule ( ) { none ( ) }
1118
+ /** An entity that resolves to a type. */
1119
+ class TypeRef extends AstNode , TTypeRef {
1120
+ abstract Type getResolvedType ( ) ;
1118
1121
1119
- string getName ( ) { none ( ) }
1122
+ /** Gets the module that this entity resolves to, if this reference resolves to a module */
1123
+ final FileOrModule getResolvedModule ( ) { result .toType ( ) = this .getResolvedType ( ) }
1120
1124
}
1121
1125
1122
1126
/**
1123
1127
* An import statement.
1124
1128
*/
1125
- class Import extends TImport , ModuleMember , ModuleRef {
1129
+ class Import extends TImport , ModuleMember , TypeRef {
1126
1130
QL:: ImportDirective imp ;
1127
1131
1128
1132
Import ( ) { this = TImport ( imp ) }
@@ -1173,7 +1177,9 @@ class Import extends TImport, ModuleMember, ModuleRef {
1173
1177
)
1174
1178
}
1175
1179
1176
- final override FileOrModule getResolvedModule ( ) { resolve ( this , result ) }
1180
+ override Type getResolvedType ( ) {
1181
+ exists ( FileOrModule mod | resolve ( this , mod ) | result = mod .toType ( ) )
1182
+ }
1177
1183
}
1178
1184
1179
1185
/** A formula, such as `x = 6 and y < 5`. */
@@ -2191,18 +2197,8 @@ class DontCare extends TDontCare, Expr {
2191
2197
override string getAPrimaryQlClass ( ) { result = "DontCare" }
2192
2198
}
2193
2199
2194
- /**
2195
- * A type expression seen as a reference to a module as part of a parameterized module (or it's instantiation).
2196
- * This might not be a reference to a module, but we assume so until we find out in the resolve phase.
2197
- */
2198
- class ModuleParameterRef extends ModuleRef instanceof TypeExpr {
2199
- final override FileOrModule getResolvedModule ( ) { resolveModuleRef ( this , result ) }
2200
-
2201
- override string getName ( ) { result = TypeExpr .super .getClassName ( ) }
2202
- }
2203
-
2204
2200
/** A module expression. Such as `DataFlow` in `DataFlow::Node` */
2205
- class ModuleExpr extends TModuleExpr , ModuleRef {
2201
+ class ModuleExpr extends TModuleExpr , TypeRef {
2206
2202
QL:: ModuleExpr me ;
2207
2203
2208
2204
ModuleExpr ( ) { this = TModuleExpr ( me ) }
@@ -2216,7 +2212,7 @@ class ModuleExpr extends TModuleExpr, ModuleRef {
2216
2212
*
2217
2213
* is `Bar`.
2218
2214
*/
2219
- override string getName ( ) {
2215
+ string getName ( ) {
2220
2216
result = me .getName ( ) .( QL:: SimpleId ) .getValue ( )
2221
2217
or
2222
2218
not exists ( me .getName ( ) ) and result = me .getChild ( ) .( QL:: SimpleId ) .getValue ( )
@@ -2237,7 +2233,9 @@ class ModuleExpr extends TModuleExpr, ModuleRef {
2237
2233
*/
2238
2234
ModuleExpr getQualifier ( ) { result = TModuleExpr ( me .getChild ( ) ) }
2239
2235
2240
- final override FileOrModule getResolvedModule ( ) { resolveModuleRef ( this , result ) }
2236
+ override Type getResolvedType ( ) {
2237
+ exists ( FileOrModule mod | resolveModuleRef ( this , mod ) | result = mod .toType ( ) )
2238
+ }
2241
2239
2242
2240
final override string toString ( ) { result = this .getName ( ) }
2243
2241
@@ -2269,7 +2267,7 @@ class SignatureExpr extends TSignatureExpr, AstNode {
2269
2267
SignatureExpr ( ) {
2270
2268
toQL ( this ) = sig .getPredicate ( )
2271
2269
or
2272
- toQL ( this ) = sig .getTypeExpr ( ) // both `TypeExpr` and `ModuleParameterRef`
2270
+ toQL ( this ) = sig .getTypeExpr ( )
2273
2271
}
2274
2272
2275
2273
/** Gets the generated AST node that contains this signature expression. */
@@ -2280,8 +2278,6 @@ class SignatureExpr extends TSignatureExpr, AstNode {
2280
2278
2281
2279
/** Gets this signature expression if it represents a type expression. */
2282
2280
TypeExpr asType ( ) { result = this }
2283
-
2284
- ModuleParameterRef asModuleRef ( ) { result = this }
2285
2281
}
2286
2282
2287
2283
/** An argument to an annotation. */
0 commit comments