FasterXML / FasterXML/java-classmate

Unintuitive information about member methods wrt return type covariance

Aberta
#57 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Java
Estrelas
266
Forks
47
Merge médio
1h 42min
PRs com merge (30d)
1

Descrição

I've recently come across a surprising behaviour regarding `MemberResolver`'s `getMemberMethods`. Consider the following classes:

```java
interface Foo {}

class Bar implements Foo {}

interface A {
Foo doSomething();
}

class B {
public Bar doSomething() {
return null;
}
}

class C extends B implements A {}
```

Notice that `C` implements `A.doSomething()` through `B.doSomething()`.

When inspecting the members of C like this:

```java
var typeResolver = new TypeResolver();
var methods = new MemberResolver(typeResolver).resolve(typeResolver.resolve(C.class), null, null).getMemberMethods();
```

`methods` will contain a single method - `public abstract Foo A.doSomething()`. However, this doesn't tell the whole story - notice that `B.doSomething` actually returns a `Bar` instead of a `Foo`. Therefore, in this case I'd expect `methods` to contain `public Bar B.doSomething()`, which gives me more information than `A.doSomething()` does.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

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.