Skip to content

Commit 2da5931

Browse files
authored
Restore concise type variables in ghc-9.2 (#2828)
* Unify ppr style * Fix test * Compatible changes
1 parent 6d8c1ba commit 2da5931

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

ghcide/src/Development/IDE/GHC/Compat/Outputable.hs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module Development.IDE.GHC.Compat.Outputable (
1313
mkPrintUnqualified,
1414
mkPrintUnqualifiedDefault,
1515
PrintUnqualified(..),
16+
defaultUserStyle,
17+
withPprStyle,
1618
-- * Parser errors
1719
PsWarning,
1820
PsError,
@@ -43,7 +45,8 @@ import GHC.Types.SourceError
4345
import GHC.Types.SrcLoc
4446
import GHC.Unit.State
4547
import GHC.Utils.Error hiding (mkWarnMsg)
46-
import GHC.Utils.Outputable
48+
import GHC.Utils.Outputable as Out hiding (defaultUserStyle)
49+
import qualified GHC.Utils.Outputable as Out
4750
import GHC.Utils.Panic
4851
#elif MIN_VERSION_ghc(9,0,0)
4952
import GHC.Driver.Session
@@ -52,14 +55,16 @@ import GHC.Types.Name.Reader (GlobalRdrEnv)
5255
import GHC.Types.SrcLoc
5356
import GHC.Utils.Error as Err hiding (mkWarnMsg)
5457
import qualified GHC.Utils.Error as Err
55-
import GHC.Utils.Outputable as Out
58+
import GHC.Utils.Outputable as Out hiding (defaultUserStyle)
59+
import qualified GHC.Utils.Outputable as Out
5660
#else
5761
import Development.IDE.GHC.Compat.Core (GlobalRdrEnv)
5862
import DynFlags
5963
import ErrUtils hiding (mkWarnMsg)
6064
import qualified ErrUtils as Err
6165
import HscTypes
62-
import Outputable as Out
66+
import Outputable as Out hiding (defaultUserStyle)
67+
import qualified Outputable as Out
6368
import SrcLoc
6469
#endif
6570

@@ -178,3 +183,10 @@ mkWarnMsg =
178183
#else
179184
Err.mkWarnMsg
180185
#endif
186+
187+
defaultUserStyle :: PprStyle
188+
#if MIN_VERSION_ghc(9,0,0)
189+
defaultUserStyle = Out.defaultUserStyle
190+
#else
191+
defaultUserStyle = Out.defaultUserStyle unsafeGlobalDynFlags
192+
#endif

ghcide/src/Development/IDE/Spans/Common.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type DocMap = NameEnv SpanDoc
3535
type KindMap = NameEnv TyThing
3636

3737
showGhc :: Outputable a => a -> T.Text
38-
showGhc = showSD . ppr
38+
showGhc = showSD . withPprStyle defaultUserStyle . ppr
3939

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

ghcide/test/exe/Main.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4288,11 +4288,7 @@ findDefinitionAndHoverTests = let
42884288
, test no yes outL45 outSig "top-level signature #767"
42894289
, test broken broken innL48 innSig "inner signature #767"
42904290
, test no yes holeL60 hleInfo "hole without internal name #831"
4291-
, if ghcVersion >= GHC92 then
4292-
-- Broken on GHC 9.2 and above due to printing of uniques
4293-
test no yes holeL65 [] "hole with variable"
4294-
else
4295-
test no yes holeL65 hleInfo2 "hole with variable"
4291+
, test no yes holeL65 hleInfo2 "hole with variable"
42964292
, test no skip cccL17 docLink "Haddock html links"
42974293
, testM yes yes imported importedSig "Imported symbol"
42984294
, testM yes yes reexported reexportedSig "Imported symbol (reexported)"

0 commit comments

Comments
 (0)