Skip to content

Releases: ZacSweers/metro

0.5.3

29 Jul 03:11
Compare
Choose a tag to compare
  • Behavior change: The enableScopedInjectClassHints option is no longer enabled by default. This option is tricky to get right and will be iterated on further in #764.
  • Enhancement: Generate synthetic $$BindsMirror classes to...
    • support full IC compatibility with changing annotations and return types on @Binds and @Multibinds declarations
    • allow these declarations to be private
  • Enhancement: Allow @Binds and @Multibinds functions to be private.
  • Enhancement: Allow "static graphs" via companions implementing the graph interface itself.
  • Enhancement: Allow graphs to aggregate internal contributions from other compilations IFF those compilations are marked as friend paths. This mainly allows for test graphs to consume contributions from their corresponding main source sets.
  • Enhancement: Allow internal graphs to extend internal contributed interfaces from other compilations IFF those compilations are marked as friend paths.
  • Fix: Sort soft edges before hard edges within (valid) cycles. Previously we would just apply a standard topological sort here, but in this scenario we want to add extra weight to ready-up nodes that depend directly on the deferred type being used to break the cycle first.
  • Fix: When recording IC lookups of overridable declarations, only record the original declaration and not fake overrides.
  • Fix: Record IC lookups to @Multibinds declarations.
  • Fix: Write @Multibinds information to metro metadata.
  • Fix: Always write metro metadata to @BindingContainer classes, even if empty.
  • Fix: When @Includes-ing other graphs, link against the original interface accessor rather than the generated $$MetroGraph accessor.
  • Fix: Disambiguate contributed nullable bindings from non-nullable bindings.
  • Fix: When computing @Includes graph dependencies from accessors, only consider directly included graphs and not transitively included graphs.
  • Fix: Expose @Includes graph dependencies as synthetic _metroAccessor types for extended graphs rather than exposing the included graph directly.
  • Fix: Prohibit calling .asContribution() on @ContributesGraphExtension-annotated types. @ContributesGraphExtension-annotated types cannot be validated at compile-time with this function as their generated class is definitionally contextual and the compiler cannot infer that from callsites of this function alone.
  • Fix: Only process @DependencyGraph types in FIR supertype generation. Contributed graph extension supertypes are merged only in IR.
  • Fix: Generate $$MetroContribution binds functions before aggregating contributions.
  • Fix: Don't short-circuit class visiting in contribution visiting in IR.
  • Fix: Propagate property annotations for @Provides-properties, previously only the accessor function annotations were being included.
  • Fix: Propagate class annotations for @Inject-annotated constructors to factory class mirror functions, previously only the constructor's annotations were being included.
  • Fix: Fix dispatch receiver for DelegateFactory fields when chunkFieldInits is enabled.
  • Fix: Fix compilation error for members-injected classes with no direct, but only inherited @Inject attributes.
  • Fix: Always look up member injectors of ancestor classes of classes member-injected by graphs (sorry, word soup I know).
  • Fix: Ensure $$MetroContribution interfaces are not generated for binding containers by ensuring binding container annotations are readable during their generation.
  • Change to UnsupportedOperationException for compiler intrinsic stubs, matching what the stdlib does.
  • Add a ViewModel assisted injection example to compose-navigation-app sample.
  • Small improvements to the doc site (404 page, favicon, etc.)

Special thanks to @hossain-khan, @bnorm, @yschimke, @kevinguitar, and @JoelWilcox for contributing to this release!

What's Changed

New Contributors

Full Changelog: 0.5.2...0.5.3

0.5.2

21 Jul 14:43
Compare
Choose a tag to compare
  • Enhancement: De-dupe contributions before processing in contributed graphs.
  • Fix: Don't extend contributed binding container classes in generated contributed graphs.
  • Small doc fixes.

Special thanks to @bnorm and @alexvanyo for contributing to this release!

What's Changed

  • Fail tests eagerly when compiler plugins report errors by @bnorm in #741
  • Move remaining Dagger interop tests to Kotlin test infrastructure by @bnorm in #749
  • Link @ContributesGraphExtension to dependency-graphs documentation by @alexvanyo in #748
  • Remove references to @Multibinding by @alexvanyo in #745
  • Parallelize gradle tests by @ZacSweers in #754
  • Update plugin spotless to v7.2.0 by @renovate[bot] in #756
  • Update ktor monorepo to v3.2.2 by @renovate[bot] in #714
  • Update junit-framework monorepo to v5.13.4 by @renovate[bot] in #763
  • Don't extend contributed containers in IR by @ZacSweers in #766

New Contributors

Full Changelog: 0.5.1...0.5.2

0.5.1

18 Jul 16:22
Compare
Choose a tag to compare
  • Breaking change: Rename the generateHintProperties Gradle DSL property to generateContributionHints.
  • Enhancement: Chunk field initializers and constructor statements across multiple init functions to avoid MethodTooLargeException in large graphs. This is currently experimental and gated behind the chunkFieldInits() Gradle DSL.
  • Enhancement: Mark generated factories and member injectors' constructors as private, matching the same change in Dagger 2.57.
  • Enhancement: Add a new Metro option warnOnInjectAnnotationPlacement to disable suggestion to lift @Inject to class when there is only one constructor, the warning applies to constructors with params too.
  • Fix: Fix @Contributes*.replaces not working if the contributed type is in the same compilation but a different file.
  • Fix: Fix generated MembersInjector.create() return types' generic argument to use the target class.
  • Fix: Don't generated nested MetroContribution classes for binding containers.
  • Fix: Fix contributing binding containers across compilations.

Special thanks to @kevinguitar and @ChristianKatzmann for contributing to this release!

What's Changed

Full Changelog: 0.5.0...0.5.1

0.5.0

14 Jul 07:40
Compare
Choose a tag to compare
  • New: Experimental support for "binding containers" via @BindingContainer. See their docs for more details.
  • New: Add keys-scopedProviderFields-*.txt and keys-providerFields-*.txt reports to see generated field reports for graphs.
  • Enhancement: Remove Any constraint from binding<T>(), allowing bindings to satisfy nullable variants.
  • Enhancement: Add diagnostic to check for scoped @Binds declarations. These are simple pipes and should not have scope annotations.
  • Enhancement: Move graph dependency cycle checks to earlier in validation.
  • Enhancement: When using Dagger interop, default allowEmpty to true when using Dagger's @Multibinds annotation.
  • Enhancement: Make Dagger interop providers/lazy instances a dagger.internal.Provider internally for better compatibility with Dagger internals. Some dagger-generated code assumes this type at runtime.
  • Enhancement: Support javax/jakarta Provider types as multibinding Map value types when Dagger interop is enabled.
  • Enhancement: Completely skip processing local and enum classes as they're irrelevant to Metro's compiler.
  • Enhancement: When reporting @Binds declarations in binding stacks, report the original declaration rather than inherited fake overrides.
  • Enhancement: Add interop support for kotlin-inject's @AssistedFactory annotations.
  • Enhancement: Add diagnostic to check for graph classes directly extending other graph classes. You should use @Extends.
  • Enhancement: Add diagnostic to check for @Assisted parameters in provides functions.
  • Enhancement: Add diagnostic to check duplicate @Provides declaration names in the same class.
  • Fix: Within (valid) cycles, topographically sort bindings within the cycle. Previously these would fall back to a deterministic-but-wrong alphabetical sort.
  • Fix: Handle enum entry arguments to qualifier, scope, and map key annotations.
  • Fix: Report the original location of declarations in fake overrides in error reporting.
  • Fix: Handle default values on provides parameters with absent bindings during graph population.
  • Fix: Don't try to read private accessors of @Includes parameters.
  • Fix: Don't quietly stub accessors for missing Binding.Provided bindings.
  • Fix: Check constructor-annotated injections when discovering scoped classes in parent graphs.
  • Fix: Fix BaseDoubleCheck.isInitialized().
  • Fix: Gracefully fall back to MessageCollector for graph seal and contributed graph errors on sourceless declarations.
  • Fix: Fix supporting overloads of binds functions from parent graphs or external supertypes.
  • Fix: Fix generating binding functions with names that contain dashes.
  • Fix: Treat interop'd Dagger/Anvil/KI components as implicitly extendable.
  • Fix: Record lookups of @Binds declarations for IC.
  • Fix: Record lookups of generated class factories and their constructor signatures for IC.

Special thanks to @kevinguitar, @gabrielittner, @chrisbanes, @yschimke, and @ajarl for contributing to this release!

What's Changed

  • Update dependency org.junit.jupiter:junit-jupiter to v5.13.2 by @renovate[bot] in #628
  • Update dependency io.github.classgraph:classgraph to v4.8.180 by @renovate[bot] in #629
  • Update ksp monorepo to v2.2.0-2.0.2 by @renovate[bot] in #630
  • Update plugin poko to v0.19.0 by @renovate[bot] in #637
  • Update atomicfu to v0.29.0 by @renovate[bot] in #636
  • Update dependency com.facebook:ktfmt to v0.56 - autoclosed by @renovate[bot] in #635
  • Update plugin binaryCompatibilityValidator to v0.18.0 by @renovate[bot] in #634
  • Update dependency org.jetbrains.kotlinx:kotlinx-datetime to v0.7.0 by @renovate[bot] in #632
  • Update circuit to v0.29.0 by @renovate[bot] in #639
  • Add a WorkManager sample by @yschimke in #578
  • Update dependency androidx.work:work-runtime to v2.10.2 by @renovate[bot] in #641
  • Update dependency com.squareup.okio:okio to v3.14.0 by @renovate[bot] in #642
  • Update kotlinx.serialization to v1.9.0 by @renovate[bot] in #640
  • Update okhttp monorepo to v5.0.0-alpha.17 by @renovate[bot] in #643
  • Update dependency mkdocs-material to v9.6.15 by @renovate[bot] in #648
  • Update circuit to v0.29.1 by @renovate[bot] in #646
  • Update plugin shadow to v9.0.0-rc1 by @renovate[bot] in #652
  • Update okio to v3.15.0 by @renovate[bot] in #650
  • Update dependency androidx.navigation:navigation-compose to v2.9.1 by @renovate[bot] in #653
  • Update kct to v0.8.0 by @renovate[bot] in #657
  • Remove Any bound from binding.kt by @ZacSweers in #654
  • Report the original location of declarations in fake overrides in error reporting by @ZacSweers in #658
  • Handle absent bindings during graph population by @ZacSweers in #660
  • Update okhttp monorepo to v5.0.0 by @renovate[bot] in #662
  • Update ktor monorepo to v3.2.1 by @renovate[bot] in #661
  • Update junit-framework monorepo to v5.13.3 by @renovate[bot] in #667
  • Update dependency gradle to v8.14.3 by @renovate[bot] in #668
  • Initial support of binding containers by @ZacSweers in #626
  • Add diagnostic for scopes on binds annotations by @ZacSweers in #670
  • Check constructor annotations in IrContributionVisitor by @ZacSweers in #671
  • Support javax/jakarta Providers as map multibinding value types by @kevinguitar in #666
  • Allow empty multibinding for Dagger's @Multibinds interop by @kevinguitar in #672
  • Fix BaseDoubleCheck.isInitialized() check by @kevinguitar in #673
  • Update dependency org.jetbrains.kotlinx:kotlinx-datetime to v0.7.1-0.6.x-compat by @renovate[bot] in #674
  • Update okhttp monorepo to v5.1.0 by @renovate[bot] in #675
  • Update wire to v5.3.4 by @renovate[bot] in #678
  • Update plugin spotless to v7.1.0 by @renovate[bot] in #676
  • Prohibit direct graph extension of other graph classes by @ZacSweers in #679
  • Add KI's new assistedfactory annotation by @ZacSweers in #680
  • Log function name for IR param size difference error by @chrisbanes in #684
  • Update wire to v5.3.5 by @renovate[bot] in #681
  • Sort within SCCs by @ZacSweers in #683
  • Update plugin binaryCompatibilityValidator to v0.18.1 by @renovate[bot] in #686
  • Update dependency com.google.googlejavaformat:google-java-format to v1.28.0 by @renovate[bot] in #687
  • Disallow assisted provides parameters by @ZacSweers in #688
  • Fall back to MessageCollector for seal errors with no file by @ZacSweers in #693
  • Handle enum arguments in renderAsAnnotationArgument by @ZacSweers in #695
  • Another message collector fallback by @ZacSweers in #696
  • Fix generating binding functions with names that contain - by @ajarl in #698
  • Update plugin poko to v0.19.1 by @renovate[bot] in #699
  • Propagate binding containers from annotation inclusions by @ZacSweers in #700
  • Better handle empty graphs by @ZacSweers in #701
  • Add checkers for binding containers by @ZacSweers in #702
  • Binding containers interop by @ZacSweers in #705
  • Run multiplatform tests on main only + macos by @ZacSweers in #706
  • Add binding container IC tests by @ZacSweers in #707
  • Fix factory class lookups in IC by @kevinguitar in #703
  • Disallow contributed binding container for now by @ZacSweers in #708
  • Revert "Disallow contributed binding container for now" by @ZacSweers in #709
  • Implement contribution merging for binding containers by @ZacSweers in #710

New Contributors

Read more

0.4.0

23 Jun 15:27
Compare
Choose a tag to compare
  • New: Injected constructors may now be private. This can be useful for scenarios where you want @Inject-annotated constructors to only be invokable by Metro's generated code.
  • New: If reporting is enabled, write unused bindings diagnostics to keys-unused-*.txt.
  • New: Support for generic assisted injection.
  • New: Support for generic member injection.
  • New: Add diagnostic to prohibit type parameters on injected member functions.
  • Enhancement: Enable child graphs to depend on parent-scoped dependencies that are unused and not referenced in the parent scope. This involves generating hints for scoped @Inject classes and is gated on a new Metro option enableScopedInjectClassHints, which is enabled by default.
  • Enhancement: Check for context parameters in top-level function injection checker.
  • Enhancement: Store member injection info in metro metadata to slightly optimize member injection code gen.
  • Enhancement: Avoid writing providers fields in graphs for unused bindings.
  • Enhancement: Improve missing binding trace originating from root member injectors.
  • Fix: Fix support for generic injected constructor parameters.
  • Fix: Fix support for repeated contributes annotations by moving contribution binding function generation to IR.
  • Fix: Ensure scope/qualifier annotation changes on constructor-injected classes dirty consuming graphs in incremental compilation.
  • Fix: Report member injection dependencies when looking up constructor-injected classes during graph population.
  • Fix: Disable IR hint generation on JS targets too, as these now have the same limitation as native/WASM targets in Kotlin 2.2. Pending upstream support for generating top-level FIR declarations in KT-75865.
  • Fix: Ensure private provider function annotations are propagated across compilation boundaries.
  • Fix: Substitute copied FIR type parameter symbols with symbols from their target functions.
  • Fix: Improved support for generic member injection.
  • Fix: Propagate qualifiers on graph member injector functions.
  • Fix: Fix support for requesting MembersInjector types.
  • [internal] Report IR errors through IrDiagnosticReporter.
  • [internal] Significantly refactor + simplify IR parameter handling.
  • Fix publishing Apple native targets in snapshots.
  • Update to Kotlin 2.2.0.
  • Update Gradle plugin to target Kotlin language version to 1.9 (requires Gradle 8.3+).

Special thanks to @kevinguitar, @gabrielittner, and @JoelWilcox for contributing to this release!

What's Changed

Full Changelog: 0.3.8...0.4.0

0.3.8

16 Jun 15:15
Compare
Choose a tag to compare
  • Enhancement: Disambiguate MetroContribution class names based on scope to better support IC when changing scopes.
  • Enhancement: Minimize deferred types when breaking cycles.
  • Fix: Disallow injection of Lazy<T> where T is an @AssistedFactory-annotated class.
  • Fix: Don't short-circuit assisted injection validation if only an accessor exists.
  • Fix: Allow cycles of assisted factories to their target classes.
  • Update shaded okio to 3.13.0.
  • Update atomicfu to 0.28.0.

Special thanks to @kevinguitar, @bnorm, and @JoelWilcox for contributing to this release!

What's Changed

Full Changelog: 0.3.7...0.3.8

0.3.7

08 Jun 10:45
Compare
Choose a tag to compare
  • 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!

What's Changed

Full Changelog: 0.3.6...0.3.7

0.3.6

06 Jun 22:25
Compare
Choose a tag to compare
  • New: Add new Provider.map, Provider.flatMap, Provider.zip, and Provider.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!

What's Changed

  • Deterministic IrType.render + sorted sets/maps again by @ZacSweers in #518
  • Failing test for ContributesGraphExtension missing binding when using @includes in parent by @kevinguitar in #526
  • Add new Provider utils by @ZacSweers in #527
  • Update wire to v5.3.2 by @renovate in #532
  • Update dependency androidx.fragment:fragment-ktx to v1.8.8 by @renovate in #536
  • Update dependency androidx.appcompat:appcompat to v1.7.1 by @renovate in #535
  • Update dependency androidx.lifecycle:lifecycle-viewmodel-ktx to v2.9.1 by @renovate in #537
  • Reparent copied lambda default values in IR. by @ZacSweers in #539
  • Fail with a clear error message if languageVersion is too old by @ZacSweers in #540
  • Validate assisted inject dependencies by @ZacSweers in #542
  • Update dependency androidx.lifecycle:lifecycle-runtime-compose to v2.9.1 by @renovate in #545
  • Update dependency gradle to v8.14.2 by @renovate in #546
  • Update wire to v5.3.3 by @renovate in #550

Full Changelog: 0.3.5...0.3.6

0.3.5

31 May 14:03
Compare
Choose a tag to compare
  • 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!

What's Changed

Full Changelog: 0.3.4...0.3.5

0.3.4

27 May 19:36
Compare
Choose a tag to compare
  • 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!

What's Changed

New Contributors

Full Changelog: 0.3.3...0.3.4