Skip to content

Add infix modifier to KoinDefinition.bind in compiler DSL - #2488

Open
Inf1mum wants to merge 1 commit into
InsertKoinIO:mainfrom
Inf1mum:fix/2484-infix-bind
Open

Inf1mum wants to merge 1 commit into
InsertKoinIO:mainfrom
Inf1mum:fix/2484-infix-bind

Conversation

@Inf1mum

@Inf1mum Inf1mum commented Nov 4, 2026

Copy link
Copy Markdown

Description

The bind function of the Compiler Plugin DSL (org.koin.plugin.module.dsl.ModuleExtKt.bind) was not declared infix, so the infix syntax documented at https://insert-koin.io/docs/reference/koin-core/definitions#compiler-plugin-dsl did not compile:

single<ImplClass>() bind InterfaceClass::class   // did not compile before this fix
single<ImplClass>().bind(InterfaceClass::class)  // was the only working form

This adds the infix modifier to KoinDefinition.bind(KClass). The JVM signature is unchanged, so the binary API and the api dump are not affected, and the regular call form keeps working.

Testing

Added ModuleExtTest in koin-core commonTest (package org.koin.plugin.module.dsl):

  • infix form definition bind Interface::class compiles and adds the secondary type to BeanDefinition.secondaryTypes
  • the regular call form definition.bind(Interface::class) still works
  • a definition built with buildSingle + infix bind resolves both by its primary type and by the bound secondary type

Fixes #2484

…compiler DSL

Signed-off-by: Inf1mum <vadim.lazuk@mail.ru>
@Inf1mum

Inf1mum commented Nov 5, 2026

Copy link
Copy Markdown
Author

Hi! These three PRs are my first contributions here, so the CI workflows (Build & Test, Test Examples, CodeQL) are stuck in "Awaiting approval" since Nov 4 and no checks show up on the PRs. Could a maintainer approve the workflow runs and take a look when convenient? (Related: #2489, #2490)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infix version of bind does not exist in compiler DSL

1 participant