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

UIP-2258 Workaround for Dart 1.23 strong mode issue with MapViewMixin #65

Merged
merged 2 commits into from
May 2, 2017
Merged
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
20 changes: 15 additions & 5 deletions lib/src/component_declaration/component_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,22 @@ abstract class UiProps
Function get componentFactory;
}

/// A class that declares the `_map` getter shared by [PropsMapViewMixin]/[StateMapViewMixin] and [MapViewMixin].
///
/// Necessary in order to work around Dart 1.23 strong mode change that disallows conflicting private members
/// in mixins: <https://github.com/dart-lang/sdk/issues/28809>.
abstract class _OverReactMapViewBase<K, V> {
Map<K, V> get _map;
}

/// Works in conjunction with [MapViewMixin] to provide [dart.collection.MapView]-like
/// functionality to [UiProps] subclasses.
abstract class PropsMapViewMixin {
abstract class PropsMapViewMixin implements _OverReactMapViewBase {
/// The props maintained by this builder and used passed into the component when built.
/// In this case, it's the current MapView object.
Map get props;

@override
Map get _map => this.props;

@override
Expand All @@ -426,8 +436,10 @@ abstract class PropsMapViewMixin {

/// Works in conjunction with [MapViewMixin] to provide [dart.collection.MapView]-like
/// functionality to [UiState] subclasses.
abstract class StateMapViewMixin {
abstract class StateMapViewMixin implements _OverReactMapViewBase {
Map get state;

@override
Map get _map => this.state;

@override
Expand All @@ -441,9 +453,7 @@ abstract class StateMapViewMixin {
///
/// For use by concrete [UiProps] and [UiState] implementations (either generated or manual),
/// and thus must remain public.
abstract class MapViewMixin<K, V> {
Map<K, V> get _map;

abstract class MapViewMixin<K, V> implements _OverReactMapViewBase<K, V> {
V operator[](Object key) => _map[key];
void operator[]=(K key, V value) { _map[key] = value; }
void addAll(Map<K, V> other) { _map.addAll(other); }
Expand Down