Skip to content

fix(flatten): use LinkedHashSet instead of HashSet#1841

Merged
arnaudgiuliani merged 2 commits into
InsertKoinIO:3.6.0from
hoc081098:patch-1
Apr 5, 2024
Merged

fix(flatten): use LinkedHashSet instead of HashSet#1841
arnaudgiuliani merged 2 commits into
InsertKoinIO:3.6.0from
hoc081098:patch-1

Conversation

@hoc081098

Copy link
Copy Markdown
Contributor

to maintain the insertion order

@arnaudgiuliani

Copy link
Copy Markdown
Member

still get error, but order is maintained in the reverse order I see 🤔

@Test
    fun `allow overrides by type`() {
        val app = koinApplication {
            modules(
                module {
                    single<Simple.ComponentInterface1> { Simple.Component2() }
                },
                module {
                    single<Simple.ComponentInterface1> { Simple.Component1() }
                },
            )
        }

        app.assertDefinitionsCount(1)
        assertTrue(app.koin.get<Simple.ComponentInterface1>() is Simple.Component1)
    }

Good thing is that order seems stable

image

@arnaudgiuliani arnaudgiuliani added core status:checking currently in analysis - discussion or need more detailed specs labels Apr 5, 2024
@arnaudgiuliani

Copy link
Copy Markdown
Member

Could test that with this test too:

@Test
    fun test_flatten_list() {

        (1..100).all { i ->
            val modules = listOf(module { },module { },module { },module { },module { },module { },module { },module { },module { },module { })
            val flatten = flatten(modules)
            flatten.reversed() == modules
        }
    }

ArrayDeque(modules.asReversed())
@hoc081098

Copy link
Copy Markdown
Contributor Author

@arnaudgiuliani just updated

-ArrayDeque(modules)
+ArrayDeque(modules.asReversed())

@arnaudgiuliani

Copy link
Copy Markdown
Member

Sounds good 🎉. Need to check the fails on test examples 🤔

@arnaudgiuliani

Copy link
Copy Markdown
Member

Seen the problem. It's not from your side 👍 Will fix it

@arnaudgiuliani arnaudgiuliani merged commit c3aad5c into InsertKoinIO:3.6.0 Apr 5, 2024
@hoc081098 hoc081098 deleted the patch-1 branch April 5, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core status:checking currently in analysis - discussion or need more detailed specs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants