Immutables: stagedBuilder=true and implementationNestedInBuilder=true don't work together

Created on 27 Mar 2018  路  3Comments  路  Source: immutables/immutables

example code:
https://gist.github.com/nogenerics/40598533d6a5bef5776cfb04e3e4f9e8

note: the ABuildStage, BBuildStage, BuildFinal interfaces are not generated, I did not omit any files

same results for 2.5.5, 2.5.6, and 2.6.0-alpha1

bug completed

Most helpful comment

In my opinion staged builder has sense when using external builder, but it requires private constructor of builder and static method to create builder returning first interface.

In this way we can achieve external builder with compile-time safety to a building.

All 3 comments

Thank you for reporting this! This use case (combination) is not implemented properly, and need to be fixed

As I've started to "solve" this by generating interfaces outside of the builders, I became apparent that this combination just makes no sense: by creating an external builder, we receive full builder with no enforcement of stage interfaces, defeating the purpose. The fix is auto-disabling staged builder when external/outer builder is used, sorry for the inconvenience, but it's troublesome and makes not much sense to support this combination.

In my opinion staged builder has sense when using external builder, but it requires private constructor of builder and static method to create builder returning first interface.

In this way we can achieve external builder with compile-time safety to a building.

Was this page helpful?
0 / 5 - 0 ratings