Java: Wildcard reports implicit Object as bound
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 141
Beschreibung
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.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.