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

CPLAT-4674: Add workaround for ddc bug via props/state impl constructor #256

Merged
merged 5 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions example/builder/abstract_inheritance.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions example/builder/basic.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 21 additions & 6 deletions example/builder/basic_library.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions example/builder/basic_with_state.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions example/builder/basic_with_type_params.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions example/builder/generic_inheritance_sub.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions example/builder/generic_inheritance_super.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions example/builder/private_component.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions lib/src/builder/generation/impl_generation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,17 @@ class ImplGenerator {
..writeln('//')
..writeln('// Implements constructor and backing map.')
..writeln('class $stateImplName$typeParamsOnClass extends $stateName$typeParamsOnSuper with $stateAccessorsMixinName$typeParamsOnSuper implements $consumableStateName$typeParamsOnSuper {')
..writeln(' $stateImplName(Map backingMap) : this._state = backingMap ?? {};')
..writeln(' // This initializer of `_state` to an empty map, as well as the reassignment')
..writeln(' // of `_state` in the constructor body is necessary to work around an unknown ddc issue.')
..writeln(' // See <https://jira.atl.workiva.net/browse/CPLAT-4673> for more details')
..writeln(' $stateImplName(Map backingMap) : this._state = {} {')
..writeln(' this._state = backingMap ?? {};')
..writeln(' }')
..writeln()
..writeln(' /// The backing state map proxied by this class.')
..writeln(' @override')
..writeln(' Map get state => _state;')
..writeln(' final Map _state;')
..writeln(' Map _state;')
..writeln()
..writeln(' /// Let [UiState] internals know that this class has been generated.')
..writeln(' @override')
Expand Down Expand Up @@ -685,12 +690,17 @@ class ImplGenerator {
..writeln('//')
..writeln('// Implements constructor and backing map, and links up to generated component factory.')
..write(classDeclaration)
..writeln(' $implName(Map backingMap) : this._props = backingMap ?? {};')
..writeln(' // This initializer of `_props` to an empty map, as well as the reassignment')
..writeln(' // of `_props` in the constructor body is necessary to work around an unknown ddc issue.')
..writeln(' // See <https://jira.atl.workiva.net/browse/CPLAT-4673> for more details')
..writeln(' $implName(Map backingMap) : this._props = {} {')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thought of one thing; have you tried initializing to null instead?

Would be nice to avoid this object creation if it's easy to; no big deal if it's a pain to try out, though.

Suggested change
..writeln(' $implName(Map backingMap) : this._props = {} {')
..writeln(' $implName(Map backingMap) : this._props = null {')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this doesn't work in ddc.

..writeln(' this._props = backingMap ?? {};')
..writeln(' }')
..writeln()
..writeln(' /// The backing props map proxied by this class.')
..writeln(' @override')
..writeln(' Map get props => _props;')
..writeln(' final Map _props;')
..writeln(' Map _props;')
..writeln()
..writeln(' /// Let [UiProps] internals know that this class has been generated.')
..writeln(' @override')
Expand Down
9 changes: 7 additions & 2 deletions lib/src/component/resize_sensor.over_react.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading