dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.24k stars 1.58k forks source link

flutter builds / reloads / restarts fail when using a macro's `builder.report()` regardless of severity #56364

Open Lootwig opened 3 months ago

Lootwig commented 3 months ago

Not sure if this is the analyzer declaring any "Diagnostic"s an error, or flutter being too strict in processing the output, this shows up when trying to build a project with a macro reporting anything:

lib/test.dart: Error: Success!
class X {}
      ^
@SomeMacro()
class X {}

macro class SomeMacro implements ClassDeclarationsMacro {
  const SomeMacro();

  @override
  Future<void> buildDeclarationsForClass(
      ClassDeclaration clazz,
      MemberDeclarationBuilder builder,
      ) async {
    builder.report(
      Diagnostic(
        DiagnosticMessage(
          'Success!',
          target: DeclarationDiagnosticTarget(clazz),
        ),
        Severity.info,
      ),
    );
  }
}
flutter doctor

Flutter version 3.24.0-1.0.pre.403 on channel [user-branch] • Upstream repository https://github.com/luminateenterprises/flutter.git • Framework revision fa9b991b0d (3 months ago), 2024-04-25 17:23:02 +0200 • Engine revision 230879c793 • Dart version 3.6.0 (build 3.6.0-105.0.dev) • DevTools version 2.37.1

dart-github-bot commented 3 months ago

Summary: Macros using builder.report() to emit diagnostics, regardless of severity, cause build failures in Flutter. This issue may stem from the analyzer treating all diagnostics as errors or Flutter being overly strict in processing macro output.