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

Allow abstract classes to be instantiated given definitions of all abstract methods #55544

Closed
lukehutch opened this issue Apr 22, 2024 · 1 comment

Comments

@lukehutch
Copy link

lukehutch commented Apr 22, 2024

Dart does not currently support anonymous classes, and does not allow for abstract classes to be instantiated.

Without necessarily going all the way to supporting anonymous classes, it would be nice to be able to at least instantiate abstract classes by providing definitions for all abstract methods:

abstract class Point {
  int x();
  int y();
}

final origin = Point() {
  int x() => 0;
  int y() => 0;
};

Right now the only alternative is to use function-typed fields.

@mraleph
Copy link
Member

mraleph commented Apr 24, 2024

Without necessarily going all the way to supporting anonymous classes

What you are asking is pretty much the same as an anonymous class.

So this is duplicate of dart-lang/language#2927

@mraleph mraleph closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants