RFR: [type-classes] Fix issue with type class op resolution inside speculative attribution
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Jan 27 12:24:15 UTC 2026
On Tue, 27 Jan 2026 12:10:22 GMT, Danish Nawab <duke at openjdk.org> wrote:
>> During speculative attribution of lambda expressions, we might get to the unary/binary op resolution code with erroneous types.
>> When this happens, type class witness resolution fails if Numerical/Integral are tweaked to contain witness methods.
>>
>> This PR fixes this condition and adds a test.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Operators.java line 594:
>
>> 592: public boolean test(Env<AttrContext> env, Type arg1, Type arg2) {
>> 593: if (types.unboxedTypeOrType(arg1).isPrimitive() ||
>> 594: types.unboxedTypeOrType(arg1).isPrimitive() ||
>
> `types.unboxedTypeOrType(arg1).isPrimitive()` is repeated twice. Perhaps the intention was to check arg**2** instead?
>
> Suggestion:
>
> if (types.unboxedTypeOrType(arg1).isPrimitive() ||
> types.unboxedTypeOrType(arg2).isPrimitive() ||
Whoops -- good catch :-)
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1981#discussion_r2731757238
More information about the valhalla-dev
mailing list