Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ Changelog

- [IR] Never eagerly init graph extension impls (scoped or not).
- [IR] Don't cache creator-less scoped graph extension impls in their parent graphs. This was initially implemented this way due to a misunderstanding to how Dagger generated subcomponents! Getters for graph extensions now always return new instances.
- [IR] Check for `open` or `final` modality on classes first before searching for injectable constructors.
- [IC] Record lookups of contributed classes when looking up hints from IR. Previously Metro only recorded a lookup of the generated hint function, which appears to not be enough for Kotlin 2.3.20.
- [IC] Link IR-generated hint function files back to source class via expect-actual tracker to link their compilations. This fixes an edge case where simply changing a contribution scope (or removing it) could leave behind a stale hint file that downstream compilations would incidentally read.
- [FIR] Ensure hint functions generated by FIR hint generation match the visibility of the source contributor.

### Changes

- Enable `contributesAsInject` by default. See its docs for more details, but in short this means that `@Inject` is now optional on `@ContributesBinding`, `@ContributesIntoSet`, and `@ContributesIntoMap` annotated declarations.
```kotlin
@ContributesBinding(AppScope::class)
// @Inject // <-- now implicit!
class TacoImpl(...) : Taco
```
- [IR] Already mentioned above, but worth calling out again — creator-less scoped graph extensions _are no longer cached_ in their parent graphs. Accessors to this will always get new instances now.
- [IR] Report log files reported from within graph generation now use snake-cased fully-qualified names of the impl graph as the file name suffix.
- [IR] Do not report similar bindings when a missing binding has type `kotlin.Any`. In practice this reported all available bindings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.backend.jvm.ir.isWithFlexibleNullability
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocationWithRange
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.Modality
Expand Down Expand Up @@ -1551,9 +1552,11 @@ private fun List<IrConstructorCall>?.annotationsAnnotatedWith(

context(context: IrMetroContext)
internal fun IrClass.findInjectableConstructor(onlyUsePrimaryConstructor: Boolean): IrConstructor? {
if (kind.isObject) {
if (kind != ClassKind.CLASS) {
// No constructor for this one but can be annotated with Contributes*
return null
} else if (modality != Modality.FINAL && modality != Modality.OPEN) {
return null
}
return findInjectableConstructor(
onlyUsePrimaryConstructor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ constructor(
* If enabled, treats `@Contributes*` annotations (except ContributesTo) as implicit `@Inject`
* annotations.
*
* Disabled by default.
* Enabled by default.
*/
public val contributesAsInject: Property<Boolean> =
objects.property(Boolean::class.javaObjectType).convention(false)
objects.property(Boolean::class.javaObjectType).convention(true)

/**
* If set, the Metro compiler will dump verbose report diagnostics about resolved dependency
Expand Down