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

Fix conversion of signed constants to unsigned #1277

Merged
merged 1 commit into from
Jun 24, 2023

Conversation

sifmelcara
Copy link
Contributor

Signed integer constant cannot be automatically converted to unsigned integer anymore after Kotlin 1.9.0.

See https://youtrack.jetbrains.com/issue/KT-56583 for detail

Signed integer constant cannot be automatically converted to unsigned
integer anymore after Kotlin 1.9.0.

See https://youtrack.jetbrains.com/issue/KT-56583 for detail
@JakeWharton
Copy link
Collaborator

I had no idea you could use lowercase letters. I think we should always use uppercase because a lowercase L can be mistaken for the number 1.

@JakeWharton
Copy link
Collaborator

JakeWharton commented Jun 22, 2023

Although weirdly in reviewing some of my own code I like lowercase f apparently.

Also fun/horrific fact: You can write 1uL as valid Kotlin 😩

@oldergod
Copy link
Member

We don't need test to cover that?

@JakeWharton
Copy link
Collaborator

It's not a behavior change that can be tested, it's a language change. Before there was an implicit type conversation and now that type conversation either needs to be explicit (toUInt()) or the literal needs changed to the right type (this PR).

@sifmelcara
Copy link
Contributor Author

Examples in official doc uses lower case u https://kotlinlang.org/docs/unsigned-integer-types.html#unsigned-integers-literals , but I can change it to upper case if you prefer

@JakeWharton
Copy link
Collaborator

No. Thanks for the link, though. I'll discuss it somewhere else and won't hold this up any longer. Then maybe we can get enforcement from ktlint.

@JakeWharton JakeWharton merged commit e937a50 into square:master Jun 24, 2023
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.

3 participants