FasterXML / FasterXML/java-classmate

Unintuitive information about member methods wrt return type covariance

未关闭
#57 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
266
派生
47
平均合并
1 小时 42 分钟
30 天内合并 PR
1

描述

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.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。