@@ -80,15 +80,19 @@ object Writer {
8080 case class CircularExports (
8181 duplicate : UnversionedCoordinate ,
8282 path : List [UnversionedCoordinate ],
83- transitiveSet : List [MavenCoordinate ]
83+ transitiveSet : List [MavenCoordinate ],
84+ // these nodes depend on duplicate, but are also reachable
85+ loopNodes : List [MavenCoordinate ]
8486 ) extends TargetsError {
8587 def message = {
86- val pathStr =
87- path.iterator.map(_.asString).mkString(" [" , " , " , " ]" )
88- val set =
89- transitiveSet.iterator.map(_.asString).mkString(" [" , " , " , " ]" )
88+ def list [A ](i : List [A ])(fn : A => String ): String =
89+ i.iterator.map(fn).mkString(" [" , " , " , " ]" )
9090
91- s " circular exports graph. Node: ${duplicate.asString} -- Path: $pathStr -- ReachableSet: $set"
91+ val pathStr = list(path)(_.asString)
92+ val set = list(transitiveSet)(_.asString)
93+ val loops = list(loopNodes)(_.asString)
94+
95+ s " circular exports graph. Node: ${duplicate.asString} -- Path: $pathStr -- DependsOnNode: $loops -- ReachableSet: $set"
9296 }
9397 }
9498 }
@@ -678,7 +682,15 @@ object Writer {
678682 case Left (existing) if existing.contains(u) =>
679683 val explicitLoopNodes = existing.flatMap(uvToVerExplicit.get(_))
680684 val reachable = g.reflexiveTransitiveClosure(explicitLoopNodes).toList.sorted
681- Left (NonEmptyList .of(TargetsError .CircularExports (u, existing, reachable)))
685+ // which of the reachable items point to the existing
686+ val loops = uvToVerExplicit.get(u) match {
687+ case Some (vu) =>
688+ g.hasDestination(vu).map(_.source).toList.sorted
689+ case None => Nil
690+ }
691+ Left (NonEmptyList .one(
692+ TargetsError .CircularExports (u, existing, reachable, loopNodes = loops)
693+ ))
682694 case Left (existing) =>
683695 cache.update(u, Left (u :: existing))
684696 val res = compute
0 commit comments