Reified classes #3368
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
type-enhancement
A request for a change that isn't a bug
Milestone
This issue was originally filed by [email protected]
What steps will reproduce the problem?
The class of an object is not accessible what leads to some shortcomings when implementing the operator == in a class hierarchy (please correct me if I am wrong). For example the following code is rather repetitive and error prone:
class A {
var a;
operator == (other) => other is A && a == other.a;
}
class B extends A {
var b;
// alternatively we could call super, but that would do unnecessary class checks
operator == (other) => other is B && a == other.a && b == other.b;
}
class C extends B {
// alternatively we could call super, but that would do unnecessary class checks
operator == (other) => other is C && a == other.a && b == other.b;
}
What is the expected output? What do you see instead?
class A {
var a;
// access to a comparable class object would simplify the code
operator == (other) => this.class == other.class && a == other.a;
}
class B extends A {
var b;
operator == (other) => super == other && b == other.b;
}
class C extends B {
// no necessary to implement operator == here
}
What version of the product are you using? On what operating system?
Dart SDK version 7904
The text was updated successfully, but these errors were encountered: