Coder Social home page Coder Social logo

Comments (6)

GoodforGod avatar GoodforGod commented on August 22, 2024 1

Can't guarantee 100% scan on all rounds

Advice: Use injection by class:

@Module
interface FooRepositoryModule {
  fun fooRepository(a: AbstractFooRepository): FooRepository = a
}

from kora.

mitasov-ra avatar mitasov-ra commented on August 22, 2024

Turned out that checking only requested type for @Repository annotation is the specific of Kora's Repository extension.

The intended way of solving the problem is adding:

@Module
interface FooRepositoryModule {
  fun fooRepository(a: AbstractFooRepository): FooRepository = a
}

from kora.

mitasov-ra avatar mitasov-ra commented on August 22, 2024

In 0.13.1 version the above solution doesn't work anymore. But problem still persist.

I get the error:

Required dependency type FooRepository was not found and can't be autocreated.

but now when I try to fix it with module:

@Module
interface FooRepositoryModule {
  fun fooRepository(a: AbstractFooRepository): FooRepository = a
}

I get the following error:

More than one component matches dependency claim FooRepository tag=[]:
  TargetDependency(claim=DependencyClaim(type=FooRepository, tags=[], claimType=ONE_REQUIRED), component=ResolvedComponent(index=125, declaration=FromExtensionComponent(type=$AbstractFooRepository_Impl ...
  TargetDependency(claim=DependencyClaim(type=FooRepository, tags=[], claimType=ONE_REQUIRED), component=ResolvedComponent(index=126, declaration=FromModuleComponent(type=FooRepository, module=MixedInModule(element=Application) ...

The only remaining fix for this issue that I found is manually instantiating $AbstractFooRepository_Impl:

@Module
interface FooRepositoryModule {
  fun fooRepository(/* ... deps ... */): FooRepository = `$AbstractFooRepository_Impl`(/* ... deps ... */)
}

from kora.

Squiry avatar Squiry commented on August 22, 2024

Try put @Component on your repository class.

from kora.

mitasov-ra avatar mitasov-ra commented on August 22, 2024

Tried. Got the error:

ApplicationGraph.kt:1655:11: Cannot create an instance of an abstract class
      component118 = graphDraw.addNode0(map["component118"], 
        arrayOf(),
        { AbstractFooRepository(
          it.get(holder0.component117)
        ) },
        listOf(),
        component117
      )

from kora.

mitasov-ra avatar mitasov-ra commented on August 22, 2024

Kora version: 0.13.3

Now even my last fix (which btw worked in 0.11.10) to directly instantiate $AbstractFooRepository_Impl does not work.

The following Module:

@Module
interface FooRepositoryModule {
  fun fooRepository(/* ... deps ... */): FooRepository = `$AbstractFooRepository_Impl`(/* ... deps ... */)
}

Makes task :kspKotlin run forever.

from kora.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.