Skip to content

Wip/9.10 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/supported-ghc-versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ "9.8", "9.6", "9.4" , "9.2" ]
["9.10", "9.8", "9.6", "9.4" , "9.2" ]
39 changes: 36 additions & 3 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ packages:
./hls-plugin-api
./hls-test-utils

index-state: 2024-04-30T10:44:19Z
index-state: 2024-05-18T02:15:01Z

tests: True
test-show-details: direct

benchmarks: True
-- benchmarks: True

write-ghc-environment-files: never

Expand Down Expand Up @@ -40,4 +40,37 @@ constraints:
-- the flag '-fopen-simd', which blocked the release 2.2.0.0.
-- We want to be able to benefit from the performance optimisations
-- in the future, thus: TODO: remove this flag.
bitvec -simd
bitvec -simd,


if impl(ghc >= 9.9)
benchmarks: False
source-repository-package
type:git
location: https://github.com/wz1000/retrie.git
tag: 7bf599856f055aefa86a6db10c12dcbc10c7130a
constraints:
lens >= 5.3.2,
haskell-language-server -stylishHaskell -ormolu -fourmolu -floskell -hlint,
allow-newer:
co-log-core:base,
constraints-extras:base,
constraints-extras:template-haskell,
commutative-semigroups:base,
dependent-map:containers,
entropy:base,
entropy:directory,
entropy:filepath,
entropy:process,
free:template-haskell,
haddock-library:base,
haddock-library:containers,
hie-bios:ghc,
hiedb:base,
hiedb:ghc,
monoid-subclasses:containers,
quickcheck-instances:base,
quickcheck-instances:containers,
uuid-types:template-haskell,
else
benchmarks: True
2 changes: 1 addition & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ library
, implicit-hie >= 0.1.4.0 && < 0.1.5
, lens
, list-t
, lsp ^>=2.5.0.0
, lsp ^>=2.6.0.0
, lsp-types ^>=2.2.0.0
, mtl
, opentelemetry >=0.6.1
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import Development.IDE.Core.Shake
import Development.IDE.Core.Tracing (withTrace)
import Development.IDE.GHC.Compat hiding (loadInterface,
parseHeader, parseModule,
tcRnModule, writeHieFile)
tcRnModule, writeHieFile, assert)
import qualified Development.IDE.GHC.Compat as Compat
import qualified Development.IDE.GHC.Compat as GHC
import qualified Development.IDE.GHC.Compat.Util as Util
Expand Down
8 changes: 4 additions & 4 deletions ghcide/src/Development/IDE/Core/RuleTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Development.IDE.Core.RuleTypes(
) where

import Control.DeepSeq
import Control.Exception (assert)
import qualified Control.Exception as E
import Control.Lens
import Data.Aeson.Types (Value)
import Data.Hashable
Expand Down Expand Up @@ -188,9 +188,9 @@ hiFileFingerPrint HiFileResult{..} = hirIfaceFp <> maybe "" snd hirCoreFp

mkHiFileResult :: ModSummary -> ModIface -> ModDetails -> ModuleEnv ByteString -> Maybe (CoreFile, ByteString) -> HiFileResult
mkHiFileResult hirModSummary hirModIface hirModDetails hirRuntimeModules hirCoreFp =
assert (case hirCoreFp of Just (CoreFile{cf_iface_hash}, _)
-> getModuleHash hirModIface == cf_iface_hash
_ -> True)
E.assert (case hirCoreFp of
Just (CoreFile{cf_iface_hash}, _) -> getModuleHash hirModIface == cf_iface_hash
_ -> True)
HiFileResult{..}
where
hirIfaceFp = fingerprintToBS . getModuleHash $ hirModIface -- will always be two bytes
Expand Down
8 changes: 7 additions & 1 deletion ghcide/src/Development/IDE/GHC/CPP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import qualified GHC.Driver.Pipeline.Execute as Pipeline
import qualified GHC.SysTools.Cpp as Pipeline
#endif

#if MIN_VERSION_ghc(9,11,0)
import qualified GHC.SysTools.Tasks as Pipeline
#endif

addOptP :: String -> DynFlags -> DynFlags
addOptP f = alterToolSettings $ \s -> s
{ toolSettings_opt_P = f : toolSettings_opt_P s
Expand All @@ -52,7 +56,9 @@ doCpp env input_fn output_fn =
#if MIN_VERSION_ghc(9,5,0)
let cpp_opts = Pipeline.CppOpts
{ cppLinePragmas = True
#if MIN_VERSION_ghc(9,9,0)
#if MIN_VERSION_ghc(9,11,0)
, sourceCodePreprocessor = Pipeline.SCPHsCpp
#elif MIN_VERSION_ghc(9,10,0)
, useHsCpp = True
#else
, cppUseCc = False
Expand Down
11 changes: 9 additions & 2 deletions ghcide/src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ myCoreToStg logger dflags ictxt

return (stg_binds2, denv, cost_centre_info)


#if MIN_VERSION_ghc(9,9,0)
reLocA :: (HasLoc (GenLocated a e), HasAnnotation b)
=> GenLocated a e -> GenLocated b e
reLocA = reLoc
#endif

getDependentMods :: ModIface -> [ModuleName]
#if MIN_VERSION_ghc(9,3,0)
Expand Down Expand Up @@ -510,13 +514,16 @@ data GhcVersion
| GHC94
| GHC96
| GHC98
| GHC910
deriving (Eq, Ord, Show)

ghcVersionStr :: String
ghcVersionStr = VERSION_ghc

ghcVersion :: GhcVersion
#if MIN_VERSION_GLASGOW_HASKELL(9,8,0,0)
#if MIN_VERSION_GLASGOW_HASKELL(9,10,0,0)
ghcVersion = GHC910
#elif MIN_VERSION_GLASGOW_HASKELL(9,8,0,0)
ghcVersion = GHC98
#elif MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
ghcVersion = GHC96
Expand Down
37 changes: 33 additions & 4 deletions ghcide/src/Development/IDE/GHC/Compat/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ module Development.IDE.GHC.Compat.Core (
pattern RealSrcLoc,
SrcLoc.SrcLoc(SrcLoc.UnhelpfulLoc),
BufSpan,
#if !MIN_VERSION_ghc(9,9,0)
GHC.SrcAnn,
#endif
SrcLoc.leftmost_smallest,
SrcLoc.containsSpan,
SrcLoc.mkGeneralSrcSpan,
Expand Down Expand Up @@ -494,8 +496,11 @@ import Data.Foldable (toList)
import GHC.Core.Multiplicity (scaledThing)
import GHC.Data.Bag
import GHC.Driver.Env
import GHC.Hs (HsModule (..), SrcSpanAnn')
import GHC.Hs.Decls hiding (FunDep)
import GHC.Hs (HsModule (..))
#if !MIN_VERSION_ghc(9,9,0)
import GHC.Hs (SrcSpanAnn')
#endif
import GHC.Hs.Decls hiding (FunDep)
import GHC.Hs.Doc
import GHC.Hs.Expr
import GHC.Hs.Extension
Expand Down Expand Up @@ -651,20 +656,36 @@ instance HasSrcSpan SrcSpan where
instance HasSrcSpan (SrcLoc.GenLocated SrcSpan a) where
getLoc = GHC.getLoc

#if MIN_VERSION_ghc(9,9,0)
instance HasSrcSpan (EpAnn a) where
getLoc = GHC.getHasLoc
#endif

#if MIN_VERSION_ghc(9,9,0)
instance HasSrcSpan (SrcLoc.GenLocated (EpAnn ann) a) where
getLoc (L l _) = getLoc l
#else
instance HasSrcSpan (SrcSpanAnn' ann) where
getLoc = GHC.locA
instance HasSrcSpan (SrcLoc.GenLocated (SrcSpanAnn' ann) a) where
getLoc (L l _) = l
#endif

pattern L :: HasSrcSpan a => SrcSpan -> e -> SrcLoc.GenLocated a e
pattern L l a <- GHC.L (getLoc -> l) a
{-# COMPLETE L #-}

-- This is from the old api, but it still simplifies
pattern ConPatIn :: SrcLoc.Located (ConLikeP GhcPs) -> HsConPatDetails GhcPs -> Pat GhcPs
#if MIN_VERSION_ghc(9,9,0)
pattern ConPatIn con args <- ConPat _ (L _ (SrcLoc.noLoc -> con)) args
where
ConPatIn con args = ConPat GHC.noAnn (GHC.noLocA $ SrcLoc.unLoc con) args
#else
pattern ConPatIn con args <- ConPat EpAnnNotUsed (L _ (SrcLoc.noLoc -> con)) args
where
ConPatIn con args = ConPat EpAnnNotUsed (GHC.noLocA $ SrcLoc.unLoc con) args
#endif

conPatDetails :: Pat p -> Maybe (HsConPatDetails p)
conPatDetails (ConPat _ _ args) = Just args
Expand All @@ -680,8 +701,16 @@ initObjLinker env =
GHCi.initObjLinker (GHCi.hscInterp env)

loadDLL :: HscEnv -> String -> IO (Maybe String)
loadDLL env =
GHCi.loadDLL (GHCi.hscInterp env)
loadDLL env str = do
res <- GHCi.loadDLL (GHCi.hscInterp env) str
#if MIN_VERSION_ghc(9,11,0)
pure $
case res of
Left err_msg -> Just err_msg
Right _ -> Nothing
#else
pure res
#endif

unload :: HscEnv -> [Linkable] -> IO ()
unload hsc_env linkables =
Expand Down
9 changes: 7 additions & 2 deletions ghcide/src/Development/IDE/GHC/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,19 @@ instance NFData ModSummary where
instance Ord FastString where
compare a b = if a == b then EQ else compare (fs_sbs a) (fs_sbs b)


#if MIN_VERSION_ghc(9,9,0)
instance NFData (EpAnn a) where
rnf = rwhnf
#else
instance NFData (SrcSpanAnn' a) where
rnf = rwhnf
deriving instance Functor SrcSpanAnn'
#endif

instance Bifunctor GenLocated where
bimap f g (L l x) = L (f l) (g x)

deriving instance Functor SrcSpanAnn'

instance NFData ParsedModule where
rnf = rwhnf

Expand Down
4 changes: 3 additions & 1 deletion ghcide/src/Development/IDE/LSP/Outline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ hsConDeclsBinders cons

get_flds_gadt :: HsConDeclGADTDetails GhcPs
-> [LFieldOcc GhcPs]
#if MIN_VERSION_ghc(9,3,0)
#if MIN_VERSION_ghc(9,9,0)
get_flds_gadt (RecConGADT _ flds) = get_flds (reLoc flds)
#elif MIN_VERSION_ghc(9,3,0)
get_flds_gadt (RecConGADT flds _) = get_flds (reLoc flds)
#else
get_flds_gadt (RecConGADT flds) = get_flds (reLoc flds)
Expand Down
6 changes: 5 additions & 1 deletion ghcide/test/exe/CodeLensTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ addSigLensesTests =
, ("symbolKindTest = Proxy @\"qwq\"", "symbolKindTest :: Proxy \"qwq\"")
, ("promotedKindTest = Proxy @Nothing", if ghcVersion >= GHC96 then "promotedKindTest :: Proxy Nothing" else "promotedKindTest :: Proxy 'Nothing")
, ("typeOperatorTest = Refl", "typeOperatorTest :: forall {k} {a :: k}. a :~: a")
, ("notInScopeTest = mkCharType", "notInScopeTest :: String -> Data.Data.DataType")
, ("notInScopeTest = mkCharType"
, if ghcVersion < GHC910
then "notInScopeTest :: String -> Data.Data.DataType"
else "notInScopeTest :: String -> GHC.Internal.Data.Data.DataType"
)
, ("aVeryLongSignature a b c d e f g h i j k l m n = a && b && c && d && e && f && g && h && i && j && k && l && m && n", "aVeryLongSignature :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool")
]
in testGroup
Expand Down
4 changes: 2 additions & 2 deletions ghcide/test/exe/FindDefinitionAndHoverTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ tests = let
xvL20 = Position 24 8 ; xvMsg = [ExpectHoverText ["pack", ":: String -> Text", "Data.Text", "text"]]
clL23 = Position 27 11 ; cls = [mkR 25 0 26 20, ExpectHoverText ["MyClass", "GotoHover.hs:26:1"]]
clL25 = Position 29 9
eclL15 = Position 19 8 ; ecls = [ExpectHoverText ["Num", "Defined in ", "GHC.Num", "base"]]
eclL15 = Position 19 8 ; ecls = [ExpectHoverText ["Num", "Defined in ", if ghcVersion < GHC910 then "GHC.Num" else "GHC.Internal.Num", "base"]]
dnbL29 = Position 33 18 ; dnb = [ExpectHoverText [":: ()"], mkR 33 12 33 21]
dnbL30 = Position 34 23
lcbL33 = Position 37 26 ; lcb = [ExpectHoverText [":: Char"], mkR 37 26 37 27]
Expand All @@ -159,7 +159,7 @@ tests = let
holeL65 = Position 65 8 ; hleInfo2 = [ExpectHoverText ["_ :: a -> Maybe a"]]
cccL17 = Position 17 16 ; docLink = [ExpectHoverTextRegex "\\*Defined in 'GHC.Types'\\* \\*\\(ghc-prim-[0-9.]+\\)\\*\n\n"]
imported = Position 56 13 ; importedSig = getDocUri "Foo.hs" >>= \foo -> return [ExpectHoverText ["foo", "Foo", "Haddock"], mkL foo 5 0 5 3]
reexported = Position 55 14 ; reexportedSig = getDocUri "Bar.hs" >>= \bar -> return [ExpectHoverText ["Bar", "Bar", "Haddock"], mkL bar 3 (if ghcVersion >= GHC94 then 5 else 0) 3 (if ghcVersion >= GHC94 then 8 else 14)]
reexported = Position 55 14 ; reexportedSig = getDocUri "Bar.hs" >>= \bar -> return [ExpectHoverText ["Bar", "Bar", "Haddock"], mkL bar 3 (if ghcVersion >= GHC94 && ghcVersion < GHC910 then 5 else 0) 3 (if ghcVersion >= GHC94 && ghcVersion < GHC910 then 8 else 14)]
thLocL57 = Position 59 10 ; thLoc = [ExpectHoverText ["Identity"]]
cmtL68 = Position 67 0 ; lackOfdEq = [ExpectHoverExcludeText ["$dEq"]]
import310 = Position 3 10; pkgTxt = [ExpectHoverText ["Data.Text\n\ntext-"]]
Expand Down
5 changes: 3 additions & 2 deletions ghcide/test/exe/OutlineTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Config
import Control.Monad.IO.Class (liftIO)
import Data.Text (Text)
import qualified Data.Text as T
import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion)
import Language.LSP.Protocol.Types hiding (SemanticTokenAbsolute (..),
SemanticTokenRelative (..),
SemanticTokensEdit (..), mkRange)
Expand Down Expand Up @@ -55,11 +56,11 @@ tests =
[ docSymbolD "A a" "type family" SymbolKind_Function (R 1 0 1 15),
docSymbol "A ()" SymbolKind_Interface (R 2 0 2 23)
],
testSymbolsA "data family" ["{-# language TypeFamilies #-}", "data family A"] [docSymbolD "A" "data family" SymbolKind_Function (R 1 0 1 11)],
testSymbolsA "data family" ["{-# language TypeFamilies #-}", "data family A"] [docSymbolD "A" "data family" SymbolKind_Function (R 1 0 1 (if ghcVersion >= GHC910 then 13 else 11))],
testSymbolsA
"data family instance "
["{-# language TypeFamilies #-}", "data family A a", "data instance A () = A ()"]
[ docSymbolD "A a" "data family" SymbolKind_Function (R 1 0 1 11),
[ docSymbolD "A a" "data family" SymbolKind_Function (R 1 0 1 (if ghcVersion >= GHC910 then 15 else 11)),
docSymbol "A ()" SymbolKind_Interface (R 2 0 2 25)
],
testSymbolsA "constant" ["a = ()"] [docSymbol "a" SymbolKind_Function (R 0 0 0 6)],
Expand Down
2 changes: 1 addition & 1 deletion ghcide/test/exe/PluginSimpleTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tests =

-- Error: cabal: Failed to build ghc-typelits-natnormalise-0.7.7 (which is
-- required by plugin-1.0.0). See the build log above for details.
ignoreFor (BrokenForGHC [GHC96, GHC98]) "fragile, frequently times out" $
ignoreFor (BrokenForGHC [GHC96, GHC98, GHC910]) "fragile, frequently times out" $
ignoreFor (BrokenSpecific Windows [GHC94]) "ghc-typelist-natnormalise fails to build on GHC 9.4.2 for windows only" $
testSessionWithExtraFiles "plugin-knownnat" "simple plugin" $ \dir -> do
_ <- openDoc (dir </> "KnownNat.hs") "haskell"
Expand Down
Loading