Skip to content

[breaking change] Change the superinterface of IntX #59776

Closed
@eernstg

Description

@eernstg

Change Intent

IntX implements Comparable<IntX> rather than Comparable<Object>.

Justification

Currently, Int64 and Int32 have no supertype K such that K extends Comparable<K>. This causes all invocations of methods like sortedBy to fail. Inference fails, and it is also impossible to specify the actual type argument explicitly because there is no solution to the given constraint K 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

dart-lang/core#866

Metadata

Metadata

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.breaking-change-approvedbreaking-change-requestThis tracks requests for feedback on breaking changes

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions