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

Dart: fix problems with default values that use immutable types #1623

Merged

Conversation

pwrobeldev
Copy link
Contributor

This series fixes problems that occur when either 'Immutable'
or 'PositionalDefaults' annotation is used in combination with
immutable types that have default value.

In both cases the resulting code did not contain the required
'const' keyword.

-------- Content of change --------

  • New smoke and functional tests that were used to confirm
    the invalid behavior.
  • Adjustments of 'DartStructConstructors.mustache' file to
    correctly prepend 'const' keyword when needed for immutable
    struct fields.

This change is used to showcase the invalid behavior of
Dart generator. Usage of 'Immutable' annotation combined
with field, which has default value and uses immutable
struct type yields the code that does not compile.

The generator does not apply 'const' keyword before the calls
to constructors of structures. It is required, because the
constructor of 'Immutable' structure is marked as 'const'.

Signed-off-by: Patryk Wrobel <[email protected]>
…not compile

This change is used to showcase the invalid behavior of
Dart generator. Usage of 'PositionalDefaults' annotation combined
with field, which has default value and uses immutable
struct type yields the code that does not compile.

The generator does not apply 'const' keyword before the calls
to constructors of structures. It is required, because the
value of optional parameters must use 'const' keyword.

Signed-off-by: Patryk Wrobel <[email protected]>
This change ensures that the required 'const' keyword
is prepended to constructor call when needed in the case
of 'DartStructConstructors.mustache' and usage of struct
types for fields with default values.

Signed-off-by: Patryk Wrobel <[email protected]>
This commit describes the implemented bug-fix

Signed-off-by: Patryk Wrobel <[email protected]>
@pwrobeldev pwrobeldev requested a review from Hsilgos November 25, 2024 08:32
@pwrobeldev pwrobeldev merged commit 92226b7 into master Nov 27, 2024
17 checks passed
@pwrobeldev pwrobeldev deleted the pwrobeldev/immutable-struct-field-with-default-value branch November 27, 2024 06:53
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.

2 participants