google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.72k stars 254 forks source link

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

Open IsakTheHacker opened 3 months ago

IsakTheHacker commented 3 months ago

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 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:

typealias MyHiltViewModel = dagger.hilt.android.lifecycle.HiltViewModel
typealias MyInject = javax.inject.Inject

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

}
aftabahmadTW commented 3 months ago

@ting-yuan any help you can provide here?