'Samuel Rawlins' via Dart Misc
2017-03-11 00:04:46 UTC
Hey Dart strong mode experts,
I am wondering why we cannot override fields in strong mode (without
changing type). Take this example:
class A {
int a;
}
class B extends A {
@deprecated
int a;
}
https://dartpad.dartlang.org/69bf3a7802e742e87a9c82b7a641a30a
yields the error: "Field declaration A.a cannot be overridden in B."
I think there are probably many reasons to want to annotate a field from
your super class (mark it @deprecated, or to observe it, or declare it
non-null, etc), and the only way to annotate it is to re-declare it.
A) Why can we not re-declare a field, if we don't change it's type or
access?
B) How else might you annotate a field in your super class?
I am wondering why we cannot override fields in strong mode (without
changing type). Take this example:
class A {
int a;
}
class B extends A {
@deprecated
int a;
}
https://dartpad.dartlang.org/69bf3a7802e742e87a9c82b7a641a30a
yields the error: "Field declaration A.a cannot be overridden in B."
I think there are probably many reasons to want to annotate a field from
your super class (mark it @deprecated, or to observe it, or declare it
non-null, etc), and the only way to annotate it is to re-declare it.
A) Why can we not re-declare a field, if we don't change it's type or
access?
B) How else might you annotate a field in your super class?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.