RFR: 8174840: Elements.overrides does not check the return type of the methods
Chen Liang
liach at openjdk.org
Mon Jan 6 22:11:37 UTC 2025
On Mon, 6 Jan 2025 22:01:00 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>> test/langtools/tools/javac/processing/model/util/elements/overrides/TestOverrides.java line 54:
>>
>>> 52: if (!elements.overrides(tm, sm, t))
>>> 53: messager.printError(String.format(
>>> 54: "%s does not override %s from %s", tm, sm, t.getQualifiedName()));
>>
>> This message implies `sm` is from `t`, which is not the case. Consider improving the failure message.
>
> This uses the wording from JLS 8.4.8.1 (emphasis mine):
>
>> An instance method `mC` declared in or inherited by class `C`, overrides **from** `C` another method `mA` declared in class `A`, iff all of the following are true:
Then we should use
`String.format("%s does not override from %s %s", tm, t.getQualifiedName(), sm)`. `sm` is not from `t`, the override is instead.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22920#discussion_r1904687031
More information about the compiler-dev
mailing list