Confusing error message when inheriting from an abstract class with a factory without providing a factory

abstract class Foo {
  factory Foo([var message]) => new _Object();
}

class Bar<T> extends Foo {
}

[error] The generative constructor ‘Foo([dynamic message]) → Foo’ expected, but factory found (test.dart, line 5, col 7)

This error message is really unclear, especially if you’ve never seen the actual definition of class Foo (and even then, if you’re not particularly familiar with Dart).

I would have been less confused with the following message, or something like it:

“Class Bar extends abstract class Foo which declares a factory ‘Foo([dynamic message]) → Foo’, but class Bar doesn’t provide an implementation for that factory.”

Author: Fantashit

2 thoughts on “Confusing error message when inheriting from an abstract class with a factory without providing a factory

  1. I guess the message should really be “Class Bar extends abstract class Foo which does not declare a generative constructor and therefore cannot be extended”, or something?

Comments are closed.