[scala] Infer object type for metavariables from object creation if type is not present
Is your feature request related to a problem? Please describe. It would be nice to be able to search for the usage of method calls on particular objects. But scala is not strictly typed language and when type is missed some metavariables do not work, for example: invocation of method makeBean on the object MapToBeanMapperImpl() for the example below.
val mapper = MapToBeanMapperImpl()
($OBJECT : MapToBeanMapperImpl).makeBean
There could be object inheritance, but we could start simple, just take object type on the right.
Describe the solution you'd like A clear and concise description of what you want to happen. https://semgrep.dev/s/eEz0
Describe alternatives you've considered when I need to search for method invocation, I just create patterns to search for object init.
Use case This will allow us to perform better scan for method usage on objects.
This issue is synced in Linear at https://linear.app/r2c/issue/PA-1513/infer-object-type-for-metavariables-from-object-creation-if-type-is. Note: this link is for r2c use only and is not accessible publicly.
Note that that's something DeepSemgrep was designed for.
@aryx what is deep semgrep ? could you share any link ?
https://r2c.dev/blog/2022/introducing-deepSemgrep/
but we can still independently do a best effort for semgrep and try to match the function name to the type in that case. It's nice that scala does not need x = new Foo(), but for us it makes things harder :)
This issue is being marked stale because there hasn't been any activity in 14 days and either it wasn't prioritized or its priority is high. Please apply the appropriate priority:* label before removing the stale label.
Stale-bot has closed this stale item. Please reopen it if this is in error.