freezed
freezed copied to clipboard
Incorrect "The class Foo was declared as abstract, but ..."
Describe the bug I had code with freezed classes that need to be abstract in order to compile, but got a warning at code generation time about this "not being needed anymore".
To Reproduce
Example code (the point is to have some property accessible at the Union
type, which for some subtypes is always the same and shouldn't be passed to their constructor):
@freezed
abstract class Union with _$Union {
const factory Union.int(int value) = _Int;
@With<_HalfMixin>()
const factory Union.half() = _Half;
num get value;
}
abstract class _HalfMixin {
double get value => 0.5;
}
Generated code is working, but it's getting:
The class Union was declared as abstract, but it is not needed anymore.
Read here: https://github.com/rrousselGit/freezed/blob/master/packages/freezed/CHANGELOG.md#0140
Expected behavior No warning in this case and/or a better way to achieve the above.
Remove the abstract keyword. It's not needed
If I remove it, the example does not compile anymore with the error:
'value' must have a method body because 'Union' isn't abstract.
Try making 'Union' abstract, or adding a body to 'value'.
Could you please kindly take a look at the example I provided in this issue?
I apologize, I misunderstood your description. Thats reasonable then.