github / github/codeql

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

Đang mở
#5,707 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement Java
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

### 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/)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.