Skip to content

Can't use compile-time constant string as a configuration name #60

Description

@Terenfear

Description

Using a compile-time constant string as a configuration name leads to the module being incorrectly assigned to the default configuration.

To reproduce, try this:

const val TEST_CONFIG_NAME = "test"

@Module
@Configuration(TEST_CONFIG_NAME)
class TestModule

@KoinApplication(configurations = ["test"])
object KoinApp

In debug logs you'll be able to see clearly that this module is treated as a part of the default configuration.

Also there's an error in logs (although for some reason only in some cases, haven't been able to figure out which ones):
w: [Koin-Debug-FIR] -> Unknown expression type for @Configuration: FirPropertyAccessExpressionImpl
It makes sense since FIR only works with literals and varargs of literals:

Honestly would be good to get an actual build-stopping error, it took way too much time to figure out.

Versions

Koin version: 4.2.2
Plugin version: 1.0.1
Kotlin version: 2.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions