Created
March 4, 2024 23:30
-
-
Save MarcusDunn/d57e8875828ed980a2a37551d513a399 to your computer and use it in GitHub Desktop.
This file contains 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
import org.koin.dsl.bind | |
import org.koin.dsl.koinApplication | |
import org.koin.dsl.module | |
import kotlin.test.Test | |
import kotlin.test.fail | |
private fun module(useB: Boolean) = module { | |
single { AImpl() } | |
single { BAndAImpl() } | |
single { get<BAndAImpl>() } bind B::class | |
single { | |
if (useB) { | |
get<BAndAImpl>() | |
} else { | |
get<AImpl>() | |
} | |
} bind A::class | |
} | |
private interface A { | |
} | |
private interface B { | |
} | |
private class AImpl : A | |
private class BAndAImpl : A, B | |
class ReproStackOverflowTest { | |
@Test | |
fun stackOverflowTest() { | |
val koin = koinApplication { | |
modules(module(useB = false)) | |
} | |
try { | |
koin.koin.get<A>() | |
koin.koin.get<B>() | |
} catch (e: Exception) { | |
fail(e.message) | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment