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

Several mixin application issues #25765

Closed
sgrekhov opened this issue Feb 11, 2016 · 2 comments
Closed

Several mixin application issues #25765

sgrekhov opened this issue Feb 11, 2016 · 2 comments
Labels
area-specification closed-as-intended Closed as the reported issue is expected behavior type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sgrekhov
Copy link
Contributor

There are several issues here and its unclear which one is an issue and which one is not.

  1. It's not clear from the specification if is it allowed or not if superclass is used as a mixin
class S {
}
class C extends S with S {
}
main() {
  new C();
}

This code produces no warnings in analyzer but when runned

error: super type 'S' may not be listed in implements clause of class 'S&S'
class C extends S with S {
                       ^
  1. The following code works (no warnings in analyzer, no errors when runned)
class A {
}
class S extends A {
}
class C extends S with A {
}
main() {
  new C();
}

In fact both S with S and S with A should not add anything to the superclass of C, but one of them works and the other not.

  1. Again the code below works well
class S {
}
class M {
}
class C extends S with M, M, M, M {
}
main() {
  new C();
}

Was this intended?

Please clarify which of the cases above are bugs and which one not.

Tested on Dart VM version: 1.15.0-dev.2.0 (Wed Feb 10 02:55:12 2016) on "windows_x64"

@anders-sandholm anders-sandholm added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). Type-Defect labels Feb 25, 2016
@anders-sandholm
Copy link
Contributor

Not clear if this is a spec (area-language) or implementation (area-vm) issue.
Feel free to reassign labels as you see fit.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Type-Defect labels Mar 1, 2016
@munificent munificent added area-specification and removed area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Dec 13, 2016
@lrhn
Copy link
Member

lrhn commented Jun 9, 2017

Never noticed this issue before, sorry.

I think the behaviors are all correct.

There is nothing inherently wrong with mixing a mixin derived from a class on top of the class itself.
The only reason you get an error is that applying a mixin also makes the class implement the mixin's class' interface, and there is a specific rule saying that you are not allowed to extend and implement the same type in the same class declaration (not because it matters, it would work perfectly fine, it's just not useful, so it's assumed to be an error).

So, the S with S mixin application introduces a new anonymous class that both extends S and implements S and that gives an error.

The S with M, M introduces a new anonymous class for S with M which implements M, and an anonymous class for (S with M) with M which also implements M, but each class only implements M once, and M itself is not the superclass of any of them.

@lrhn lrhn closed this as completed Jun 9, 2017
@lrhn lrhn added the closed-as-intended Closed as the reported issue is expected behavior label Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-specification closed-as-intended Closed as the reported issue is expected behavior type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants