dart-lang / dart-lang/language

Should inline class members with same names as those of the field be targets of lint?

Open
#3,168 8 comments 0 reactions 0 assignees View on GitHub
extension-types-later
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

For the same reason of prohibiting to override `toString()`, it is very confusing.

```dart
inline class Id {
final int value;
Id(this.value);
bool get isEven => value.isOdd; // lying. Should this be a target of lint?
}

main() {
Id id = Id(123);
print(id.isEven); // true (deceived)
dynamic d = id;
print(d.isEven); // false
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the inline class Id example in the issue and reproduce the differing isEven results for static and dynamic access. Determine whether this naming pattern should be covered by a lint, then document the intended rule and its expected diagnostic behavior; no implementation files or tests are identified in the issue.

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.