Ruby: Use another join order for nested constant lookup

This commit is contained in:
Asger F
2022-11-01 15:22:54 +01:00
parent a195ea942e
commit 0f1b3486de

View File

@@ -1106,8 +1106,8 @@ private newtype TConstLookupScope =
MkQualifiedLookup(ConstantAccess base) or
/** Look up in the ancestors of `mod`. */
MkAncestorLookup(Module mod) or
/** Look up in a module syntactically nested in `scope`. */
MkNestedLookup(ModuleBase scope) or
/** Look up in a module syntactically nested in a declaration of `mod`. */
MkNestedLookup(Module mod) or
/** Pseudo-scope for accesses that are known to resolve to `mod`. */
MkExactLookup(Module mod)
@@ -1178,15 +1178,6 @@ class ConstRef extends LocalSourceNode {
*/
private ModuleNode getAncestryTarget() { result.getAnAncestorExpr() = this }
/**
* Gets a module scope in which the value of this constant is part of `Module.nesting`.
*/
private ModuleBase getANestingScope() {
result = this.getAncestryTarget().getADeclaration()
or
result.getEnclosingModule() = this.getANestingScope()
}
/**
* Gets the known target module.
*
@@ -1204,7 +1195,7 @@ class ConstRef extends LocalSourceNode {
access = any(ConstantAccess ac).getScopeExpr() and
result = MkQualifiedLookup(access)
or
result = MkNestedLookup(this.getANestingScope())
result = MkNestedLookup(this.getAncestryTarget())
or
result = MkExactLookup(access.(Namespace).getModule())
}
@@ -1224,7 +1215,7 @@ class ConstRef extends LocalSourceNode {
(
result = MkAncestorLookup(access.getEnclosingModule().getNamespaceOrToplevel().getModule())
or
result = MkNestedLookup(access.getEnclosingModule())
result = MkNestedLookup(access.getEnclosingModule().getEnclosingModule*().getModule())
)
}