Skip to content

Commit 0fbb0db

Browse files
authored
Merge pull request #10488 from AndreasPK/selector_fix
Fix a incomplete selector warning
2 parents de03759 + 419890c commit 0fbb0db

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

Cabal/src/Distribution/Simple/Build/Macros.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ generateCabalMacrosHeader pkg_descr lbi clbi =
5858
, let (major1, major2, minor) = majorMinor ver
5959
]
6060
, Z.zPackageKey = case clbi of
61-
LibComponentLocalBuildInfo{} -> componentCompatPackageKey clbi
61+
LibComponentLocalBuildInfo{componentCompatPackageKey = compatPackageKey} -> compatPackageKey
6262
_ -> ""
6363
, Z.zComponentId = prettyShow (componentComponentId clbi)
6464
, Z.zPackageVersion = pkgVersion (package pkg_descr)

Cabal/src/Distribution/Simple/Register.hs

+5-3
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
497497
{ IPI.sourcePackageId = packageId pkg
498498
, IPI.installedUnitId = componentUnitId clbi
499499
, IPI.installedComponentId_ = componentComponentId clbi
500-
, IPI.instantiatedWith = componentInstantiatedWith clbi
500+
, IPI.instantiatedWith = expectLibraryComponent (maybeComponentInstantiatedWith clbi)
501501
, IPI.sourceLibName = libName lib
502-
, IPI.compatPackageKey = componentCompatPackageKey clbi
502+
, IPI.compatPackageKey = expectLibraryComponent (maybeComponentCompatPackageKey clbi)
503503
, -- If GHC >= 8.4 we register with SDPX, otherwise with legacy license
504504
IPI.license =
505505
if ghc84
@@ -518,7 +518,7 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
518518
, IPI.indefinite = componentIsIndefinite clbi
519519
, IPI.exposed = libExposed lib
520520
, IPI.exposedModules =
521-
componentExposedModules clbi
521+
expectLibraryComponent (maybeComponentExposedModules clbi)
522522
-- add virtual modules into the list of exposed modules for the
523523
-- package database as well.
524524
++ map (\name -> IPI.ExposedModule name Nothing) (virtualModules bi)
@@ -601,6 +601,8 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
601601
)
602602
| otherwise =
603603
(libdir installDirs : dynlibdir installDirs : extraLibDirs', [])
604+
expectLibraryComponent (Just attribute) = attribute
605+
expectLibraryComponent Nothing = (error "generalInstalledPackageInfo: Expected a library component, got something else.")
604606

605607
-- the compiler doesn't understand the dynamic-library-dirs field so we
606608
-- add the dyn directory to the "normal" list in the library-dirs field

Cabal/src/Distribution/Types/ComponentLocalBuildInfo.hs

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module Distribution.Types.ComponentLocalBuildInfo
66
( ComponentLocalBuildInfo (..)
77
, componentIsIndefinite
88
, maybeComponentInstantiatedWith
9+
, maybeComponentCompatPackageKey
10+
, maybeComponentExposedModules
911
) where
1012

1113
import Distribution.Compat.Prelude
@@ -126,3 +128,13 @@ maybeComponentInstantiatedWith :: ComponentLocalBuildInfo -> Maybe [(ModuleName,
126128
maybeComponentInstantiatedWith
127129
LibComponentLocalBuildInfo{componentInstantiatedWith = insts} = Just insts
128130
maybeComponentInstantiatedWith _ = Nothing
131+
132+
maybeComponentCompatPackageKey :: ComponentLocalBuildInfo -> Maybe String
133+
maybeComponentCompatPackageKey
134+
LibComponentLocalBuildInfo{componentCompatPackageKey = key} = Just key
135+
maybeComponentCompatPackageKey _ = Nothing
136+
137+
maybeComponentExposedModules :: ComponentLocalBuildInfo -> Maybe [Installed.ExposedModule]
138+
maybeComponentExposedModules
139+
LibComponentLocalBuildInfo{componentExposedModules = exposed} = Just exposed
140+
maybeComponentExposedModules _ = Nothing

0 commit comments

Comments
 (0)