github / github/codeql

Java: Wildcard reports implicit Object as bound

Abierto
#5,405 1 comentario 0 reacciones 0 asignados Ver en GitHub
question
Lenguaje dominante
CodeQL
Estrellas
10.1k
Forks
2.1k
Merge medio
2 d 15 h
PR fusionados (30 d)
141

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.