Skip to content

1.6.1

Latest

Choose a tag to compare

@ZacSweers ZacSweers released this 02 Dec 17:02
· 2 commits to main since this release

Enhancements

  • [core] Stop copying and re-sorting each binding's dependencies when ordering the graph.
  • [core] Store one copy of the encoded type for each unqualified binding key.
  • [FIR] Skip formatting class and function names for FIR trace events when compiler tracing is disabled.
  • [IR] Compare shared bindings only once when compiling graph extensions. This cut compile time from 43.5 s to 3.2 s on a 58-class test graph.
  • [IDEA] The IDE's Plugins dialog and JetBrains Marketplace now list IDEA and core changes and credit contributors.
  • [IDEA] Opening a second module with the same Metro options now reuses the existing graph index.
  • [IDEA] Reading cached gutter icons and inlay hints no longer queues extra work for the index.
  • [IDEA] Look up binding data once per file when drawing inlay hints.
  • [IDEA] Avoid taking a second snapshot of the same Kotlin type when indexing a plain binding request or a map request.
  • [IDEA] Stop copying the full batch of pending file edits each time another edit arrives.

Fixes

  • [core] Include the graph accessor in missing-binding errors, even when the missing dependency is several constructors deep.
  • [core] Generated set and map entries now have the same graph keys in the IDE and compiler reports, including entries from libraries.
  • [core] Set and map entries declared as properties now use the property name in both the IDE and compiler reports.
  • [core] Report a clear missing binding when a key like Thing<String, *> names a generic @Inject class. Previously, the compiler reported a missing binding for the class's raw type parameter, and the IDE resolved the key to the class.
  • [core] Fix unsigned qualifier arguments such as @Id(4294967295u) appearing as -1 in binding keys, reports, and error messages.
  • [Compiler] Preserve unrelated files when clearing old reports from reportsDestination.
  • [FIR] Limit generated contribution providers to bindings declared for their scope. Previously when a class contributed bindings to multiple scopes, FIR exposed all of them in each scope. Each container now generates providers only for its own bindings.
  • [FIR] Report abstract properties on @AssistedFactory and @DependencyGraph.Factory at compile time. Reading one on an assisted factory could throw AbstractMethodError.
  • [FIR] @ElementsIntoSet could put lists in a Set<String> when a provider returned Batch<String> and Batch<T> implemented List<List<T>>. Metro now reports a compile error. Declare Set<List<String>> and return batch.toSet().
  • [FIR/IR] Fix @get: site targets for @OptionalBinding.
  • [FIR/IR] Fix a bug where a provider returning Map<K, V>? could supply null to a non-null Map<K, V> accessor.
  • [FIR/IR] Fix a JVM compiler crash (Function has no body) when a class has overloaded @Inject methods such as accept(Int) and accept(String).
  • [FIR/IR] Fix a compiler crash when resolving bindings with star projections such as Map<String, *> and Lazy<*>.
  • [FIR/IR] Fix a compiler crash when a graph factory returns a specialized type such as AppGraph<String>.
  • [IR] Record @Inject methods in declaration order in library metadata. Sorting them by name could swap two @Named arguments of the same type when another module injected the class.
  • [IR] Fix a ClassCastException in generated factories that passed an @Provides method's extension receiver or context parameter in the argument slot for the graph.
  • [IR] Fix @set:Inject writing directly to the backing field and skipping the custom setter.
  • [IR] If a graph already exposed a provided Map<String, String>, Metro could reuse it for a Map<String, () -> String> accessor. Metro now reports a missing binding for the second accessor.
  • [IR] Fix a ClassCastException when injecting a provided Map<Class<*>, V> with enableKClassToClassInterop enabled. Metro tried to convert keys that were already Java classes.
  • [IR] Fix a compiler crash when a generic dependency graph declares a scoped provider.
  • [IR] Report a missing binding when a graph requests an unbound class with injected members. Previously, Metro could mistake a member injector for a binding for the class and crash during IR generation.
  • [IR] Fix a NoSuchMethodError when createGraph() tried to call a suspend function synchronously to get an extension receiver (e.g. @Provides suspend fun next(): Int for @Provides fun Int.twice(): Long).
  • [IR] Fix a compiler crash when two @IntoSet or @IntoMap functions have names with the same hash code, such as provideAa and provideBB.
  • [IR] Fix a compiler crash when a graph extension adds an @IntoMap entry to a map that its parent graph also contributes to. This happened when the parent's entry was a scoped @Provides function using @ClassKey with no class argument.
  • [IR] Fix single-entry set multibindings that allowed mutation on non-JVM targets.
  • [IR] Fix a compiler crash when a graph extension calls an inherited provider on a generic parent graph.
  • [IR] Fix graph diagnostics that could go missing when two of them fell back to the same declaration. Their messages are now joined in one report.
  • [IR] Fix a missing binding error when a compilation requests a qualified @Inject class or @AssistedFactory both with and without its qualifier. Previously, only the first request resolved.
  • [IR] Fix a JVM name clash between a graph accessor function such as fun getFoo(): Foo and the getter that Metro generates for a shared Foo binding. Before, the build failed with "Platform declaration clash" (Kotlin 2.4.10), or the graph class failed to load with ClassFormatError (Kotlin 2.4.20).
  • [IR] Keep the scope on @Provides functions in Dagger modules that come from another compilation. Previously, Metro treated these providers as unscoped and created a new instance on every request.
  • [IR] Fix how error messages such as duplicate binding errors print providers with parameters. The return type no longer wraps to its own line, and context parameters now print before fun or val.
  • [Gradle] The hidden dependency check no longer fails because of dependencies that only another source set in the same project uses. For example, adding test fixtures no longer makes the check report main's implementation dependencies.
  • [IDEA] Discard a file snapshot if its worker is canceled while reading it for the IDE index.
  • [IDEA] After a lookup in the inactive graph browser, unrelated edits no longer trigger an index build.
  • [IDEA] Selecting a module with Metro disabled no longer triggers index rebuilds in other modules on unrelated edits.
  • [IDEA] The graph browser now finds graphs annotated through a Kotlin typealias. Changing the alias updates the index without an edit to the graph.
  • [IDEA] When a missing parent interface appears, the graph browser picks up its inherited accessors without an edit to the graph.
  • [IDEA] Graph accessors that refer to a missing Java class now resolve when the class appears.
  • [IDEA] Fix false suspend errors in child graphs when a parent's generic binding recursively requests larger types.
  • [IDEA] Adding an entry to a child graph's map no longer flags scoped entries inherited from the parent as duplicate keys.
  • [IDEA] Graph validation now reports duplicate map keys when different annotations unwrap to the same value.
  • [IDEA] A matching generic provider in a dynamic graph's container now overrides a static provider. An exact provider in the dynamic container still wins.
  • [IDEA] Go to Metro Binding on a provider's extension receiver now jumps to the receiver's binding. It used to jump back to the provider itself.
  • [IDEA] Pinning a graph no longer hides a generic provider's consumers from Find Usages or the gutter.
  • [IDEA] Select in Metro now finds the generic provider in the graph browser when it supplies a concrete type.
  • [IDEA] When graphs specialize an inherited generic parameter differently, its inlay hint now shows the implementation from the pinned graph.
  • [IDEA] Find Usages on a generic provider returning a Set or Map now includes requests that use it.
  • [IDEA] In projects without graphs, Find Usages no longer lists consumers in modules that can't see the provider.
  • [IDEA] In projects without graphs, Find Usages no longer reports consumers for generic providers when derived bindings are disabled.
  • [IDEA] Resolve a qualified @Inject class or @AssistedFactory for a request with no qualifier, like the compiler does. Previously, graph validation reported a missing binding and editor navigation found no binding for the request.

Changes

  • [core] Report a new Metro/MultibindingConflict error when a Set or Map key has both a direct binding and multibinding contributions or a @Multibinds declaration. Previously, this compiled and Metro silently dropped the contributions, so code that compiled before can now fail.
    @DependencyGraph
    interface AppGraph {
      val strings: Set<String>
    
      // Error: Metro/MultibindingConflict
      @Provides fun strings(): Set<String> = setOf("a")
      @Provides @IntoSet fun b(): String = "b"
    }
    A graph extension's contributions to a Set or Map that its parent provides directly are an error too.
    @DependencyGraph
    interface AppGraph {
      @Provides fun strings(): Set<String> = setOf("a")
      fun child(): ChildGraph
    }
    
    @GraphExtension
    interface ChildGraph {
      val strings: Set<String>
    
      // Error: Metro/MultibindingConflict
      @Provides @IntoSet fun b(): String = "b"
    }
    A graph extension's own whole Set or Map still replaces its parent's contributions.
  • Test IntelliJ IDEA 2025.3.6.3, 2026.1.5.2, 2026.2.5.1, 2026.3.0.1, and 2026.3.1 RC.
  • Test Android Studio Rabbit 2 Patch 3, Rabbit 3 RC 2, and Stingray 1 Canary 4.
  • [compat] Support Kotlin 2.5.0. Metro retains the Kotlin 2.5 dev adapters used by IntelliJ IDEA 2026.3 and Android Studio Stingray.
  • [compat] Support Kotlin 2.5.20-dev-6103.

Contributors

Special thanks to the following contributors for contributing to this release!

Consider sponsoring Metro's development

What's Changed

New Contributors

Full Changelog: 1.6.0...1.6.1