@@ -289,10 +289,41 @@ predicate resolveTypeExpr(TypeExpr te, Type t) {
289
289
else
290
290
if primTypeName ( te .getClassName ( ) )
291
291
then t = TPrimitive ( te .getClassName ( ) )
292
- else
293
- exists ( FileOrModule m , boolean public , string clName | qualifier ( te , m , public , clName ) |
294
- defines ( m , clName , t , public )
292
+ else resolveTypeExpr2 ( te , t )
293
+ }
294
+
295
+ pragma [ noopt]
296
+ predicate resolveTypeExpr2 ( TypeExpr te , Type t ) {
297
+ exists ( FileOrModule m , boolean public , string clName |
298
+ qualifier ( te , m , public , clName ) and
299
+ defines ( m , clName , t , public ) and
300
+ // there can be some cross-talk between modules due to collapsing parameterized modules. This should remove the worst.
301
+ // require that the Type is contained in the same pack or a dependency.
302
+ (
303
+ exists ( YAML:: QLPack base , YAML:: QLPack sup |
304
+ te .getFile ( ) = base .getAFileInPack ( ) and
305
+ exists ( AstNode decl , File f |
306
+ decl = t .getDeclaration ( ) and
307
+ f = decl .getFile ( ) and
308
+ f = sup .getAFileInPack ( )
309
+ ) and
310
+ (
311
+ base .getADependency * ( ) = sup
312
+ or
313
+ // only interested in blocking language -> language flow, so we include if one of the packs is shared (has no dbscheme).
314
+ not exists ( YAML:: QLPack dep | dep = base .getADependency * ( ) | exists ( dep .getDBScheme ( ) ) )
315
+ or
316
+ not exists ( YAML:: QLPack dep | dep = sup .getADependency * ( ) | exists ( dep .getDBScheme ( ) ) )
317
+ )
295
318
)
319
+ or
320
+ // for tests, and other cases where no qlpack exists.
321
+ not exists ( YAML:: QLPack base | te .getFile ( ) = base .getAFileInPack ( ) )
322
+ or
323
+ // e.g. alias for primitives.
324
+ not exists ( t .getDeclaration ( ) )
325
+ )
326
+ )
296
327
}
297
328
298
329
pragma [ noinline]
0 commit comments