Skip to content
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

Closed
johnniwinther opened this issue Jan 31, 2014 · 5 comments
Closed

Interface inheritance and override rules are unclear #16443

johnniwinther opened this issue Jan 31, 2014 · 5 comments
Labels
area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@johnniwinther
Copy link
Member

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.
}

@jwren
Copy link
Member

jwren commented Feb 19, 2014

Marked this as blocking #16498.

@gbracha
Copy link
Contributor

gbracha commented Feb 19, 2014

The text should be clarified to state: 'declares a member" as that is the original intent.


Added Accepted label.

@johnniwinther johnniwinther added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Feb 19, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@munificent munificent added area-specification (deprecated) Deprecated: use area-language and a language- label. and removed area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Dec 15, 2016
@eernstg
Copy link
Member

eernstg commented Feb 7, 2018

No Dart 2 milestone: This is now considered a subtask of #31228, which has a Dart 2 milestone.

@eernstg
Copy link
Member

eernstg commented Feb 9, 2018

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).

@eernstg
Copy link
Member

eernstg commented Jan 8, 2019

Said feature specification was completed, and then 614ae7f integrated this topic into dartLangSpec.tex.

@eernstg eernstg closed this as completed Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants