Ruby: fix regression for methods in singleton classes

This commit is contained in:
Asger F 2022-10-14 11:57:35 +02:00
Родитель 30f7380f74
Коммит 8228730634
2 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -413,10 +413,10 @@ private module Cached {
// end
// end
// ```
exists(Module target |
exists(Module target, MethodBase caller |
target = m.getSuperClass*() and
selfInMethod(sourceNode.(SsaSelfDefinitionNode).getVariable(), any(SingletonMethod sm),
target) and
selfInMethod(sourceNode.(SsaSelfDefinitionNode).getVariable(), caller, target) and
singletonMethod(caller, _, _) and
// Singleton methods declared in a block in the top-level may spuriously end up being seen as singleton
// methods on Object, if the block is actually evaluated in the context of another class.
// The 'self' inside such a singleton method could then be any class, leading to self-calls

Просмотреть файл

@ -265,6 +265,8 @@ getTarget
| private.rb:104:1:104:20 | call to new | calls.rb:117:5:117:16 | new |
| private.rb:104:1:104:28 | call to call_m1 | private.rb:91:3:93:5 | call_m1 |
| private.rb:105:1:105:20 | call to new | calls.rb:117:5:117:16 | new |
| toplevel_self_singleton.rb:29:13:29:19 | call to call_me | toplevel_self_singleton.rb:25:9:26:11 | call_me |
| toplevel_self_singleton.rb:30:13:30:20 | call to call_you | toplevel_self_singleton.rb:28:9:31:11 | call_you |
unresolvedCall
| calls.rb:23:9:23:19 | call to singleton_m |
| calls.rb:26:9:26:18 | call to instance_m |
@ -356,8 +358,6 @@ unresolvedCall
| toplevel_self_singleton.rb:13:9:13:27 | call to ab_singleton_method |
| toplevel_self_singleton.rb:17:12:21:1 | call to new |
| toplevel_self_singleton.rb:19:9:19:27 | call to ab_singleton_method |
| toplevel_self_singleton.rb:29:13:29:19 | call to call_me |
| toplevel_self_singleton.rb:30:13:30:20 | call to call_you |
privateMethod
| calls.rb:1:1:3:3 | foo |
| calls.rb:39:1:41:3 | call_instance_m |