github / github/codeql

Shadowing happens when overriding method

Aberta
#15,525 3 comentários 0 reações 0 responsáveis Ver no GitHub
Java question
Linguagem predominante
CodeQL
Estrelas
10.1k
Forks
2.1k
Merge médio
2d 15h
PRs com merge (30d)
141

Descrição

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();
}
}
```

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.