kotlin-inject icon indicating copy to clipboard operation
kotlin-inject copied to clipboard

Warn when scope annoation would have no effect

Open denchic45 opened this issue 2 years ago • 5 comments

If I pass the dependency through the provide function using scope, then everything works correctly:

    @MyScope
    @Provides
    fun provideFoo() = Foo()

generation:

foo = _scoped.get("com.example.Foo") {
        provideFoo()
      }

But if I declare a variable instead, then the scope is ignored:

    @MyScope
    abstract val foo: Foo

generation:

  public override val foo: Foo
    get() = Foo()

or:

    @MyScope
    abstract val lambdaFoo: () -> Foo

generation:

  public override val lambdaFoo: Function0<Foo>
    get() = {
      Foo()
    }

denchic45 avatar Oct 29 '22 19:10 denchic45