New
-
[IR] Revamp graph-validation diagnostics with structured output. Taking some inspiration from Rust error messages.
-
Stable diagnostic IDs
-
Compact dependency chains
-
Aligned binding traces
-
Source snippets
-
help:/note:guidance in messages (replaces the previous(hint)sections) -
Per-diagnostic docs links
-
Diagnostics now wrap to 100 columns and start on their own line after the compiler location prefix
-
Example plain output
ExampleGraph.kt:9:3: error: [Metro/MissingBinding] No binding found for String trace (in dev.zacsweers.example.ExampleGraph): String is requested at dev.zacsweers.example.ExampleGraph.a similar bindings: - CharSequence (Supertype. Type: Provided) - ExampleGraph.kt:12:3 help: ensure String has an @Inject constructor or is provided by an @Provides or @Binds declaration visible to ExampleGraph docs: https://zacsweers.github.io/metro/latest/diagnostics/#missingbinding -
Example rich output
(note that in rich terminals this would have color and markup too!)
ExampleGraph.kt:9:3: error: ╭─ [Metro/MissingBinding] No binding found for String │ → ExampleGraph.kt:9:3 │ 9 │ val a: String │ ⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃ ╰─ trace (in dev.zacsweers.example.ExampleGraph): String is requested at dev.zacsweers.example.ExampleGraph.a similar bindings: • CharSequence (Supertype. Type: Provided) — ExampleGraph.kt:12:3 help: ensure String has an @Inject constructor or is provided by an @Provides or @Binds declaration visible to ExampleGraph docs: https://zacsweers.github.io/metro/latest/diagnostics/#missingbinding
-
-
[runtime/JVM] Add experimental runtime tracing for generated graph code, backed by AndroidX Tracing 2.x. Enable it with
metro.enableRuntimeTracing. See the runtime tracing performance docs for setup guidance.- Metro will add the JVM-only
metro-traceruntime helper artifact. - Graphs must bind an
androidx.tracing.Tracerinstances as a graph input as a parent tracer. - This is experimental as AndroidX Tracing 2.x is still actively being developed.
- Metro will add the JVM-only
-
[gradle] Add a
diagnosticsRenderModeGradle option (AUTO/PLAIN/RICH) for diagnostic rendering.AUTOdefaults to rich output and falls back to plain output for non-emptyNO_COLOR,--console=plain, and IDE-invoked builds.- The resolved mode is passed as a non-input compiler option, so render-mode changes do not invalidate compilation or poison build caches.
-
[docs] Add a generated Diagnostics Reference docs page for Metro's common graph validation diagnostics.
-
[FIR/IR] Add support for parameterless
@Bindsdeclarations for constructor-injected classes.
Enhancements
- [FIR] Add a diagnostic to report mutable graph accessor properties.
- [FIR] Add a diagnostic to report
openclasses annotated with@BindingContainer. - [FIR] Add a diagnostic to report scope annotations on graph factory parameters.
- [IR] Add cycle-breaking
help:guidance for dependency cycle errors, suggesting deferred types such as() -> TorLazy<T>. - [IR/reporting] Collapse sibling missing-binding errors with identical trace tails to a
... same as for Xcontinuation, and fully qualify type names only when two distinct types in one diagnostic share a simple name. - [docs] Improve docs around
@GraphPrivate.
Fixes
- [FIR] Improve diagnostic reporting locations for assisted factory parameter mismatches.
- [FIR/IR] Fully qualify generated hint function names so scope classes with the same simple name don't collide.
- [IR] Preserve substituted generic type arguments when generating assisted factory delegate parameters and dynamic graph container inputs.
- [IR] Forward extension and context receivers when generated binding-container factories invoke the original binding function.
- [IR] Fix dispatch receivers for generated graph factory functions and companion/object factory accessors.
- [IR] Manage transitive simple class binding containers included by contributed binding containers when they have instance providers.
- [IR] Patch declaration parents for generated
@Bindsmirror declarations so copied declarations remain attached to the correct generated class. - [IR] Preserve
@GraphPrivateon cross-module mirror functions so private multibinding contributions do not leak through chained graph extensions. - [IR/Dagger interop] Report a clear diagnostic when an injected declaration or binding container from an upstream module was not processed by Metro, instead of crashing or reporting a generic compiler error.
- [IR/Dagger interop] Fix an IR gen crash when an unscoped parent
@Providesbinding is injected asdagger.Lazy<T>from a child graph. - [IR/JS] Fix
Map<K, () -> V>multibindings accessed through provider-style map factories on Kotlin/JS. Generated maps now store callable function values instead of MetroProviderobjects. - [IR/KLIB] Fix generated
@Bindsimplementations on KLIB backends. Metro now emits concrete identity bodies for inherited@Bindsmembers where JS, Native, and Wasm validate abstract members during deserialization. - [IR/KLIB] Keep generated graph and shard backing fields private while preserving generated access through properties. This avoids backing-field visibility validation failures on KLIB backends.
- [gradle] Fix multiplatform output collisions in MetroArtifactCopyTask.
Changes
- Run Metro's functional compiler unit tests on JS.
- Redundant checksum files are no longer published: checksums of
.ascsignature files (gradle/gradle#20232) and thesha256/sha512. If you rely on these, let me know. - Remove
binding-contributions-as-containersflag, onlybinding-contributions-as-containersis supported going forward. - [gradle] Build against Gradle
9.6.1. - Test Kotlin
2.4.10-RC. - Test Kotlin
2.4.20-Beta1. - Test Android Studio Quail 2 RCs.
- Test Android Studio Quail 3 canaries.
Contributors
Special thanks to the following contributors for contributing to this release!
Consider sponsoring Metro's development
What's Changed
- Run JS tests in compiler-tests by @ZacSweers in #2421
- Rich diagnostics by @ZacSweers in #2436
- Update Metro bootstrap to v1.2.1 by @renovate[bot] in #2438
- Update IDE version mappings by @ZacSweers in #2443
- Update compiler API doc. by @ychescale9 in #2441
- Update koin.compiler to v1.0.1 by @renovate[bot] in #2439
- Report mutable graph properties by @ZacSweers in #2445
- Regenerate tests by @ZacSweers in #2444
- Fully qualify scope names for hint functions by @BraisGabin in #2442
- Clean up render mode naming by @ZacSweers in #2446
- Update koin to v4.2.2 by @renovate[bot] in #2448
- Run apt-get first on IDE tests by @ZacSweers in #2455
- Update androidx.lint.gradle to v1.0.0 by @renovate[bot] in #2453
- Update IDE version mappings by @ZacSweers in #2452
- Update plugin com.gradle.develocity to v4.4.3 by @renovate[bot] in #2450
- Update IDE version mappings by @ZacSweers in #2456
- Update actions/checkout action to v7 by @renovate[bot] in #2459
- Add a diagnostic to report scope annotations on graph inputs by @ZacSweers in #2460
- Fix KMP output collisions in MetroArtifactCopyTask by @FletchMcKee in #2449
- Update to Gradle 9.6.0 by @ZacSweers in #2462
- Clean up NO_COLOR docs by @ZacSweers in #2463
- Update IDE version mappings by @ZacSweers in #2464
- Fix transitive managed containers from instance containers by @BraisGabin in #2458
- Improve assisted factory param locations by @ZacSweers in #2461
- Fix IDE test for assisted params by @ZacSweers in #2466
- Clean up annotation-default arg by @ZacSweers in #2465
- Tighten IDE smoke diagnostics by @ZacSweers in #2467
- Avoid project-local property lookups for Gradle 10 by @ZacSweers in #2468
- Update maven publish to 0.37.0 by @ZacSweers in #2469
- Enable NO_IMPLICIT_LOOKUP_IN_PARENT_PROJECTS preview by @ZacSweers in #2471
- Clean up contributions-as-containers by @ZacSweers in #2470
- Update dependency zensical to v0.0.46 by @renovate[bot] in #2472
- Update dependency pymdown-extensions to v11 by @renovate[bot] in #2474
- Update actions/cache action to v6 by @renovate[bot] in #2476
- Update wire to v6.4.1 by @renovate[bot] in #2475
- Fix type mismatch for dagger.Lazy interop by @ZacSweers in #2478
- Streamline release infra by @ZacSweers in #2480
- Add runtime tracing by @tikurahul in #2354
- Update dependency com.facebook:ktfmt to v0.64 by @renovate[bot] in #2481
- Improve docs for Runtime tracing. by @tikurahul in #2482
- Test 2.4.20-Beta1 by @ZacSweers in #2483
- Update dependency click to v8.4.2 by @renovate[bot] in #2484
- Update tested IDE versions by @ZacSweers in #2485
- Fix code fence in documentation by @tikurahul in #2486
- Update IDE version mappings by @ZacSweers in #2491
- Parallelize some workflow steps by @ZacSweers in #2492
- Update ktor monorepo to v3.5.1 by @renovate[bot] in #2488
- Update plugin shadow to v9.4.3 by @renovate[bot] in #2490
- Update dagger to v2.60 by @renovate[bot] in #2489
- Use Mordant + align rendering with ktoolchain by @ZacSweers in #2487
- Add instant support to runtime tracing by @ZacSweers in #2494
- Fix: GraphPrivate bindings can leak to chained Graph Extensions by @jonamireh in #2497
- Improve GraphPrivate docs by @ZacSweers in #2498
- Retry JS box tests by @ZacSweers in #2499
- Test 2.4.10-RC by @ZacSweers in #2501
- Support parameter-less binds by @ZacSweers in #2500
- Update Gradle to 9.6.1 by @ZacSweers in #2502
- Clean up git-lfs usage by @ZacSweers in #2503
- Improve error messaging on missing upstream factories by @ZacSweers in #2505
New Contributors
- @ychescale9 made their first contribution in #2441
- @BraisGabin made their first contribution in #2442
- @FletchMcKee made their first contribution in #2449
- @tikurahul made their first contribution in #2354
Full Changelog: 1.2.1...1.3.0