dart-lang / dart-lang/language

Context type intentionally different from parameter type in non-standard `==`?

Open
#3,098 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-inference
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Consider the following program:

```dart
X getContextType() {
print(X);
throw 0;
}

class A {
bool operator ==(covariant A other) => identical(this, other);
}

void main() {
A() == getContextType(); // Prints 'dynamic'.
}
```

I would expect the context type to be `A?`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Dart program and confirming the reported dynamic context type for getContextType(). Then read the language specification and existing discussions around operator ==, covariant parameters, and context types; done means reaching and documenting a settled decision about whether the context should be A?.

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.