Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Oct 12, 2025

This PR contains the following updates:

Package Change Age Confidence
dev.zacsweers.metro 0.6.9 -> 0.7.2 age confidence
dev.zacsweers.metro:runtime 0.6.9 -> 0.7.2 age confidence

Release Notes

ZacSweers/metro (dev.zacsweers.metro)

v0.7.2

Compare Source

2025-10-22

  • Fix: Fix eager initialization of some bindings going into multibindings.
  • Fix: Fix injection of Lazy-wrapped multibindings.

v0.7.1

Compare Source

2025-10-21

🚨 This release has a severe bug in multibinding code gen, please use 0.7.2 instead!

  • New: Add missing dependency hints for missing bindings errors

    [Metro/MissingBinding] Cannot find an @​Inject constructor or @​Provides-annotated function/property for: FooImpl
    
        FooImpl is injected at
            [AppGraph] Bindings.bind: FooImpl
        Base is requested at
            [AppGraph] AppGraph.base
    
    (Hint)
    'FooImpl' doesn't appear to be visible to this compilation. This can happen when a binding references a type from an 'implementation' dependency that isn't exposed to the consuming graph's module.
    Possible fixes:
    - Mark the module containing 'FooImpl' as an 'api' dependency in the module that defines 'Bindings' (which is requesting it).
    - Add the module containing 'FooImpl' as an explicit dependency to the module that defines 'AppGraph'.
    
  • Enhancement: Improve code generation around multibinding collection builders and contributors, using more lazy getters in graph code gen.

  • Enhancement: Short-circuit empty map providers to emptyMap().

  • Enhancement: Support default values for assisted parameter arguments in top-level function injection.

  • Enhancement: Allow using @Contributes* annotations on assisted factories with contributesAsInject enabled.

  • Enhancement: Allow @OptionalBinding annotation to be customizable/replaceable.

  • Change: Deprecate @OptionalDependency in favor of @OptionalBinding. Same behavior, just a slightly more consistent name.

  • Fix: Compute Optional instance lazily when requested as a Provider<Optional<T>> and the underlying optional is not empty. Only applies to @BindsOptionalOf interop.

  • Fix: Don't generate duplicate init() functions when chunking initializers if graphs already have an explicit init() function.

  • Fix: Fix support for assisted inject with no assisted params.

  • Fix: Detect platform types in just the kotlin package. Previously it missed any that didn't have multiple package segments.

  • Fix: Align unused context parameter special names on Kotlin 2.3.x.

  • Remove 2.3.0-dev-7984 compat (superseded by 2.3.0-Beta1).

Special thanks to @​Lavmee, @​kevinguitar, and @​jackwilsdon for contributing to this release!

v0.7.0

Compare Source

2025-10-17

Dynamic Graphs

Dynamic graphs are a powerful new feature of the Metro compiler that allows for dynamically replacing bindings in a given graph. To use them, you can pass in a vararg set of binding containers to the createDynamicGraph() and createDynamicGraphFactory() intrinsics.

@&#8203;DependencyGraph
interface AppGraph {
  val message: String

  @&#8203;Provides fun provideMessage(): String = "real"
}

class AppTest {
  val testGraph = createDynamicGraph<AppGraph>(FakeBindings)

  @&#8203;Test
  fun test() {
    assertEquals("fake", testGraph.message)
  }

  @&#8203;BindingContainer
  object FakeBindings {
    @&#8203;Provides fun provideMessage(): String = "fake"
  }
}

This is particularly useful for tests. See their docs for more information: Dynamic Graphs.

This API is experimental and may change in the future, please report any issues you encounter!

Implicit @Inject behavior on (most) @Contributes*-annotated types

Up to this point, Metro has always required you to use @Inject on most @Contributes* annotated types. However, this can feel a bit repetitive and tedious. In this release, there is a new contributesAsInject option that can be enabled that will treat all @Contributes* annotated types as @Inject by default. You can still use @Inject on classes to be explicit, and if you have multiple constructors you must still use @Inject on the constructor you want to be used.

The only exception to this is @ContributesTo, which isn't applicable to injected types.

This is disabled by default to start but will likely become the default in a future release.

@&#8203;ContributesBinding(AppScope::class)
// @&#8203;Inject // <-- now implicit!
class TacoImpl(...) : Taco
Other Changes
  • Behavior change: Remove assistedInjectMigrationSeverity DSL. You must now move fully to using @AssistedInject annotations for assisted types.
  • New: Allow exposing assisted-injected classes on a graph with qualifier annotations via @Provides declarations. This means you could, for example, write a provider like so:
    @&#8203;Provides @&#8203;Named("qualified")
    fun provideTaco(factory: Taco.Factory): Taco = factory.create("spicy")
  • New: Add diagnostic disallowing qualifier annotations directly on @AssistedInject-annotated classes.
  • New: Add wasmWasi targets to Metro's runtime.
  • New: Add diagnostic to report positional arguments use in custom interop annotations. See the interop docs for more information. This is disabled by default but can be configured via the interopAnnotationsNamedArgSeverity option.
  • New: Support context parameters on top-level injected functions. See the docs for more information.
  • New: Improve diagnostic checks around binding container arguments to annotations and graph creators.
  • New: Add a diagnostic to warn on suspicious injection of unqualified object classes.
  • Enhancement: Add diagnostic for providing a constructor-injected class with a different scope than the class (if the class has a scope).
  • Enhancement: Allow replacing/excluding binding containers by @Origin annotations.
  • Fix: Don't use interoped annotation arguments at matching indices if their name does not match the requested name.
  • Fix: Trace all member injection dependencies from supertypes in graph reachability computation.
  • Fix: Use compat getContainingClassSymbol() (fixes Kotlin 2.3.0-x compatibility).
  • Fix: Better escape field names to be valid in JVM.
  • Fix: Don't double-invoke Optional binding fields.
  • Fix: Don't report duplicate bindings if injectors for both a parent and child class are present on a graph.
  • Fix: Look up correct target class ID for computed member injectors in BindingLookup.
  • Fix: Don't allow binding containers to be inner classes.
  • Fix: Don't allow binding containers to be local classes.
  • Fix: Don't allow binding containers to be anonymous objects.
  • Fix: Fix wrong parent graph name in IncompatiblyScopedBindings hint.
  • Fix: Fix replacements for regular contributed types not getting processed in graph extensions.
  • Fix: Don't re-process contribution merging for generated graph extension impls during graph node creation.
  • Fix: Don't reserve provider fields for custom wrapper types like interoped Optional types, avoiding accidental eager initialization in cycles.
  • Change the warning key for redundant provides to more specific REDUNDANT_PROVIDES.

Special thanks to @​erawhctim and @​CharlieTap for contributing to this release!

v0.6.10

Compare Source

2025-10-11

Optional Dependency Behaviors

Graph accessors can now expose optional dependencies, just use @OptionalDependency on the accessor. Note that the accessor must declare a default body that Metro will use if the dependency is absent.

@&#8203;DependencyGraph
interface AppGraph {
  @&#8203;OptionalDependency
  val message: String
    get() = "Absent!"
}

There are a couple of optional configuration for Metro's optional dependency support that can be configured via the optionalDependencyBehavior Gradle DSL:

  • DISABLED - Disallows optional dependencies entirely.
  • REQUIRE_OPTIONAL_DEPENDENCY - Requires optional dependency parameters to also be annotated with @OptionalDependency. This may be preferable for consistency with accessors and/or explicitness.
  • DEFAULT - The default behavior as described above — accessors must be annotated with @OptionalDependency with default bodies and parameters just use default value expressions.
Other changes
  • New: Add interop for Dagger @BindsOptionalOf. Note this is currently only limited to java.util.Optional.
  • Enhancement: Improve error messages for unexpected IrErrorType encounters.
  • Enhancement: Add configurable statementsPerInitFun to option to control the number of statements per init function. Only for advanced/debugging use.
  • Fix: Allow @Includes types themselves (i.e., not their accessors) to be dependencies in generated graphs.
  • Fix: Allow multiple graph extension factory accessors of the same factory type on parent graphs.
  • Fix: Report all missing @Provides body diagnostics rather than returning early.
  • Fix: Allow open members from abstract graph class superclasses to be accessors.
  • Fix: When detecting default function/property getter bodies in graph accessors, check for open modality as well.
  • Fix: Don't duplicate includes accessor keys across multiple parent context levels.
  • Fix: Fix not respecting ref counting when allocating provider fields for constructor-injected class providers. This should reduce generated graph code size quite a bit.

Special thanks to @​ChristianKatzmann for contributing to this release!


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot changed the title Update metro to v0.6.10 Update metro to v0.7.0 Oct 17, 2025
@renovate renovate bot changed the title Update metro to v0.7.0 Update metro to v0.7.1 Oct 21, 2025
@renovate renovate bot changed the title Update metro to v0.7.1 Update metro to v0.7.2 Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants