这是indexloc提供的服务,不要输入任何密码
Skip to content

Make compareTo more robust in semantics.dart #81083

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

Merged
merged 1 commit into from
Apr 23, 2021
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
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/semantics/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ class _BoxEdge implements Comparable<_BoxEdge> {

@override
int compareTo(_BoxEdge other) {
return (offset - other.offset).sign.toInt();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add an assert just so that it still crashes in debug mode. Otherwise, I feel we won't ever figure out what the issue is.

Copy link
Member Author

Choose a reason for hiding this comment

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

line 2333 has the assert that will trigger before this line crashes.

return offset.compareTo(other.offset);
}
}

Expand Down Expand Up @@ -2381,7 +2381,7 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> {

@override
int compareTo(_SemanticsSortGroup other) {
return (startOffset - other.startOffset).sign.toInt();
return startOffset.compareTo(other.startOffset);
}

/// Sorts this group assuming that [nodes] belong to the same vertical group.
Expand Down