Shadowing happens when overriding method
- Langage dominant
- CodeQL
- Étoiles
- 10.1k
- Forks
- 2.1k
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 141
Description
Consider the following example:
##### MyCallable.qll
```codeql
import java
class CallableByErasure extends Callable {
override predicate hasQualifiedName(string package, string type, string name) {
this.isDeclaredIn(package, type) and this.hasName(name)
}
predicate isDeclaredIn(string package, string type) {
this.getDeclaringType().getErasure().(RefType).hasQualifiedName(package, type)
}
}
```
##### Query.ql
```codeql
import java
// import MyCallable
from Call c
where c.getCallee().hasQualifiedName("java.util", "Set", "iterator")
select c
```
The query correctly finds one instance (see test case below).
If I uncomment `import MyCallable` however, then the query does not return anything. Is this expected behaviour? How do I prevent this from happening?
This is the test case I used:
```java
import java.util.HashSet;
import java.util.Set;
class GenericsClass {
public void foo() {
Set set = new HashSet();
set.iterator();
}
}
```
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.