Open alexeyinkin opened 2 months ago
Summary: The issue is that macros cannot accept enum values as parameters, even though they can declare such parameters and have default values. This results in a macro_application_argument_error
when passing an enum value as a macro parameter.
A workaround is to subclass the macro and hardcode a value for the parameter:
macro class MyMacroHello extends MyMacro {
const MyMacroHello({
super.intValue = 1,
}) : super(enumValue: MyEnum.hello);
This should be done for each of the enum values you need.
Looks like a macro can't accept enum values as parameters although it can declare such parameters and have default values for them.
macro.dart:
main.dart:
pubspec.yaml
```yaml name: temp1 environment: sdk: ^3.5.0-180 dependencies: macros: ^0.1.0-main.5 # For 3.5.0-180 ```
Expected
dart run --enable-experiment=macros main.dart
:Actual
dart run --enable-experiment=macros main.dart
:dart analyze
:dart info
``` If providing this information as part of reporting a bug, please review the information below to ensure it only contains things you're comfortable posting publicly. #### General info - Dart 3.5.0-323.2.beta (beta) (Mon Jul 29 04:29:41 2024 +0000) on "macos_arm64" - on macos / Version 13.6 (Build 22G120) - locale is es-GE #### Process info | Memory | CPU | Elapsed time | Command line | | ------: | ---: | -----------: | ------------------------------------------------------------------------------------------ | | 14 MB | 0.0% | 03-23:17:43 | dart devtools --machine --dtd-uri=ws:/0vhzmGQ5d7QlMnqZ |
| 16 MB | 0.0% | 05-03:07:32 | dart devtools --machine --dtd-uri=ws:/563fXWb9URFyRWt8 |
| 7 MB | 0.0% | 14-07:14:59 | dart devtools --machine --dtd-uri=ws:/8cdxpf3B0Q1F9jFY |
| 13 MB | 0.0% | 05-22:03:35 | dart devtools --machine --dtd-uri=ws:/LOjlfHO5jN4iJsR3 |
| 17 MB | 0.0% | 04-22:47:06 | dart devtools --machine --dtd-uri=ws:/Sirkb3N4HiIZqC0o |
| 68 MB | 0.0% | 17:21 | dart devtools --machine --dtd-uri=ws:/cqTYO8HCTYfhQ6HT |
| 810 MB | 0.0% | 06:54:47 | dart language-server --client-id=Android-Studio --client-version=AI-241.15989.150 --protocol=analyzer |
| 3021 MB | 0.0% | 02-23:07:02 | dart language-server --client-id=Android-Studio --client-version=AI-241.15989.150 --protocol=analyzer |
| 697 MB | 0.0% | 17:22 | dart language-server --client-id=Android-Studio --client-version=AI-241.15989.150 --protocol=analyzer |
| 191 MB | 0.0% | 05:07:38 | dart language-server --client-id=Android-Studio --client-version=AI-241.15989.150 --protocol=analyzer |
| 145 MB | 0.0% | 05-03:07:33 | dart language-server --client-id=Android-Studio --client-version=AI-241.15989.150 --protocol=analyzer |
| 120 MB | 0.0% | 03-23:17:45 | dart language-server --client-id=Android-Studio --client-version=AI-241.15989.150 --protocol=analyzer |
| 8 MB | 0.0% | 14-07:14:59 | dart tooling-daemon --machine |
| 83 MB | 0.0% | 17:21 | dart tooling-daemon --machine |
| 17 MB | 0.0% | 05-03:07:32 | dart tooling-daemon --machine |
| 12 MB | 0.0% | 03-23:17:43 | dart tooling-daemon --machine |
| 19 MB | 0.0% | 05-22:03:35 | dart tooling-daemon --machine |
| 20 MB | 0.0% | 04-22:47:06 | dart tooling-daemon --machine |
| 55 MB | 0.1% | 02-23:09:53 | flutter_tools.snapshot daemon |
| 53 MB | 0.1% | 02-23:09:53 | flutter_tools.snapshot daemon |
| 53 MB | 0.1% | 02-23:09:53 | flutter_tools.snapshot daemon |
| 52 MB | 0.0% | 02-23:09:53 | flutter_tools.snapshot daemon |
| 101 MB | 0.2% | 17:25 | flutter_tools.snapshot daemon |
```