Skip to content

[pigeon] Remove remaining dart:mirrors usage #190228

Open
flutter/packages
#13524

Description

@stuartmorgan-g

We still have a couple of minor uses of dart:mirrors, which we should try to eliminate since the bulk of Pigeon hasn't used mirrors in a long time:

  • an isVoid function in generator_tools.dart, which AFAICT isn't used anywhere and can just be removed
  • code in runWithOptions, the library entry point that almost nobody uses AFAIK, to find a method called configurePigeon and execute it. That seems to be a vestige of when that's how Pigeon configuration worked, instead of the annotation system we have now (https://pub.dev/packages/pigeon/changelog#030). Presumably the library call should be working the new way as well, not using the old method? Or if it has to be a method, we should probably make the client pass it in.

Activity

  1. added
    packageflutter/packages repository. See also p: labels.
    p: pigeonrelated to pigeon messaging codegen tool
    P2Important issues not at the top of the work list
    on Jul 29, 2026
  2. theprantadutta commented on Oct 2, 2026

    @theprantadutta
    Contributor

    I'd like to pick this up. I checked both uses on current main:

    • isVoid(TypeMirror) in generator_tools.dart has no callers anywhere in the package (the isVoid used throughout the generators is the unrelated TypeDeclaration.isVoid getter in ast.dart), so it can just go.
    • _executeConfigurePigeon is the only other dart:mirrors user. It's called unconditionally at the start of runWithOptions and walks every loaded library looking for a top-level configurePigeon(PigeonOptions). Nothing in test/, example/ or platform_tests/ defines one, so it's currently untested, and as you say it predates the @ConfigurePigeon annotation from 0.3.0. CONTRIBUTING.md also still says "This is how dart:mirrors gets access to the supplied Pigeon file."

    With both gone, dart:mirrors disappears from the package entirely (and CONTRIBUTING.md gets corrected).

    The one decision I'd want from you is what happens to the hook:

    1. Remove it. runWithOptions callers already pass a fully-formed PigeonOptions, so mutating it beforehand is the natural replacement. Technically breaking for anyone relying on the reflection lookup.
    2. Keep the behaviour but make it explicit — e.g. an optional void Function(PigeonOptions)? configure parameter on runWithOptions — so nothing needs reflection.

    I'd lean towards (1) given how little it's likely used, with a CHANGELOG note — but I'm happy to do either, and to follow your call on the version bump if you treat it as breaking.

    I'm at the open-PR limit in flutter/packages at the moment, so this would start as a draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions