Java: Wildcard reports implicit Object as bound
- 主要語言
- 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 還沒有評估資料。