android / android/nowinandroid

Restrict @Dispatcher qualifier to constructor parameters

Open
#2,001 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

Description

This change would adds @Target(AnnotationTarget.VALUE_PARAMETER) to the @Dispatcher qualifier to explicitly limit its usage to constructor/function parameters.
This removes Kotlin’s use-site target warnings, improves clarity.
I believe Kotlin 2.2 uses param by default it makes it more predictable in Hilt.
(Alternatively, we can add @param e.g @param:Dispatcher(IO), but having @Target reduces boilerplate)

Any suggestion for writing a test for this?

```
@Target(AnnotationTarget.PROPERTY_SETTER)
@Qualifier
@Retention(RUNTIME)
annotation class Dispatcher(val niaDispatcher: NiaDispatchers)

enum class NiaDispatchers {
Default,
IO,
}
```

Contributor guide

Open the contributing guide

Research direction

Locate the @Dispatcher annotation and inspect its current usages and compiler warnings. Check how Kotlin 2.2 resolves the qualifier target, then determine whether an existing test location can verify parameter-only usage and the absence of warnings. Done means the target is restricted as described and the relevant behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.