sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Macro with Map param doesn't work properly

Open Sadhorsephile opened this issue 6 months ago • 1 comments

Problem

Cannot launch project with macro with Map param.

Macro
import 'dart:async';

import 'package:macros/macros.dart';

macro class MapEntryExample implements ClassDeclarationsMacro {
  final Map<String, String> map;

  const MapEntryExample(this.map);

  @override
  FutureOr<void> buildDeclarationsForClass(
    ClassDeclaration clazz,
    MemberDeclarationBuilder builder,
  ) async {}
}
Example
import 'package:test_macros/map_entry_example/macro.dart';

@MapEntryExample({
  'a': 'b',
  'c': 'd',
})
class Target {}

void main() {
  Target();
}
Output
example.dart:3:2: Error: This macro application didn't apply correctly due to an unhandled map entry.
@MapEntryExample({
 ^

Additional info

dart info output:

#### General info

- Dart 3.5.0-180.3.beta (beta) (Wed Jun 5 15:06:15 2024 +0000) on "macos_arm64"
- on macos / Version 14.4.1 (Build 23E224)
- locale is en-RU

#### Project info

- sdk constraint: '^3.5.0-180'
- dependencies: collection, dio, flutter, json, macros, provider
- dev_dependencies: flutter_lints, flutter_test

Sadhorsephile avatar Aug 13 '24 08:08 Sadhorsephile