Skip to content

Macro with Map param doesn't work properly #56458

Open
@Sadhorsephile

Description

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

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).feature-macrosImplementation of the macros featurepkg-macrosThe experimental package:_macros librarytype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions