dart-lang / dart-lang/language

Make sure type-special-casing for numbers is updated to account for extension types.

Open
#3,203 5 comments 2 reactions 1 assignee Claimed by @lrhn View on GitHub
extension-types-later
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Extension types allow introducing subtypes of `num` and `int`.
We should make sure that the special-case rules for typing of `int + int` are aware of this, and figure out what we want them to do when meeting a surprising subtype of `int`.

If the rules usees phrasing as "is a non-`Never` subtype of `int`", that's no longer guaranteed to be the type `int` or a type variable with bound or promotion to `int`, or necessarily use the `operator+` of `int`.

We may just have to add something like "and the `+` operator an instance member, not an extension type member" to discount a subtype which shadows the instance method with an extension method.

But first we should look at the rules, figure out if there is a problem, and whether or not, if they should be changed.
(We may *want* extension type subtypes of `int` to work in some cases, where they wouldn't with the current phrasing. Impossible to know without checking.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.