data_class
data_class copied to clipboard
fix: Dart Macros `declareInType` Incompatibility with Sealed Classes in Dart 3
Issue Description
In Dart 3, there is an issue with Dart macros when applied to sealed classes. The macros incorrectly add the abstract keyword to the generated code, resulting in a compilation error.
Example
@Equatable() // considering the usage of the data_class package
sealed class CodePushState {
const CodePushState();
}
Error
A 'sealed' class can't be marked 'abstract' because it's already implicitly abstract.
Try removing the 'abstract' keyword.
augment abstract sealed class CodePushState {
Steps to Reproduce:
- Define a sealed class as per Dart 3.
- Apply a Dart macro (using the data_class package) to the sealed class.
- Observe the generated
Augmentcode , which incorrectly includes theabstractkeyword.
Reference:
This issue has also been reported in the Dart language repository. You can track the progress here: Dart Macros Cannot Handle Sealed Classes Correctly (Dart 3) dart-lang/sdk#56525.