From e8575053e1bf58aece4a238b6ec36d44c6b07fa8 Mon Sep 17 00:00:00 2001 From: Ben Simms Date: Fri, 1 Jan 2021 02:38:33 +0000 Subject: [PATCH 1/5] Fix #723 --- ghcide/src/Development/IDE/Core/Compile.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index 86401c2c9f..6b42851e42 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -184,14 +184,21 @@ mkHiFileResultCompile mkHiFileResultCompile session' tcm simplified_guts ltype = catchErrs $ do let session = session' { hsc_dflags = ms_hspp_opts ms } ms = pm_mod_summary $ tmrParsed tcm + tcGblEnv = tmrTypechecked tcm -- give variables unique OccNames - (guts, details) <- tidyProgram session simplified_guts - 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 + details <- mkBootModDetailsTc session tcGblEnv + pure (Nothing, details, []) + else do + (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 From d71929b67fb1d5b8d2ce6a4022577f37493d308a Mon Sep 17 00:00:00 2001 From: Ben Simms Date: Sat, 2 Jan 2021 00:38:36 +0000 Subject: [PATCH 2/5] Update boot test to have instance declarations --- ghcide/test/data/boot/A.hs | 1 + ghcide/test/data/boot/A.hs-boot | 1 + 2 files changed, 2 insertions(+) diff --git a/ghcide/test/data/boot/A.hs b/ghcide/test/data/boot/A.hs index 7f0bcca74c..5391dee591 100644 --- a/ghcide/test/data/boot/A.hs +++ b/ghcide/test/data/boot/A.hs @@ -3,6 +3,7 @@ module A where import B( TB(..) ) newtype TA = MkTA Int + deriving Eq f :: TB -> TA f (MkTB x) = MkTA x diff --git a/ghcide/test/data/boot/A.hs-boot b/ghcide/test/data/boot/A.hs-boot index 04f7eece40..aa35288eda 100644 --- a/ghcide/test/data/boot/A.hs-boot +++ b/ghcide/test/data/boot/A.hs-boot @@ -1,2 +1,3 @@ module A where newtype TA = MkTA Int +instance Eq TA From fd12d8010fe7f31bad7c1ea7fc03d2dd60aed515 Mon Sep 17 00:00:00 2001 From: Ben Simms Date: Sat, 2 Jan 2021 16:44:43 +0000 Subject: [PATCH 3/5] Correct expected location of 'f' in boot-def-test --- ghcide/test/exe/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 1416363b1e..26f3418f37 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -3568,7 +3568,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 8 0 8 1 checkDefs locs (pure [floc]) -- | test that TH reevaluates across interfaces From 0fb4bb6628330a5d8e911d1f61077bdba0db1db1 Mon Sep 17 00:00:00 2001 From: Ben Simms Date: Sat, 2 Jan 2021 18:17:17 +0000 Subject: [PATCH 4/5] Missed TemplateHaskell pragma from boot test --- ghcide/test/data/boot/A.hs | 1 + ghcide/test/exe/Main.hs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ghcide/test/data/boot/A.hs b/ghcide/test/data/boot/A.hs index 5391dee591..9f2c0d73ac 100644 --- a/ghcide/test/data/boot/A.hs +++ b/ghcide/test/data/boot/A.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} module A where import B( TB(..) ) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 26f3418f37..e9056f6b59 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -3568,7 +3568,7 @@ bootTests = testCase "boot-def-test" $ runWithExtraFiles "boot" $ \dir -> do cdoc <- createDoc cPath "haskell" cSource locs <- getDefinitions cdoc (Position 7 4) - let floc = mkR 8 0 8 1 + let floc = mkR 9 0 9 1 checkDefs locs (pure [floc]) -- | test that TH reevaluates across interfaces From 42d57fe76b7723e36edfbb6e86ab316eca001cd2 Mon Sep 17 00:00:00 2001 From: Ben Simms Date: Sat, 2 Jan 2021 20:32:59 +0000 Subject: [PATCH 5/5] Fix comment placement --- ghcide/src/Development/IDE/Core/Compile.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index 6b42851e42..bc633bf940 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -185,7 +185,7 @@ mkHiFileResultCompile session' tcm simplified_guts ltype = catchErrs $ do let session = session' { hsc_dflags = ms_hspp_opts ms } ms = pm_mod_summary $ tmrParsed tcm tcGblEnv = tmrTypechecked tcm - -- give variables unique OccNames + let genLinkable = case ltype of ObjectLinkable -> generateObjectCode BCOLinkable -> generateByteCode @@ -193,9 +193,11 @@ mkHiFileResultCompile session' tcm simplified_guts ltype = catchErrs $ do (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)