You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LongLiteralExpressionVisitor stripped the trailing L/l from a Java long
literal and emitted the remaining text verbatim, so the generated C# lost
the suffix that makes it a long.
That produced code which does not compile. C# types a bare numeric literal
as int, so `long a = 0xFFFFFFFFFFFFFFFFL` became `long a = 0xFFFFFFFFFFFFFFFF`
-- a ulong that will not implicitly convert to long (CS0266).
Re-append the suffix when building the literal token, and strip the incoming
L/l as a suffix rather than via a blanket Replace over the whole string.
A hex literal above long.MaxValue stays invalid in C# even with the suffix,
since the literal is typed by its magnitude. For that case emit the wrapped
decimal value, which is the number Java means: 0xFFFFFFFFFFFFFFFFL -> -1L.
The existing long-literal tests only asserted the parsed numeric Value, which
is why this went unnoticed; the new cases assert the emitted token text.
LongLiterals.java covers it end to end through the compile-and-run harness.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments