Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support universal equality of unsigned numeric types #3584

Merged

Conversation

WojciechMazur
Copy link
Contributor

This change allows to use universal equality for combination of signed and unsigned numeric types. It means we can run comparisons like 2 + 2 == 4.toUInt, or -1.toUByte == 255.
To allow for that when used in erased context, we modify the NIR generated for == and != primitives. These now would delegate to scala.runtime.BoxesRunTime.equals instead of delegating to custom Object.__scala_== which now becomes obsolete and removed.

All numeric equality comparsions are now available between any of Byte, Short, Int, Long, UByte, UShort, UInt, UByte, Size, USize and Char.

Copy link
Member

@ekrich ekrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is a great change.

docs/user/interop.rst Outdated Show resolved Hide resolved
auxlib/src/main/scala/scala/runtime/BoxesRunTime.scala Outdated Show resolved Hide resolved
@WojciechMazur WojciechMazur merged commit a79fb09 into scala-native:main Oct 29, 2023
61 checks passed
@WojciechMazur WojciechMazur deleted the unsiged/universal-equality branch October 29, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants