Integrated: [type-classes]: Lowered code for operator for type class operators is missing a cast

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jan 26 19:52:17 UTC 2026


On Mon, 26 Jan 2026 10:30:56 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> When we lower an unary/binary type class-mediated operation:
> 
> 
> P p1 = ... ; P p2 = ...
> p1 + p2
> 
> 
> To:
> 
> 
> Numerical<P>.__witness.add(p1, p2)
> 
> 
> We should add a cast to the resulting expression, as the result type of the witness method (e.g. `add`, in this case) is generic, and its erasure is just `Object`.
> Leaving the type as is leads to verifier errors due to wrong stack maps being generated.

This pull request has now been integrated.

Changeset: ddd948a1
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/valhalla/commit/ddd948a1fb86d873834f8fe0e37df1f74331d535
Stats:     88 lines in 2 files changed: 74 ins; 6 del; 8 mod

[type-classes]: Lowered code for operator for type class operators is missing a cast

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

PR: https://git.openjdk.org/valhalla/pull/1968


More information about the valhalla-dev mailing list