Skip to content

Fix #723 (Instance declarations in hs-boot files result in GHC errors) #781

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 10 commits into from
Jan 5, 2021
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
15 changes: 12 additions & 3 deletions ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,23 @@ mkHiFileResultCompile
mkHiFileResultCompile session' tcm simplified_guts ltype = catchErrs $ do
let session = session' { hsc_dflags = ms_hspp_opts ms }
ms = pm_mod_summary $ tmrParsed tcm
-- give variables unique OccNames
(guts, details) <- tidyProgram session simplified_guts
tcGblEnv = tmrTypechecked tcm

let genLinkable = case ltype of
ObjectLinkable -> generateObjectCode
BCOLinkable -> generateByteCode

(diags, linkable) <- genLinkable session ms guts
(linkable, details, diags) <-
if mg_hsc_src simplified_guts == HsBootFile
then do
-- give variables unique OccNames
details <- mkBootModDetailsTc session tcGblEnv
pure (Nothing, details, [])
else do
-- give variables unique OccNames
(guts, details) <- tidyProgram session simplified_guts
(diags, linkable) <- genLinkable session ms guts
pure (linkable, details, diags)
#if MIN_GHC_API_VERSION(8,10,0)
let !partial_iface = force (mkPartialIface session details simplified_guts)
final_iface <- mkFullIface session partial_iface
Expand Down
2 changes: 2 additions & 0 deletions ghcide/test/data/boot/A.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{-# LANGUAGE TemplateHaskell #-}
module A where

import B( TB(..) )

newtype TA = MkTA Int
deriving Eq

f :: TB -> TA
f (MkTB x) = MkTA x
1 change: 1 addition & 0 deletions ghcide/test/data/boot/A.hs-boot
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module A where
newtype TA = MkTA Int
instance Eq TA
2 changes: 1 addition & 1 deletion ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3673,7 +3673,7 @@ bootTests = testCase "boot-def-test" $ runWithExtraFiles "boot" $ \dir -> do

cdoc <- createDoc cPath "haskell" cSource
locs <- getDefinitions cdoc (Position 7 4)
let floc = mkR 7 0 7 1
let floc = mkR 9 0 9 1
checkDefs locs (pure [floc])

-- | test that TH reevaluates across interfaces
Expand Down