Skip to content

Restore concise type variables in ghc-9.2 #2828

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

Merged
merged 4 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 15 additions & 3 deletions ghcide/src/Development/IDE/GHC/Compat/Outputable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module Development.IDE.GHC.Compat.Outputable (
mkPrintUnqualified,
mkPrintUnqualifiedDefault,
PrintUnqualified(..),
defaultUserStyle,
withPprStyle,
-- * Parser errors
PsWarning,
PsError,
Expand Down Expand Up @@ -43,7 +45,8 @@ import GHC.Types.SourceError
import GHC.Types.SrcLoc
import GHC.Unit.State
import GHC.Utils.Error hiding (mkWarnMsg)
import GHC.Utils.Outputable
import GHC.Utils.Outputable as Out hiding (defaultUserStyle)
import qualified GHC.Utils.Outputable as Out
import GHC.Utils.Panic
#elif MIN_VERSION_ghc(9,0,0)
import GHC.Driver.Session
Expand All @@ -52,14 +55,16 @@ import GHC.Types.Name.Reader (GlobalRdrEnv)
import GHC.Types.SrcLoc
import GHC.Utils.Error as Err hiding (mkWarnMsg)
import qualified GHC.Utils.Error as Err
import GHC.Utils.Outputable as Out
import GHC.Utils.Outputable as Out hiding (defaultUserStyle)
import qualified GHC.Utils.Outputable as Out
#else
import Development.IDE.GHC.Compat.Core (GlobalRdrEnv)
import DynFlags
import ErrUtils hiding (mkWarnMsg)
import qualified ErrUtils as Err
import HscTypes
import Outputable as Out
import Outputable as Out hiding (defaultUserStyle)
import qualified Outputable as Out
import SrcLoc
#endif

Expand Down Expand Up @@ -178,3 +183,10 @@ mkWarnMsg =
#else
Err.mkWarnMsg
#endif

defaultUserStyle :: PprStyle
#if MIN_VERSION_ghc(9,0,0)
defaultUserStyle = Out.defaultUserStyle
#else
defaultUserStyle = Out.defaultUserStyle unsafeGlobalDynFlags
#endif
4 changes: 2 additions & 2 deletions ghcide/src/Development/IDE/Spans/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type DocMap = NameEnv SpanDoc
type KindMap = NameEnv TyThing

showGhc :: Outputable a => a -> T.Text
showGhc = showSD . ppr
showGhc = showSD . withPprStyle defaultUserStyle . ppr

showSD :: SDoc -> T.Text
showSD = T.pack . unsafePrintSDoc
Expand All @@ -62,7 +62,7 @@ safeTyThingId _ = Nothing
-- Possible documentation for an element in the code
data SpanDoc
= SpanDocString HsDocString SpanDocUris
| SpanDocText [T.Text] SpanDocUris
| SpanDocText [T.Text] SpanDocUris
deriving stock (Eq, Show, Generic)
deriving anyclass NFData

Expand Down
6 changes: 1 addition & 5 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4288,11 +4288,7 @@ findDefinitionAndHoverTests = let
, test no yes outL45 outSig "top-level signature #767"
, test broken broken innL48 innSig "inner signature #767"
, test no yes holeL60 hleInfo "hole without internal name #831"
, if ghcVersion >= GHC92 then
-- Broken on GHC 9.2 and above due to printing of uniques
test no yes holeL65 [] "hole with variable"
else
test no yes holeL65 hleInfo2 "hole with variable"
, test no yes holeL65 hleInfo2 "hole with variable"
, test no skip cccL17 docLink "Haddock html links"
, testM yes yes imported importedSig "Imported symbol"
, testM yes yes reexported reexportedSig "Imported symbol (reexported)"
Expand Down