Changelog¶
Unreleased¶
0.3.7¶
2025-06-08
- Fix: Record lookups of generated static member inject functions for IC.
- Fix: Dedupe merged overrides of
@Includes
accessors.
Special thanks to @kevinguitar for contributing to this release!
0.3.6¶
2025-06-06
- New: Add new
Provider.map
,Provider.flatMap
,Provider.zip
, andProvider.memoize
utility APIs. - Enhancement: Improve graph validation performance by avoiding unnecessary intermediate sorts (again).
- Enhancement: Fail eagerly with a clear error message if
languageVersion
is too old. - Enhancement: Validate improperly depending on assisted-injected classes directly at compile-time.
- Fix: Support constructing nested function return types for provider functions.
- Fix: Propagate
@Include
bindings from parent graphs to extension graphs. - Fix: Reparent copied lambda default values in IR.
- [internal] Make internal renderings of
IrType
more deterministic.
Special thanks to @kevinguitar for contributing to this release!
0.3.5¶
2025-05-31
- New: Implement top-level function injection checkers.
- Change: Disallow top-level function injections to be scoped.
- Fix: Support type parameters with
where
bounds. - Fix: Support injected class type parameters with any bounds.
- Fix: Support generic graph factory interfaces.
- Fix: In the presence of multiple contributing annotations to the same scope, ensure only hint function/file is generated.
- Fix: Improve shading to avoid packaging in stdlib and other dependency classes.
- Fix: Revert #483 as it broke some cases we haven’t been able to debug yet.
Special thanks to @gabrielittner and @kevinguitar for contributing to this release!
0.3.4¶
2025-05-27
- Enhancement: Use a simple numbered (but deterministic) naming for contributed graph classes to avoid long class names.
- Enhancement: Improve graph validation performance by avoiding unnecessary intermediate sorts.
- Enhancement: Move binding validation into graph validation step.
- Enhancement: Avoid unnecessary BFS graph walk in provider field collection.
- Fix: Fix provider field populating missing types that previously seen types dependent on.
Special thanks to @ChristianKatzmann and @madisp for contributing to this release!
0.3.3¶
2025-05-26
- Enhancement: Don’t unnecessarily wrap
Provider
graph accessors. - Enhancement: Allow multiple contributed graphs to the same parent graph.
- Fix: Don’t unnecessarily recompute bindings for roots when populating graphs.
- Fix: Better handle generic assisted factory interfaces.
- Fix: Use fully qualified names when generating hint files to avoid collisions.
- Fix: Support provides functions with capitalized names.
- Fix: Prohibit consuming
Provider<Lazy<...>>
graph accessors. - [internal] Migrate to new IR
parameters
/arguments
/typeArguments
compiler APIs.
Special thanks to @gabrielittner for contributing to this release!
0.3.2¶
2025-05-15
- Enhancement: Optimize supertype lookups in IR.
- Fix: Fix generic members inherited from generic supertypes of contributed graphs.
- Fix: Fix
@ContributedGraphExtension
that extends the same interface as the parent causes a duplicate binding error. - Fix: Fix contributed binding replacements not being respected in contributed graphs.
- Fix: Fix contributed providers not being visible to N+2+ descendant graphs.
- Fix: Collect bindings from member injectors as well as exposed accessors when determining scoped provider fields.
- Fix: Fix a few
-Xverify-ir
and-Xverify-ir-visibility
issues + run all tests with these enabled now.
Special thanks to @bnorm, @gabrielittner, @kevinguitar, and @JoelWilcox for contributing to this release!
0.3.1¶
2025-05-13
- Enhancement: Rewrite graph resolution using topological sorting to vastly improve performance and simplify generation.
- Enhancement: Return early once an externally-compiled dependency graph is found.
- Enhancement: Simplify multibinding contributor handling in graph resolution by generating synthetic qualifiers for each of them. This allows them to participate in standard graph resolution.
- Enhancement: When there are multiple empty
@Multibinds
errors, report them all at once. - Enhancement: Avoid unnecessary
StringBuilder
allocations. - Fix: Don’t transform
@Provides
function’s to be private if its visibility is already explicitly defined. - Fix: Fix a comparator infinite loop vector.
- Fix: Fix
@ElementsIntoSet
multibinding contributions triggering a dependency cycle in some situations. - Fix: Fix assertion error for generated multibinding name hint when using both @Multibinds and @ElementsIntoSet for the same multibinding.
- Fix: Fix contributed graph extensions not inheriting empty declared multibindings.
- Fix: Ensure we report the
@Multibinds
declaration location in errors if one is available. - Fix: Dedupe overrides by all parameters not just value parameters.
- Fix: Dedupe overrides by signature rather than name when generating contributed graphs.
- Fix: Fix accidentally adding contributed graphs as child elements of parent graphs twice.
- Fix: Fix not deep copying
extensionReceiverParameter
when implementing fake overrides in contributed graphs. - Fix: Report fully qualified qualifier renderings in diagnostics.
- Fix: Don’t generate provider fields for multibinding elements unnecessarily.
- When debug logging + reports dir is enabled, output a
logTrace.txt
to the reports dir for tracing data. - Update to Kotlin
2.1.21
.
Special thanks to @asapha, @gabrielittner, @jzbrooks, and @JoelWilcox for contributing to this release!
0.3.0¶
2025-05-05
- New: Add support for
@ContributesGraphExtension
! See the docs for more info. - New: Add a
asContribution()
compiler intrinsic to upcast graphs to expected contribution types. For example:val contributedInterface = appGraph.asContribution<ContributedInterface>()
. This is validated at compile-time. - New: Automatically transform
@Provides
functions to beprivate
. This is enabled by defaults and supersedes thepublicProviderSeverity
when enabled, and can be disabled via the Gradle extension ortransform-providers-to-private
compiler option. Note that properties and providers with any annotations withKClass
arguments are not supported yet pending upstream kotlinc changes. - Enhancement: Rewrite the internal
BindingGraph
implementation to be more performant, accurate, and testable. - Enhancement: Add diagnostic to check that graph factories don’t provide their target graphs as parameters.
- Enhancement: Add diagnostic to check that a primary scope is defined if any additionalScopes are also defined on a graph annotation.
- Enhancement: Add diagnostic to validate that contributed types do not have narrower visibility that aggregating graphs. i.e. detect if you accidentally try to contribute an
internal
type to apublic
graph. - Enhancement: Optimize supertype lookups when building binding classes by avoiding previously visited classes.
- Enhancement: Don’t generate hints for contributed types with non-public API visibility.
- Enhancement: When reporting duplicate binding errors where one of the bindings is contributed, report the contributing class in the error message.
- Enhancement: When reporting scope incompatibility, check any extended parents match the scope and suggest a workaround in the error diagnostic.
- Enhancement: Allow AssistedFactory methods to be protected.
- Fix: Fix incremental compilation when a parent graph or supertype modifies/removes a provider.
- Fix: Fix rank processing error when the outranked binding is contributed using Metro’s ContributesBinding annotation.
- Fix: Fix
@Provides
graph parameters not getting passed on to extended child graphs. - Fix: Fix qualifiers on bindings not getting seen by extended child graphs.
- Fix: Fix qualifiers getting ignored on accessors from
@Includes
dependencies. - Fix: Fix transitive scoped dependencies not always getting initialized first in graph provider fields.
- Fix: Fix injected
lateinit var
properties being treated as if they have default values. - Fix: Alias bindings not always having their backing type visited during graph validation.
- Fix: Fix race condition in generating parent graphs first even if child graph is encountered first in processing.
- Fix: Fallback
AssistedInjectChecker
error report to the declaration source. - Fix: Fix missing parent supertype bindings in graph extensions.
- Change:
InstanceFactory
is no longer a value class. This wasn’t going to offer much value in practice. - Change: Change debug reports dir to be per-compilation rather than per-platform.
Special thanks to @gabrielittner, @kevinguitar, @JoelWilcox, and @japplin for contributing to this release!
0.2.0¶
2025-04-21
- New: Nullable bindings are now allowed! See the nullability docs for more info.
- Enhancement: Add diagnostics for multibindings with star projections.
- Enhancement: Add diagnostic for map multibindings with nullable keys.
- Fix: Ensure assisted factories’ target bindings’ parameters are processed in MetroGraph creation. Previously, these weren’t processed and could result in scoped bindings not being cached.
- Fix: Fix duplicate field accessors generated for graph supertypes.
- Add compose navigation sample.
Special thanks to @bnorm and @yschimke for contributing to this release!
0.1.3¶
2025-04-18
- Change: Multibindings may not be empty by default. To allow an empty multibinding,
@Multibinds(allowEmpty = true)
must be explicitly declared now. - New: Write graph metadata to reports (if enabled).
- New: Support configuring debug and reports globally via
metro.debug
andmetro.reportsDestination
Gradle properties (respectively). - Enhancement: Change how aggregation hints are generated to improve incremental compilation. Externally contributed hints are now looked up lazily per-scope instead of all at once.
- Enhancement: Optimize empty map multibindings to reuse a singleton instance.
- Enhancement: Report error diagnostic if Dagger’s
@Reusable
is used on a provider or injected class. - Enhancement: Tweak diagnostic error strings for members so that IDE terminals auto-link them better. i.e., instead of printing
example.AppGraph.provideString
, Metro will printexample.AppGraph#provideString
instead. - Enhancement: Support repeatable @ContributesBinding annotations with different scopes.
- Fix: Fix incremental compilation when
@Includes
-annotated graph parameters change accessor signatures. - Fix: Don’t allow graph extensions to use the same scope as any extended ancestor graphs.
- Fix: Don’t allow multiple ancestor graphs of graph extensions to use the same scope.
- Fix: Handle scenarios where the compose-compiler plugin runs before Metro’s when generating wrapper classes for top-level
@Composable
functions. - Fix: Fix an edge case in graph extensions where child graphs would miss a provided scoped binding in a parent graph that was also exposed as an accessor.
- Fix: Fix Dagger interop issue when calling Javax/Jakarta/Dagger providers from Metro factories.
- Fix: Fix Dagger interop issue when calling
dagger.Lazy
from Metro factories. - Fix: Preserve the original
Provider
orLazy
type used in injected types when generating factory creators. - Temporarily disable hint generation in WASM targets to avoid file count mismatches until KT-75865.
- Add an Android sample: https://github.com/ZacSweers/metro/tree/main/samples/android-app
- Add a multiplatform Circuit sample: https://github.com/ZacSweers/metro/tree/main/samples/circuit-app
- Add samples docs: https://zacsweers.github.io/metro/samples
- Add FAQ docs: https://zacsweers.github.io/metro/faq
Special thanks to @JoelWilcox, @bnorm, and @japplin for contributing to this release!
0.1.2¶
2025-04-08
- Enhancement: Implement
createGraph
andcreateGraphFactory
FIR checkers for better error diagnostics on erroneous type arguments. - Enhancement: Add
ContributesBinding.rank
interop support with Anvil. - Enhancement: Check Kotlin version compatibility. Use the
metro.version.check=false
Gradle property to disable these warnings if you’re feeling adventurous. - Fix: Fix class-private qualifiers on multibinding contributions in other modules not being recognized in downstream graphs.
- Fix: Fix member injectors not getting properly visited in graph validation.
- Fix: Fix a bug where
Map<Key, Provider<Value>>
multibindings weren’t always unwrapped correctly. - Fix: Fix
Map<Key, Provider<Value>>
type keys not correctly interpreting the underlying type key asMap<Key, Value>
. - Change: Change
InstanceFactory
to a value class. - Change: Make
providerOf
useInstanceFactory
under the hood.
Special thanks to @JoelWilcox, @bnorm, @japplin, @kevinguitar, and @erawhctim for contributing to this release!
0.1.1¶
2025-04-03
Initial release!
See the announcement blog post: https://www.zacsweers.dev/introducing-metro/