google / google/ksp

KSP doesn't accept typealiases of @Inject, @HiltViewModel etc. annotations and no code is generated

Open
#1,774 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

I am raising an issue here to raise attention of this issue. The bug currently makes it impossible to have a typealias of the @Inject annotation to enable multiplatform support for example and there are probably many more usecases where the behaviour I am going to describe breaks things.

There is an [issue](https://youtrack.jetbrains.com/issue/KT-62179/KMPKAPT-KSP-Kotlin-1.9-doesnt-recognize-multiplatform-alias-for-Inject) in the Kotlin issue tracker that provides more context but this is the gist of it. It isn't currently possible to create a ViewModel like this and have it injected by Dagger Hilt:
```kotlin
typealias MyHiltViewModel = dagger.hilt.android.lifecycle.HiltViewModel
typealias MyInject = javax.inject.Inject

@MyHiltViewModel
class ExampleViewModel @MyInject constructor() : ViewModel() {

}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.