-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interface inheritance and override rules are unclear #16443
Comments
Marked this as blocking #16498. |
The text should be clarified to state: 'declares a member" as that is the original intent. Added Accepted label. |
No Dart 2 milestone: This is now considered a subtask of #31228, which has a Dart 2 milestone. |
This CL contains a proposal for a feature specification about conflict resolution regarding inheritance and overriding which would resolve this issue in a feature spec (remaining: integrate that into dartLangSpec.tex). |
Said feature specification was completed, and then 614ae7f integrated this topic into dartLangSpec.tex. |
The paragraph the defines 'inherited(J, K)' for interfaces (§8.1.1) uses the unclear wording 'm is a member of A' instead of for instance the well-defined 'A declares m'.
This makes is unclear how to handle the synthetic members introduced in case of multiple inherited members.
Consider this:
class A {
method(int a) => null;
}
class B {
method(num a) => null;
}
abstract class C implements A, B {
// C has a 'method' of type '(dynamic) -> dynamic'.
}
class Class implements C {
method(double a) => null;
}
If the synthetic '(dynamic) -> dynamic' method in C is 'a member of C' the checking of 'method' declared in 'Class' should be done against the synthetic member, thus causing no warning since '(double) -> dynamic' is a subtype of '(dynamic) -> dynamic'.
If the synthetic '(dynamic) -> dynamic' method in C is not 'a member of C' the checking of 'method' declared in 'Class' should be done against the members declared in A and B, thus causing a warning for the override of the method declared in A since '(double) -> dynamic' is a not subtype of '(int) -> dynamic'.
I think the latter should be the case, since it would be consistent with the hierarchy in which 'Class' directly overrides methods in 'A' and 'B':
class A {
method(int a) => null;
}
class B {
method(num a) => null;
}
class Class implements A, B {
method(double a) => null; /// warning for the override of A.method.
}
The text was updated successfully, but these errors were encountered: