[breaking change] Change the superinterface of IntX
#59776
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
breaking-change-request
This tracks requests for feedback on breaking changes
Change Intent
IntX
implementsComparable<IntX>
rather thanComparable<Object>
.Justification
Currently,
Int64
andInt32
have no supertypeK
such thatK extends Comparable<K>
. This causes all invocations of methods likesortedBy
to fail. Inference fails, and it is also impossible to specify the actual type argument explicitly because there is no solution to the given constraintK extends Comparable<K>
.The change proposed here makes
IntX
a solution to the constraint, which means that it can be specified manually. Moreover, it can be inferred automatically starting with Dart 3.7.0 (because it has the new feature proposed in dart-lang/language#3009).Impact
No impact is expected.
Of course, it is always possible to find an expression that breaks (
assert(Int64(1) is! Comparable<IntX>)
), but the change did not give rise to any failures in a TAP Presubmit in internal code, and there are no known examples of breakage with any practical relevance.Mitigation
No mitigation needed. Developers may wish to use
sortedBy
and similar methods in situations where it was previously not possible, but this is an option, not a necessity.Change Timeline
ASAP.
Associated CLs
https://dart-review.googlesource.com/c/core/+/401680
The text was updated successfully, but these errors were encountered: