diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index feaa183ab0..df9894ef5e 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -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 diff --git a/ghcide/test/data/boot/A.hs b/ghcide/test/data/boot/A.hs index 7f0bcca74c..9f2c0d73ac 100644 --- a/ghcide/test/data/boot/A.hs +++ b/ghcide/test/data/boot/A.hs @@ -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 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 diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index e3cfb1d17e..7173bbb69d 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -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