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

fix(scale): take descending items into account for hashCode #151

Merged
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
7 changes: 5 additions & 2 deletions lib/src/scale/scale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ class Scale<T extends Scalable<T>> implements Transposable<Scale<T>> {
bool operator ==(Object other) =>
other is Scale<T> &&
ListEquality<T>().equals(items, other.items) &&
ListEquality<T>().equals(descendingItems, other.descendingItems);
ListEquality<T>().equals(_descendingItems, other._descendingItems);

@override
int get hashCode => Object.hashAll(items);
int get hashCode => Object.hash(
Object.hashAll(items),
_descendingItems != null ? Object.hashAll(_descendingItems!) : null,
);
}

extension _ListScalableExtension<T extends Scalable<T>> on List<T> {
Expand Down
7 changes: 6 additions & 1 deletion lib/src/scale/scale_pattern.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,10 @@ final class ScalePattern {
.equals(_descendingIntervalSteps, other._descendingIntervalSteps);

@override
int get hashCode => Object.hashAll(intervalSteps);
int get hashCode => Object.hash(
Object.hashAll(intervalSteps),
_descendingIntervalSteps != null
? Object.hashAll(_descendingIntervalSteps!)
: null,
);
}