@@ -289,10 +289,31 @@ predicate resolveTypeExpr(TypeExpr te, Type t) {
289289 else
290290 if primTypeName ( te .getClassName ( ) )
291291 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+ base .getADependency * ( ) = sup
295311 )
312+ or
313+ // for tests, and other cases where no qlpack exists.
314+ not exists ( YAML:: QLPack base | te .getFile ( ) = base .getAFileInPack ( ) )
315+ )
316+ )
296317}
297318
298319pragma [ noinline]
0 commit comments