github / github/codeql

Java: IntersectionType is missing predicates and does not work correctly

Đang mở
#5,403 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
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ả

There are several issues with [`IntersectionType`](https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/Type.qll/type.Type$IntersectionType.html):
- It currently only provides `getFirstBound()`, there are no other predicates to get the other bounds (though `getASubtype()` can apparently be used as workaround)
- It does not preserve order of the bounds (i.e. `MyInterface2 & MyInterface1` would become MyInterface1 & MyInterface2)
- It requires that `getFirstBound()` is a class, returning `Object` when only interfaces are used as bounds; that is (to my understanding) wrong

It would be good to give it the following predicates:
- `getFirstBoundType()`
- `getBoundType(int position)`
- `getABoundType()`

(I cannot submit a pull request for this because it appears that database changes are required for this)

Side note: Usage of `IntersectionType` in `erase(Type)` will also behave incorrectly due to the `getFirstBound()` behavior described above, and also does not match the JLS which [does not mention intersection types](https://docs.oracle.com/javase/specs/jls/se15/html/jls-4.html#jls-4.6) for type erasure (not sure what the correct behavior would be here).
https://github.com/github/codeql/blob/a760ed8c557ae34fa96b306f5cf79e013cfdeaa2/java/ql/src/semmle/code/java/Type.qll#L1014

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.