@@ -160,8 +160,10 @@ updateLHsType = traverse
160160
161161-- Main process
162162updateHsType :: HsType GhcPs -> (Any, HsType GhcPs)
163−updateHsType (HsQualTy xty ctxt body) =
164− flagASTModified $ HsQualTy xty (fmap appendHSC ctxt) body
163+updateHsType ty@(HsQualTy xty ctxt body) =
164+ if hasHasCallStack (unLoc ctxt)
165+ then pure ty
166+ else flagASTModified $ HsQualTy xty (fmap appendHSC ctxt) body
165167updateHsType ty@HsTyVar {} =
166168 flagASTModified $ HsQualTy xQualTy (noLoc $ appendHSC []) (noLoc ty)
167169updateHsType ty@HsAppTy {} =
@@ -188,6 +190,13 @@ flagASTModified a = (Any True, a)
188190appendHSC :: HsContext GhcPs -> HsContext GhcPs
189191appendHSC cs = mkHSC : cs
190192
193+hasHasCallStack :: HsContext GhcPs -> Bool
194+hasHasCallStack = any (checkHsType . unLoc)
195+ where
196+ checkHsType :: HsType GhcPs -> Bool
197+ checkHsType (HsTyVar _ _ lid) = unLoc lid == (mkRdrUnqual $ mkClsOcc "HasCallStack")
198+ checkHsType _ = False
199+
191200-- make HasCallStack => constraint
192201mkHSC :: LHsType GhcPs
193202mkHSC = noLoc $ HsTyVar xQualTy NotPromoted lId