summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Class.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-09-08 07:20:02 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2020-09-08 07:22:00 -0400
commit5e883375409efc2336da6295c7d81bd10b542210 (patch)
treebb555de9629f59d0bb7ae22c6a0a9e170537dabb /compiler/GHC/Core/Class.hs
parentd4bc9f0de7992f60bce403731019829f6248cc2c (diff)
downloadhaskell-wip/T18648.tar.gz
Postpone associated tyfam default checks until after typecheckingwip/T18648
Previously, associated type family defaults were validity-checked during typechecking. Unfortunately, the error messages that these checks produce run the risk of printing knot-tied type constructors, which will cause GHC to diverge. In order to preserve the current error message's descriptiveness, this patch postpones these validity checks until after typechecking, which are now located in the new function `GHC.Tc.Validity.checkValidAssocTyFamDeflt`. Fixes #18648.
Diffstat (limited to 'compiler/GHC/Core/Class.hs')
-rw-r--r--compiler/GHC/Core/Class.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/GHC/Core/Class.hs b/compiler/GHC/Core/Class.hs
index f5d24aaf3c..57e6defca6 100644
--- a/compiler/GHC/Core/Class.hs
+++ b/compiler/GHC/Core/Class.hs
@@ -8,7 +8,7 @@
module GHC.Core.Class (
Class,
ClassOpItem,
- ClassATItem(..),
+ ClassATItem(..), ATValidityInfo(..),
ClassMinimalDef,
DefMethInfo, pprDefMethInfo,
@@ -97,10 +97,21 @@ type DefMethInfo = Maybe (Name, DefMethSpec Type)
data ClassATItem
= ATI TyCon -- See Note [Associated type tyvar names]
- (Maybe (Type, SrcSpan))
+ (Maybe (Type, ATValidityInfo))
-- Default associated type (if any) from this template
-- Note [Associated type defaults]
+-- | Information about an associated type family default implementation. This
+-- is used solely for validity checking.
+-- See @Note [Type-checking default assoc decls]@ in "GHC.Tc.TyCl".
+data ATValidityInfo
+ = NoATVI -- Used for associated type families that are imported
+ -- from another module, for which we don't need to
+ -- perform any validity checking.
+
+ | ATVI SrcSpan [Type] -- Used for locally defined associated type families.
+ -- The [Type] are the LHS patterns.
+
type ClassMinimalDef = BooleanFormula Name -- Required methods
data ClassBody