From 13318ed2122e886d3a6c0c63bf4e99ab01aed571 Mon Sep 17 00:00:00 2001 From: Arnaud Giuliani Date: Wed, 10 Jul 2024 18:14:03 +0200 Subject: [PATCH] Comment equals/hashcode on beandefinition to let have modules with same definition, but different instance factory --- .../org/koin/core/instance/InstanceFactory.kt | 10 ---------- .../org/koin/dsl/ModuleFactoryIsolationTest.kt | 14 +++++++++++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/projects/core/koin-core/src/commonMain/kotlin/org/koin/core/instance/InstanceFactory.kt b/projects/core/koin-core/src/commonMain/kotlin/org/koin/core/instance/InstanceFactory.kt index 944d709cd..cd6deee73 100644 --- a/projects/core/koin-core/src/commonMain/kotlin/org/koin/core/instance/InstanceFactory.kt +++ b/projects/core/koin-core/src/commonMain/kotlin/org/koin/core/instance/InstanceFactory.kt @@ -70,16 +70,6 @@ abstract class InstanceFactory(val beanDefinition: BeanDefinition) : Locka abstract fun dropAll() -// @Suppress("NAME_SHADOWING") -// override fun equals(other: Any?): Boolean { -// val other = (other as? InstanceFactory<*>)?.beanDefinition -// return beanDefinition == other -// } -// -// override fun hashCode(): Int { -// return beanDefinition.hashCode() -// } - companion object { const val ERROR_SEPARATOR = "\n\t" } diff --git a/projects/core/koin-core/src/commonTest/kotlin/org/koin/dsl/ModuleFactoryIsolationTest.kt b/projects/core/koin-core/src/commonTest/kotlin/org/koin/dsl/ModuleFactoryIsolationTest.kt index 943ae5f0b..894eabffc 100644 --- a/projects/core/koin-core/src/commonTest/kotlin/org/koin/dsl/ModuleFactoryIsolationTest.kt +++ b/projects/core/koin-core/src/commonTest/kotlin/org/koin/dsl/ModuleFactoryIsolationTest.kt @@ -9,8 +9,7 @@ import kotlin.test.assertTrue val myValModule = module { single { Simple.ComponentA() } } -val myGetModule : Module - get() = module { single { Simple.ComponentA() } } +val myGetModule : Module get() = module { single { Simple.ComponentA() } } fun myFunModule() = module { single { Simple.ComponentA() } } @@ -37,4 +36,13 @@ class ModuleFactoryIsolationTest { assertEquals(aF.mappings.values.first().beanDefinition, bF.mappings.values.first().beanDefinition) } -} \ No newline at end of file + @Test + fun testVariableIsolationAndInstanceFactoriesLocal(){ + assertTrue(a.mappings != b.mappings) + assertEquals(a.mappings.values.first().beanDefinition, b.mappings.values.first().beanDefinition) + } + +} + +val ModuleFactoryIsolationTest.a : Module get() = myGetModule +val ModuleFactoryIsolationTest.b : Module get() = myGetModule