Skip to content

Conversation

dmlloyd
Copy link
Member

@dmlloyd dmlloyd commented May 22, 2025

Fixes #389

@dmlloyd dmlloyd added the 2.x Issue applies to Gizmo 2.x label May 22, 2025
@Ladicek
Copy link
Contributor

Ladicek commented May 27, 2025

Here's a summary of what this PR does:

AnnotatableCreator.withAnnotation -> addAnnotation
AnnotationCreator.with -> add
AnnotationCreator.withArray -> addArray
ExecutableCreator.withType -> setType
FieldCreator.withType -> setType
FieldCreator.withInitial -> setInitial
FieldCreator.withInitializer -> setInitializer
ModifiableCreator.withFlag -> addFlag
ModifiableCreator.withFlags -> addFlags
ModifiableCreator.withoutFlag -> removeFlag
ModifiableCreator.withoutFlags -> removeFlags
ModifiableCreator.withAccess -> setAccess
ParamCreator.withType -> setType
TypeVariableCreator.withFirstBound -> setFirstBound
TypeVariableCreator.withOtherBounds -> setOtherBounds

I'm missing TypeCreator.withVersion, but other than that, it seems comprehensive. Do you want to fix that in this PR? It can wait for another, for sure.

A few remarks, but I don't want them to be addressed in this PR: I would personally name the setType method (on ExecutableCreator, FieldCreator and ParamCreator) just type (together with setInitial and setInitializer on FieldCreator), but that's perhaps just me. Also, I would collapse setFirstBound and setOtherBounds on TypeVariableCreator to setBounds (or just bounds), but I would like to do more changes on generic types, so let's just ignore that :-)

@dmlloyd
Copy link
Member Author

dmlloyd commented May 27, 2025

Here's a summary of what this PR does:


AnnotatableCreator.withAnnotation -> addAnnotation

AnnotationCreator.with -> add

AnnotationCreator.withArray -> addArray

ExecutableCreator.withType -> setType

FieldCreator.withType -> setType

FieldCreator.withInitial -> setInitial

FieldCreator.withInitializer -> setInitializer

ModifiableCreator.withFlag -> addFlag

ModifiableCreator.withFlags -> addFlags

ModifiableCreator.withoutFlag -> removeFlag

ModifiableCreator.withoutFlags -> removeFlags

ModifiableCreator.withAccess -> setAccess

ParamCreator.withType -> setType

TypeVariableCreator.withFirstBound -> setFirstBound

TypeVariableCreator.withOtherBounds -> setOtherBounds

I'm missing TypeCreator.withVersion, but other than that, it seems comprehensive. Do you want to fix that in this PR? It can wait for another, for sure.

Sure, I can do that when I get started today.

A few remarks, but I don't want them to be addressed in this PR: I would personally name the setType method (on ExecutableCreator, FieldCreator and ParamCreator) just type (together with setInitial and setInitializer on FieldCreator), but that's perhaps just me.

I'll look into that as well this morning.

Also, I would collapse setFirstBound and setOtherBounds on TypeVariableCreator to setBounds (or just bounds), but I would like to do more changes on generic types, so let's just ignore that :-)

Unfortunately that would be incorrect. The first bound is special (and optional) not just due to the class file API but also due to requirements of the class file format itself, and also the JLS. Generally the first bound can be a type variable or a class, and the extra bounds must be interfaces (but only if the first bind is not a type variable).

@Ladicek
Copy link
Contributor

Ladicek commented May 27, 2025

Unfortunately that would be incorrect. The first bound is special (and optional) not just due to the class file API but also due to requirements of the class file format itself, and also the JLS. Generally the first bound can be a type variable or a class, and the extra bounds must be interfaces (but only if the first bind is not a type variable).

Yeah, I realized just a while ago that it would be incorrect, but the reason is more subtle: a type variable may have interface type bounds without having a class type bound (aka implicit object bound). That is, the API must allow setting other bounds without setting the first bound.

@dmlloyd
Copy link
Member Author

dmlloyd commented May 27, 2025

The withVersion issue is fixed.

@dmlloyd
Copy link
Member Author

dmlloyd commented May 27, 2025

And the merge issue too.

@Ladicek
Copy link
Contributor

Ladicek commented May 28, 2025

Merging this. Let's submit other PRs if we want to adjust more :-)

@Ladicek Ladicek merged commit 9d12786 into quarkusio:main May 28, 2025
1 check passed
@dmlloyd dmlloyd deleted the with branch May 28, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issue applies to Gizmo 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A mix of naming strategy
2 participants