@@ -130,6 +130,12 @@ private module Cached {
130130 )
131131 )
132132 }
133+
134+ cached
135+ Method lookupMethod ( Module m , string name ) { TMethod ( result ) = lookupMethodOrConst ( m , name ) }
136+
137+ cached
138+ Expr lookupConst ( Module m , string name ) { TExpr ( result ) = lookupMethodOrConst ( m , name ) }
133139}
134140
135141import Cached
@@ -340,24 +346,39 @@ private Module getAncestors(Module m) {
340346 result = getAncestors ( m .getAPrependedModule ( ) )
341347}
342348
343- Method getMethod ( TModule owner , string name ) {
344- exists ( ModuleBase m | m .getModule ( ) = owner and result = m .getMethod ( name ) )
349+ private newtype TMethodOrExpr =
350+ TMethod ( Method m ) or
351+ TExpr ( Expr e )
352+
353+ private TMethodOrExpr getMethodOrConst ( TModule owner , string name ) {
354+ exists ( ModuleBase m | m .getModule ( ) = owner |
355+ result = TMethod ( m .getMethod ( name ) )
356+ or
357+ result = TExpr ( m .getConstant ( name ) )
358+ )
359+ }
360+
361+ module ExposedForTestingOnly {
362+ Method getMethod ( TModule owner , string name ) { TMethod ( result ) = getMethodOrConst ( owner , name ) }
363+
364+ Expr getConst ( TModule owner , string name ) { TExpr ( result ) = getMethodOrConst ( owner , name ) }
345365}
346366
347- private Method lookupMethod0 ( Module m , string name ) {
348- result = lookupMethod0 ( m .getAPrependedModule ( ) , name )
367+ private TMethodOrExpr lookupMethodOrConst0 ( Module m , string name ) {
368+ result = lookupMethodOrConst0 ( m .getAPrependedModule ( ) , name )
349369 or
350- not exists ( getMethod ( getAncestors ( m .getAPrependedModule ( ) ) , name ) ) and
370+ not exists ( getMethodOrConst ( getAncestors ( m .getAPrependedModule ( ) ) , name ) ) and
351371 (
352- result = getMethod ( m , name )
372+ result = getMethodOrConst ( m , name )
353373 or
354- not exists ( getMethod ( m , name ) ) and result = lookupMethod0 ( m .getAnIncludedModule ( ) , name )
374+ not exists ( getMethodOrConst ( m , name ) ) and
375+ result = lookupMethodOrConst0 ( m .getAnIncludedModule ( ) , name )
355376 )
356377}
357378
358- Method lookupMethod ( Module m , string name ) {
359- result = lookupMethod0 ( m , name )
379+ private TMethodOrExpr lookupMethodOrConst ( Module m , string name ) {
380+ result = lookupMethodOrConst0 ( m , name )
360381 or
361- not exists ( lookupMethod0 ( m , name ) ) and
362- result = lookupMethod ( m .getSuperClass ( ) , name )
382+ not exists ( lookupMethodOrConst0 ( m , name ) ) and
383+ result = lookupMethodOrConst ( m .getSuperClass ( ) , name )
363384}
0 commit comments