Skip to content

Commit 4015ef0

Browse files
committed
fix(cabal-install): rewrite dependencyInconsistencies
1 parent c213cea commit 4015ef0

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

cabal-install/src/Distribution/Client/SolverInstallPlan.hs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,16 @@ import Prelude ()
5656
import Distribution.Package
5757
( HasUnitId (..)
5858
, Package (..)
59-
, PackageId
6059
, PackageIdentifier (..)
61-
, PackageName
62-
, packageName
63-
, packageVersion
6460
)
6561
import qualified Distribution.Solver.Types.ComponentDeps as CD
6662
import Distribution.Types.Flag (nullFlagAssignment)
6763

6864
import Distribution.Client.Types
6965
( UnresolvedPkgLoc
7066
)
71-
import Distribution.Version
72-
( Version
73-
)
7467

68+
import Distribution.Solver.Types.PackagePath (QPN)
7569
import Distribution.Solver.Types.ResolverPackage
7670
import Distribution.Solver.Types.SolverId
7771
import Distribution.Solver.Types.SolverPackage
@@ -189,7 +183,7 @@ data SolverPlanProblem
189183
SolverPlanPackage
190184
[PackageIdentifier]
191185
| PackageCycle [SolverPlanPackage]
192-
| PackageInconsistency PackageName [(PackageIdentifier, Version)]
186+
| PackageInconsistency QPN [(SolverId, SolverId)]
193187
| PackageStateInvalid SolverPlanPackage SolverPlanPackage
194188

195189
showPlanProblem :: SolverPlanProblem -> String
@@ -210,7 +204,7 @@ showPlanProblem (PackageInconsistency name inconsistencies) =
210204
[ " package "
211205
++ prettyShow pkg
212206
++ " requires "
213-
++ prettyShow (PackageIdentifier name ver)
207+
++ prettyShow ver
214208
| (pkg, ver) <- inconsistencies
215209
]
216210
showPlanProblem (PackageStateInvalid pkg pkg') =
@@ -267,7 +261,7 @@ problems index =
267261
-- for them here.
268262
dependencyInconsistencies
269263
:: SolverPlanIndex
270-
-> [(PackageName, [(PackageIdentifier, Version)])]
264+
-> [(QPN, [(SolverId, SolverId)])]
271265
dependencyInconsistencies index =
272266
concatMap dependencyInconsistencies' subplans
273267
where
@@ -318,6 +312,8 @@ rootSets index = [libRoots] ++ setupRoots index
318312
--
319313
-- The library roots are the set of packages with no reverse dependencies
320314
-- (no reverse library dependencies but also no reverse setup dependencies).
315+
--
316+
-- FIXME: misleading name, this includes executables too!
321317
libraryRoots :: SolverPlanIndex -> [SolverId]
322318
libraryRoots index =
323319
map (nodeKey . toPkgId) roots
@@ -345,9 +341,14 @@ setupRoots =
345341
-- distinct.
346342
dependencyInconsistencies'
347343
:: SolverPlanIndex
348-
-> [(PackageName, [(PackageIdentifier, Version)])]
344+
-> [(QPN, [(SolverId, SolverId)])]
349345
dependencyInconsistencies' index =
350-
[ (name, [(pid, packageVersion dep) | (dep, pids) <- uses, pid <- pids])
346+
[ ( name
347+
, [ (sid, solverId dep)
348+
| (dep, sids) <- uses
349+
, sid <- sids
350+
]
351+
)
351352
| (name, ipid_map) <- Map.toList inverseIndex
352353
, let uses = Map.elems ipid_map
353354
, length uses > 1
@@ -357,11 +358,11 @@ dependencyInconsistencies' index =
357358
-- and each installed ID of that package
358359
-- the associated package instance
359360
-- and a list of reverse dependencies (as source IDs)
360-
inverseIndex :: Map PackageName (Map SolverId (SolverPlanPackage, [PackageId]))
361+
inverseIndex :: Map QPN (Map SolverId (SolverPlanPackage, [SolverId]))
361362
inverseIndex =
362363
Map.fromListWith
363364
(Map.unionWith (\(a, b) (_, b') -> (a, b ++ b')))
364-
[ (packageName dep, Map.fromList [(sid, (dep, [packageId pkg]))])
365+
[ (solverQPN dep, Map.fromList [(sid, (dep, [solverId pkg]))])
365366
| -- For each package @pkg@
366367
pkg <- Foldable.toList index
367368
, -- Find out which @sid@ @pkg@ depends on

0 commit comments

Comments
 (0)