Fix @Single(createdAtStart=true) silently dropped on definition functions#57
Merged
Merged
Conversation
- single_fun_created_at_start now exercises BOTH per-definition shapes in one non-eager @componentscan module: @singleton(createdAtStart=true) class (buildClassDefinitionCall) and @single(createdAtStart=true) fun (buildFunctionDefinitionCall), each with a lazy counterpart. Verified pre-fix FAIL / post-fix PASS. - app-annotations DatabaseModule: @singleton(createdAtStart=true) on providesDatabase (eager Room DB open at startKoin) — the fixed @Module-function path in a real app. - app-kmp-klib: @single(createdAtStart=true) fun, exercising the fix on KLIB targets (iosArm64 verified).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
koin-compiler-pluginsilently ignoredcreatedAtStart = trueon@Single/@Singletondefinition functions inside a@Module. The generatedbuildSingle(...)fell back to Kotlin's default-arg trampoline (false), so eager singletons were never created atstartKoin— no compile error, no warning (koin#2425, koin#2415).Root cause
createdAtStartpropagation existed inbuildClassDefinitionCallandbuildTopLevelFunctionDefinitionCall, butbuildFunctionDefinitionCall(the@Single/@Singletonfunction inside a @module path) never set it. The module-level fix (RC3.13,@Module(createdAtStart)) masked this in the existing test.Fix
Propagate
createdAtStarttobuildSingle(...)for SINGLE function definitions, mirroring the other two builders.Tests & samples
single_fun_created_at_startin a deliberately non-eager@ComponentScanmodule (so the module-level flag can't mask it), exercising both per-definition shapes:@Singleton(createdAtStart=true) classand@Single(createdAtStart=true) fun, each with a lazy counterpart. Verified pre-fix FAIL / post-fix PASS.app-annotationsDatabaseModule(eager Room DB open) andapp-kmp-klib(@Single(createdAtStart=true)exercised on iosArm64).Full box suite green.
Fixes InsertKoinIO/koin#2425, InsertKoinIO/koin#2415
🤖 Generated with Claude Code