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

Improve type conversions #178

Merged
merged 7 commits into from
May 2, 2024
Merged

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Feb 5, 2024

Fixes #177

@Ladicek Ladicek requested review from dmlloyd and mkouba February 5, 2024 13:54
@Ladicek
Copy link
Contributor Author

Ladicek commented Feb 5, 2024

Probably best to review each commit in isolation.

I made the "smart cast" operation a Gizmo.smartCast() static method. It felt wrong to make it a method on BytecodeCreator, because it doesn't correspond to anything the JVM or the Java language would do, but I realize this makes it less discoverable. I could probably be persuaded to move it.

@Ladicek Ladicek force-pushed the better-conversions branch from 412c54b to 0490cc7 Compare February 5, 2024 13:58
@mkouba
Copy link
Contributor

mkouba commented Feb 5, 2024

I made the "smart cast" operation a Gizmo.smartCast() static method. It felt wrong to make it a method on BytecodeCreator, because it doesn't correspond to anything the JVM or the Java language would do, but I realize this makes it less discoverable. I could probably be persuaded to move it.

We should at least add link/note to Gizmo.smartCast() in the javadoc of BytecodeCreator#checkCast() and BytecodeCreator#convertPrimitive()...

@gsmet
Copy link
Member

gsmet commented Feb 5, 2024

Yeah, I think we should favor discoverability.

@Ladicek Ladicek force-pushed the better-conversions branch 2 times, most recently from 840e2ba to 81d6b98 Compare February 5, 2024 16:19
@Ladicek Ladicek force-pushed the better-conversions branch from 81d6b98 to f6c656c Compare February 6, 2024 09:45
@Ladicek
Copy link
Contributor Author

Ladicek commented Feb 6, 2024

OK, so I think I finally fixed primitive conversions in case of byte, short and char (my previous belief that these conversions are implicit, since the values are ints on the JVM stack, was sorely mistaken).

So now we just need to agree on where the "smart cast" operation should be.

@mkouba
Copy link
Contributor

mkouba commented Feb 6, 2024

So now we just need to agree on where the "smart cast" operation should be.

For me, the static method is fine but on the other hand I don't think that the BytecodeCreator must only contain stuff that would correspond to anything the JVM or the Java language would do... so maybe you should be persuaded to move it ;-).

@gsmet
Copy link
Member

gsmet commented Feb 6, 2024

If it wasn't clear, I'm in the BytecodeCreator camp :).

@Ladicek Ladicek force-pushed the better-conversions branch from f6c656c to 2a80988 Compare February 6, 2024 11:18
@Ladicek
Copy link
Contributor Author

Ladicek commented Feb 6, 2024

OK, you guys have made your opinion very clear. Moved to BytecodeCreator :-)

@Ladicek Ladicek force-pushed the better-conversions branch from 2a80988 to 63f7056 Compare February 6, 2024 11:52
@Ladicek Ladicek force-pushed the better-conversions branch from 63f7056 to cb93b2e Compare February 6, 2024 12:39
@holly-cummins
Copy link
Contributor

It looks like this got lost a bit, so nudging it. :)

@Ladicek
Copy link
Contributor Author

Ladicek commented May 2, 2024

Ah sorry, totally forgot about this!

@Ladicek Ladicek merged commit 6ce6c2c into quarkusio:main May 2, 2024
2 checks passed
@Ladicek Ladicek deleted the better-conversions branch May 2, 2024 07:34
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.

Smart cast operation
5 participants