@@ -296,9 +296,12 @@ private predicate hasLocation(AstNode n, Location l) {
296296private module ImplicitSelfSynthesis {
297297 pragma [ nomagic]
298298 private predicate identifierMethodCallSelfSynthesis ( AstNode mc , int i , Child child ) {
299- child = SynthChild ( SelfKind ( TSelfVariable ( scopeOf ( toGenerated ( mc ) ) .getEnclosingSelfScope ( ) ) ) ) and
300- mc = TIdentifierMethodCall ( _) and
301- i = 0
299+ exists ( SelfVariableImpl self |
300+ self .getDeclaringScopeImpl ( ) = scopeOf ( toGenerated ( mc ) ) .getEnclosingSelfScope ( ) and
301+ child = SynthChild ( SelfKind ( self ) ) and
302+ mc = TIdentifierMethodCall ( _) and
303+ i = 0
304+ )
302305 }
303306
304307 private class IdentifierMethodCallSelfSynthesis extends Synthesis {
@@ -309,13 +312,14 @@ private module ImplicitSelfSynthesis {
309312
310313 pragma [ nomagic]
311314 private predicate regularMethodCallSelfSynthesis ( TRegularMethodCall mc , int i , Child child ) {
312- exists ( Ruby:: AstNode g |
315+ exists ( Ruby:: AstNode g , SelfVariableImpl self |
313316 mc = TRegularMethodCall ( g ) and
314317 // If there's no explicit receiver, then the receiver is implicitly `self`.
315- not exists ( g .( Ruby:: Call ) .getReceiver ( ) )
316- ) and
317- child = SynthChild ( SelfKind ( TSelfVariable ( scopeOf ( toGenerated ( mc ) ) .getEnclosingSelfScope ( ) ) ) ) and
318- i = 0
318+ not exists ( g .( Ruby:: Call ) .getReceiver ( ) ) and
319+ self .getDeclaringScopeImpl ( ) = scopeOf ( toGenerated ( mc ) ) .getEnclosingSelfScope ( ) and
320+ child = SynthChild ( SelfKind ( self ) ) and
321+ i = 0
322+ )
319323 }
320324
321325 private class RegularMethodCallSelfSynthesis extends Synthesis {
@@ -338,9 +342,10 @@ private module ImplicitSelfSynthesis {
338342 */
339343 pragma [ nomagic]
340344 private SelfKind getSelfKind ( InstanceVariableAccess var ) {
341- exists ( Ruby:: AstNode owner |
345+ exists ( Ruby:: AstNode owner , SelfVariableImpl self |
346+ self .getDeclaringScopeImpl ( ) = scopeOf ( owner ) .getEnclosingSelfScope ( ) and
342347 owner = toGenerated ( instanceVarAccessSynthParentStar ( var ) ) and
343- result = SelfKind ( TSelfVariable ( scopeOf ( owner ) . getEnclosingSelfScope ( ) ) )
348+ result = SelfKind ( self )
344349 )
345350 }
346351
@@ -1556,20 +1561,20 @@ private module ForLoopDesugar {
15561561 * { a: a }
15571562 * ```
15581563 */
1559- private module ImplicitHashValueSynthesis {
1560- private Ruby:: AstNode keyWithoutValue ( AstNode parent , int i ) {
1564+ module ImplicitHashValueSynthesis {
1565+ Ruby:: AstNode keyWithoutValue ( Ruby :: AstNode parent , int i ) {
15611566 exists ( Ruby:: KeywordPattern pair |
15621567 result = pair .getKey ( ) and
1563- result = toGenerated ( parent .( HashPattern ) .getKey ( i ) ) and
1568+ result = parent .( Ruby :: HashPattern ) .getChild ( i ) . ( Ruby :: KeywordPattern ) . getKey ( ) and
15641569 not exists ( pair .getValue ( ) )
15651570 )
15661571 or
1567- exists ( Ruby :: Pair pair |
1568- i = 0 and
1569- result = pair . getKey ( ) and
1570- pair = toGenerated ( parent ) and
1571- not exists ( pair .getValue ( ) )
1572- )
1572+ parent =
1573+ any ( Ruby :: Pair pair |
1574+ i = 0 and
1575+ result = pair . getKey ( ) and
1576+ not exists ( pair .getValue ( ) )
1577+ )
15731578 }
15741579
15751580 private string keyName ( Ruby:: AstNode key ) {
@@ -1579,7 +1584,7 @@ private module ImplicitHashValueSynthesis {
15791584
15801585 private class ImplicitHashValueSynthesis extends Synthesis {
15811586 final override predicate child ( AstNode parent , int i , Child child ) {
1582- exists ( Ruby:: AstNode key | key = keyWithoutValue ( parent , i ) |
1587+ exists ( Ruby:: AstNode key | key = keyWithoutValue ( toGenerated ( parent ) , i ) |
15831588 exists ( TVariableReal variable |
15841589 access ( key , variable ) and
15851590 child = SynthChild ( LocalVariableAccessRealKind ( variable ) )
@@ -1606,7 +1611,7 @@ private module ImplicitHashValueSynthesis {
16061611 }
16071612
16081613 final override predicate location ( AstNode n , Location l ) {
1609- exists ( AstNode p , int i | l = keyWithoutValue ( p , i ) .getLocation ( ) |
1614+ exists ( AstNode p , int i | l = keyWithoutValue ( toGenerated ( p ) , i ) .getLocation ( ) |
16101615 n = p .( HashPattern ) .getValue ( i )
16111616 or
16121617 i = 0 and n = p .( Pair ) .getValue ( )
0 commit comments