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
Describe the bug
A class (hierarchy) annotated with @SuperBuilder cannot be instantiated with the builder pattern if any of the super building methods are used from Scala code. (The class (hierarchy in question is built in a Java module before in the same maven project)
The fix would be in the buidler() method of the Child:
@GeneratedprotectedChild(finalChildBuilder<Child, ?> b) {
super(b);
this.group = b.group;
}
because we do know, that we are going to return a Child here, this type would be propagated to all super builders and scala would know the correct type.
The text was updated successfully, but these errors were encountered:
I have never used a @SuperBuilder from Scala, but this looks like a type-inference problem in the Scala compiler. If the same logic implemented as Java code compiles (which I assume), there is probably nothing Lombok can do to mitigate the problem.
As scalac is way more strict with types than javac it might still be a type problem. I will investigate further by building the generated classes by Hand in Java and see what the problem is (and how a fix could be. Maybe you can do a similar approach too?
kurellajunior
changed the title
[BUG] @Superbuilder causes compile error when used from scala code.
[BUG] @Superbuilder causes compile error when used from scala code due to missing type for return type.
Dec 18, 2024
I reduced it to the maximum possible minimum I found and detected the problem. The builder()-method is too weakly typed.
Workaround til fix: cast to correct type in scala code
Describe the bug
A class (hierarchy) annotated with @SuperBuilder cannot be instantiated with the builder pattern if any of the super building methods are used from Scala code. (The class (hierarchy in question is built in a Java module before in the same maven project)
To Reproduce
In a java module:
in the scala module
⇒ leads to compile error
Expected behavior
compiles fine
Version info (please complete the following information):
Additional context
The generated class file:
The fix would be in the
buidler()
method of the Child:because we do know, that we are going to return a Child here, this type would be propagated to all super builders and scala would know the correct type.
The text was updated successfully, but these errors were encountered: