github / github/codeql

Java: `MemberRefExpr.getReferencedCallable()` does not work for creation of arrays

未关闭
#5,707 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement Java
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

### Description
When a Method Reference Expression performs creation of an array (e.g. `String[]::new`), `MemberRefExpr.getReferencedCallable()` has no result.

This is technically correct since there exists no 'array constructor', however it might make working with `MemberRefExpr` more cumbersome. I created this issue mainly to discuss how this can be solved, or how the current situation can be improved. A few solutions might be:
- Model a 'dummy' array constructor so `getReferencedCallable()` has a result; however, make sure that no other element by accident has this dummy constructor as result (e.g. array creation expression)
- Adjust the documentation for `getReferencedCallable()` and create a new predicate `getCreatedArrayType()` which has in these cases the result

### Example
CodeQL query:
```ql
import java

from MemberRefExpr m
where not exists(m.getReferencedCallable())
select m
```
[Query Console link](https://lgtm.com/query/8386794043699946607/)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。