dart-lang / dart-lang/language

Add infer keyword

Open
#2,173 13 comments 3 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Let:
```
abstract class Entity {
T get id;
}

class EntityStore, K> {
T getById(K id) {
...
}
}

class Customer extends Entity {
final int id;
Customer(this.id);
}
```

Calling Code:
`final store = EntityStore();`

But type parameter `K` could already be inferred from `T`:
`final store = EntityStore(); // this doesn't work`

I propose `infer` keyword for type parameters that could be inferred from other type parameters:
`class EntityStore, infer K> {}`

Contributor guide

Open the contributing guide

Research direction

Start with the examples in issue #2173 and read its 13-comment thread to understand the proposed infer keyword and the type relationship it targets. Done means the language design has a resolved decision and documented behavior for the EntityStore examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.