fix(compiler): Fix search for one element cycles (#797)

This commit is contained in:
InversionSpaces 2023-07-14 14:06:21 +02:00 committed by GitHub
parent 0f9c40e9d1
commit 33ab33d4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,12 +40,10 @@ object Linker extends Logging {
case path :: otherPaths =>
val pathDeps = deps.get(path.last).toList.flatten
val cycles = pathDeps.flatMap(dep =>
NonEmptyChain
.fromChain(
// This is slow
path.toChain.dropWhile(_ != dep)
)
.toList
NonEmptyChain.fromChain(
// This is slow
path.toChain.dropWhile(_ != dep)
)
)
val newPaths = pathDeps
.filterNot(visited.contains)
@ -62,7 +60,7 @@ object Linker extends Logging {
.flatMap(m =>
findCycles(
paths = NonEmptyChain.one(m.id) :: Nil,
visited = Set.empty,
visited = Set(m.id),
result = List.empty
)
)