github / github/codeql

Java: Wildcard reports implicit Object as bound

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

描述

The class [`Wildcard`](https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/Generics.qll/type.Generics$Wildcard.html) reports `Object` as bound when it has no bounds; this creates inconsistencies and renders some predicates useless:
- [`hasTypeBound()`](https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/Generics.qll/predicate.Generics$Wildcard$hasTypeBound.0.html) (inherited from `BoundedType`) apparently always holds
- `hasTypeBound()` is inconsistent with `TypeVariable.hasTypeBound()` which only holds for explicit bounds
- It is inconistent with [`WildcardTypeAccess`](https://codeql.github.com/codeql-standard-libraries/java/semmle/code/java/Expr.qll/type.Expr$WildcardTypeAccess.html) which only considers explicit bounds (though it could not report the implicit bound anyways since it is not an `Expr`)

Therefore it would be good to change `Wildcard` in the following ways:
- `hasTypeBound()` should only hold if an explicit bound is present
- `getUpperBound()` should only have an explicit bound as result (currently it has the implicit `Object` bound as result)

`hasUpperBound()` can probably remain as is.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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