RFR: [type-classes] Fix issue with type class op resolution inside speculative attribution

Danish Nawab duke at openjdk.org
Tue Jan 27 12:12:42 UTC 2026


On Tue, 27 Jan 2026 11:50:01 GMT, Maurizio Cimadamore <mcimadamore 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() ||

-------------

PR Review Comment: https://git.openjdk.org/valhalla/pull/1981#discussion_r2731714581


More information about the valhalla-dev mailing list