{-
(c) The University of Glasgow 2006
(c) The AQUA Project, Glasgow University, 1993-1998

-}
{-# LANGUAGE TypeFamilies #-}

-- | Typechecking @default@ declarations
module GHC.Tc.Gen.Default ( tcDefaults ) where

import GHC.Prelude

import GHC.Hs
import GHC.Core.Class
import GHC.Core.TyCon (TyCon)
import GHC.Core.Type( typeKind )

import GHC.Types.Var( tyVarKind )
import GHC.Tc.Errors.Types
import GHC.Tc.Utils.Monad
import GHC.Tc.Utils.Env
import GHC.Tc.Gen.HsType
import GHC.Tc.Zonk.Type
import GHC.Tc.Solver
import GHC.Tc.Validity
import GHC.Tc.Utils.TcType
import GHC.Builtin.Names
import GHC.Types.DefaultEnv ( DefaultEnv, ClassDefaults (..), defaultEnv )
import GHC.Types.Error
import GHC.Types.SrcLoc
import GHC.Unit.Types (Module, bignumUnit, ghcInternalUnit, moduleUnit, primUnit)
import GHC.Utils.Misc (fstOf3, sndOf3)
import GHC.Utils.Outputable
import qualified GHC.LanguageExtensions as LangExt

import Control.Monad (void)
import Data.Function (on)
import Data.List.NonEmpty ( NonEmpty (..), groupBy )


{- Note [Named default declarations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With the `NamedDefaults` language extension, a `default` declaration can specify type-class
defaulting behaviour for specific classes. For example

      class C a where
        ...
      default C( Int, Bool )  -- The default types for class C

The `default` declaration tells GHC to default unresolved constraints (C a) to (C Int) or
(C Bool), in that order. Of course, if you don't specify a class, thus

    default (Int, Bool)

the default declaration behaves as before, affecting primarily the `Num` class.

Moreover, a module export list can specify a list of classes whose defaults should be
exported.  For example

    module M( C, default C )

would export the above `default` declaration for `C`.

See details at
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0409-exportable-named-default.rst

The moving parts are as follows:

* Language.Haskell.Syntax.Decls.DefaultDecl: A `DefaultDecl` optionally carries
  the specified class.

* Parsing and renaming are entirely straightforward.

* The typechecker maintains a `DefaultEnv` (see GHC.Types.DefaultEnv)
  which maps a class to a `ClassDefaults`.  The `ClassDefaults` for a class
  specifies the defaults for that class, in the current module.

* The `DefaultEnv` of all defaults in scope in a module is kept in the `tcg_default`
  field of `TcGblEnv`.

* This field is populated by `GHC.Tc.Gen.Default.tcDefaults` which typechecks
  any local or imported `default` declarations.

* Only a single default declaration can be in effect in any single module for
  any particular class. We issue an error if a single module contains two
  default declarations for the same class, a possible warning if it imports
  them.

  See Note [Disambiguation of multiple default declarations] in GHC.Tc.Module

* There is a _default_ `DefaultEnv` even in absence of any user-declared
  `default` declarations. It is determined by the presence of the
  `ExtendedDefaultRules` and `OverloadedStrings` extensions. If neither of these
  extensions nor user-declared declarations are present, the `DefaultEnv` will
  in effect be `default Num (Integer, Double)` as specified by Haskell Language
  Report.

  See Note [Default class defaults] in GHC.Tc.Utils.Env

* Beside the defaults, the `ExtendedDefaultRules` and `OverloadedStrings`
  extensions also affect the traditional `default` declarations that don't name
  the class. They have no effect on declarations with explicit class name.
  For details of their operation see the corresponding sections of GHC User's Guide:
  - https://downloads.haskell.org/ghc/latest/docs/users_guide/ghci.html#extension-ExtendedDefaultRules
  - https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/overloaded_strings.html#extension-OverloadedStrings

* The module's `tcg_default` is consulted when defaulting unsolved constraints,
  in GHC.Tc.Solver.applyDefaultingRules.
  See Note [How type-class constraints are defaulted] in GHC.Tc.Solver

* Class defaults are imported automatically, like class instances. They are
  tracked separately from `ImportAvails`, and returned separately from them by
  `GHC.Rename.Names.rnImports`.

* Class defaults are exported explicitly, as the example above shows. A module's
  exported defaults are tracked in `tcg_default_exports`, which are then
  transferred to `mg_defaults`, `md_defaults`, and `mi_defaults_`.
  See Note [Default exports] in GHC.Tc.Gen.Export

* Since the class defaults merely help the solver infer the correct types, they
  leave no trace in Haskell Core.
-}

-- See Note [Named default declarations]
tcDefaults :: [LDefaultDecl GhcRn]
           -> TcM DefaultEnv  -- Defaulting types to heave
                              -- into Tc monad for later use
                              -- in Disambig.

tcDefaults :: [LDefaultDecl GhcRn] -> TcM DefaultEnv
tcDefaults []
  = TcM DefaultEnv
getDeclaredDefaultTys       -- No default declaration, so get the
                                -- default types from the envt;
                                -- i.e. use the current ones
                                -- (the caller will put them back there)
        -- It's important not to return defaultDefaultTys here (which
        -- we used to do) because in a TH program, tcDefaults [] is called
        -- repeatedly, once for each group of declarations between top-level
        -- splices.  We don't want to carefully set the default types in
        -- one group, only for the next group to ignore them and install
        -- defaultDefaultTys

tcDefaults [LDefaultDecl GhcRn]
decls
  = do  { ovl_str   <- Extension -> TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -> TcRnIf gbl lcl Bool
xoptM Extension
LangExt.OverloadedStrings
        ; ext_deflt <- xoptM LangExt.ExtendedDefaultRules
        ; deflt_str <- if ovl_str
                       then mapM tcLookupClass [isStringClassName]
                       else return []
        ; deflt_interactive <- if ext_deflt
                               then mapM tcLookupClass interactiveClassNames
                               else return []
        ; tcg_env <- getGblEnv
        ; let extra_clss = [Class]
deflt_str [Class] -> [Class] -> [Class]
forall a. [a] -> [a] -> [a]
++ [Class]
deflt_interactive
              here = TcGblEnv -> Module
tcg_mod TcGblEnv
tcg_env
              is_internal_unit = Module -> Unit
forall unit. GenModule unit -> unit
moduleUnit Module
here Unit -> [Unit] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Unit
bignumUnit, Unit
ghcInternalUnit, Unit
primUnit]
        ; decls' <- case (is_internal_unit, decls) of
            -- Some internal GHC modules contain @default ()@ to declare that no defaults can take place
            -- in the module.
            -- We shortcut the treatment of such a default declaration with no class nor types: we won't
            -- try to point 'cd_class' to 'Num' since it may not even exist yet.
            (Bool
True, [L SrcSpanAnnA
_ (DefaultDecl XCDefaultDecl GhcRn
_ Maybe (LIdP GhcRn)
Nothing [])]) -> [(GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])]
-> IOEnv
     (Env TcGblEnv TcLclEnv)
     [(GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])]
forall a. a -> IOEnv (Env TcGblEnv TcLclEnv) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
            -- Otherwise we take apart the declaration into the class constructor and its default types.
            (Bool, [GenLocated SrcSpanAnnA (DefaultDecl GhcRn)])
_ ->  (GenLocated SrcSpanAnnA (DefaultDecl GhcRn)
 -> IOEnv
      (Env TcGblEnv TcLclEnv)
      (GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type]))
-> [GenLocated SrcSpanAnnA (DefaultDecl GhcRn)]
-> IOEnv
     (Env TcGblEnv TcLclEnv)
     [(GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ([Class]
-> LDefaultDecl GhcRn -> TcM (LDefaultDecl GhcRn, TyCon, [Type])
declarationParts [Class]
extra_clss) [LDefaultDecl GhcRn]
[GenLocated SrcSpanAnnA (DefaultDecl GhcRn)]
decls
        ; defaultEnv . concat <$> mapM (reportDuplicates here extra_clss) (groupBy ((==) `on` sndOf3) decls') }
  where
    declarationParts :: [Class] -> LDefaultDecl GhcRn -> TcM (LDefaultDecl GhcRn, TyCon, [Type])
    reportDuplicates :: Module -> [Class] -> NonEmpty (LDefaultDecl GhcRn, TyCon, [Type]) -> TcM [ClassDefaults]
    declarationParts :: [Class]
-> LDefaultDecl GhcRn -> TcM (LDefaultDecl GhcRn, TyCon, [Type])
declarationParts [Class]
extra_clss decl :: LDefaultDecl GhcRn
decl@(L SrcSpanAnnA
locn (DefaultDecl XCDefaultDecl GhcRn
_ Maybe (LIdP GhcRn)
cls_tyMaybe [LHsType GhcRn]
mono_tys))
      = SDoc
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
forall a. SDoc -> TcM a -> TcM a
addErrCtxt SDoc
defaultDeclCtxt (TcM (LDefaultDecl GhcRn, TyCon, [Type])
 -> TcM (LDefaultDecl GhcRn, TyCon, [Type]))
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
forall a b. (a -> b) -> a -> b
$
        SrcSpan
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
forall a. SrcSpan -> TcRn a -> TcRn a
setSrcSpan (SrcSpanAnnA -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
locA SrcSpanAnnA
locn)     (TcM (LDefaultDecl GhcRn, TyCon, [Type])
 -> TcM (LDefaultDecl GhcRn, TyCon, [Type]))
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
-> TcM (LDefaultDecl GhcRn, TyCon, [Type])
forall a b. (a -> b) -> a -> b
$
        do { tau_tys <- (GenLocated SrcSpanAnnA (HsType GhcRn) -> TcRn Type)
-> [GenLocated SrcSpanAnnA (HsType GhcRn)] -> TcRn [Type]
forall a b. (a -> TcRn b) -> [a] -> TcRn [b]
mapAndReportM LHsType GhcRn -> TcRn Type
GenLocated SrcSpanAnnA (HsType GhcRn) -> TcRn Type
tc_default_ty [LHsType GhcRn]
[GenLocated SrcSpanAnnA (HsType GhcRn)]
mono_tys
           ; def_clsCon <- case cls_tyMaybe of
               Maybe (LIdP GhcRn)
Nothing ->
                 do { numTyCon <- Name -> IOEnv (Env TcGblEnv TcLclEnv) TyCon
tcLookupTyCon Name
numClassName
                    ; let classTyConAndArgKinds Class
cls = (Class -> TyCon
classTyCon Class
cls, [], TyVar -> Type
tyVarKind (TyVar -> Type) -> [TyVar] -> [Type]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Class -> [TyVar]
classTyVars Class
cls)
                          tyConsAndArgKinds = (TyCon
numTyCon, [], [Type
liftedTypeKind]) (TyCon, [Type], [Type])
-> [(TyCon, [Type], [Type])] -> [(TyCon, [Type], [Type])]
forall a. a -> [a] -> [a]
: (Class -> (TyCon, [Type], [Type]))
-> [Class] -> [(TyCon, [Type], [Type])]
forall a b. (a -> b) -> [a] -> [b]
map Class -> (TyCon, [Type], [Type])
forall {a}. Class -> (TyCon, [a], [Type])
classTyConAndArgKinds [Class]
extra_clss
                    ; void $ mapAndReportM (check_instance_any tyConsAndArgKinds) tau_tys
                    ; return numTyCon }
               Just LIdP GhcRn
cls_name ->
                 do { named_deflt <- Extension -> TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -> TcRnIf gbl lcl Bool
xoptM Extension
LangExt.NamedDefaults
                    ; checkErr named_deflt (TcRnIllegalNamedDefault decl)
                    ; let cls_ty = HsSigType GhcRn -> GenLocated SrcSpanAnnA (HsSigType GhcRn)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsSig { sig_ext :: XHsSig GhcRn
sig_ext   = XHsSig GhcRn
NoExtField
noExtField
                                                 , sig_bndrs :: HsOuterSigTyVarBndrs GhcRn
sig_bndrs = HsOuterImplicit{hso_ximplicit :: XHsOuterImplicit GhcRn
hso_ximplicit = []}
                                                 , sig_body :: LHsType GhcRn
sig_body  = HsType GhcRn -> GenLocated SrcSpanAnnA (HsType GhcRn)
forall e a. HasAnnotation e => a -> GenLocated e a
noLocA (HsType GhcRn -> GenLocated SrcSpanAnnA (HsType GhcRn))
-> HsType GhcRn -> GenLocated SrcSpanAnnA (HsType GhcRn)
forall a b. (a -> b) -> a -> b
$ XTyVar GhcRn -> PromotionFlag -> LIdP GhcRn -> HsType GhcRn
forall pass.
XTyVar pass -> PromotionFlag -> LIdP pass -> HsType pass
HsTyVar XTyVar GhcRn
forall a. NoAnn a => a
noAnn PromotionFlag
NotPromoted LIdP GhcRn
cls_name})
                    ; (_cls_tvs, cls, cls_tys, cls_arg_kinds) <- tcHsDefault cls_ty
                    ; let clsTyCon = Class -> TyCon
classTyCon Class
cls
                    ; case cls_arg_kinds
                      of [Type
k] -> IOEnv (Env TcGblEnv TcLclEnv) [()]
-> IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IOEnv (Env TcGblEnv TcLclEnv) [()]
 -> IOEnv (Env TcGblEnv TcLclEnv) ())
-> IOEnv (Env TcGblEnv TcLclEnv) [()]
-> IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -> b) -> a -> b
$ (Type -> IOEnv (Env TcGblEnv TcLclEnv) ())
-> [Type] -> IOEnv (Env TcGblEnv TcLclEnv) [()]
forall a b. (a -> TcRn b) -> [a] -> TcRn [b]
mapAndReportM ([(TyCon, [Type], [Type])]
-> Type -> IOEnv (Env TcGblEnv TcLclEnv) ()
check_instance_any [(TyCon
clsTyCon, [Type]
cls_tys, [Type
k])]) [Type]
tau_tys
                         [Type]
_ -> TcRnMessage -> IOEnv (Env TcGblEnv TcLclEnv) ()
addErrTc (UserTypeCtxt -> LHsSigType GhcRn -> TcRnMessage
TcRnNonUnaryTypeclassConstraint UserTypeCtxt
DefaultDeclCtxt LHsSigType GhcRn
GenLocated SrcSpanAnnA (HsSigType GhcRn)
cls_ty)
                    ; return clsTyCon }
           ; return (decl, def_clsCon, tau_tys) }
    reportDuplicates :: Module
-> [Class]
-> NonEmpty (LDefaultDecl GhcRn, TyCon, [Type])
-> IOEnv (Env TcGblEnv TcLclEnv) [ClassDefaults]
reportDuplicates Module
here [Class]
extra_clss ((LDefaultDecl GhcRn
_, TyCon
clsCon, [Type]
tys) :| [])
      = [ClassDefaults] -> IOEnv (Env TcGblEnv TcLclEnv) [ClassDefaults]
forall a. a -> IOEnv (Env TcGblEnv TcLclEnv) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [ ClassDefaults{cd_class :: TyCon
cd_class = TyCon
c, cd_types :: [Type]
cd_types = [Type]
tys, cd_module :: Maybe Module
cd_module = Module -> Maybe Module
forall a. a -> Maybe a
Just Module
here, cd_warn :: Maybe (WarningTxt GhcRn)
cd_warn = Maybe (WarningTxt GhcRn)
forall a. Maybe a
Nothing}
             | TyCon
c <- TyCon
clsCon TyCon -> [TyCon] -> [TyCon]
forall a. a -> [a] -> [a]
: (Class -> TyCon) -> [Class] -> [TyCon]
forall a b. (a -> b) -> [a] -> [b]
map Class -> TyCon
classTyCon [Class]
extra_clss ]
    -- Report an error on multiple default declarations for the same class in the same module.
    -- See Note [Disambiguation of multiple default declarations] in GHC.Tc.Module
    reportDuplicates Module
_ [Class]
_ decls :: NonEmpty (LDefaultDecl GhcRn, TyCon, [Type])
decls@((L SrcSpanAnnA
locn DefaultDecl GhcRn
_, TyCon
cls, [Type]
_) :| [(LDefaultDecl GhcRn, TyCon, [Type])]
_)
      = SrcSpan
-> IOEnv (Env TcGblEnv TcLclEnv) ()
-> IOEnv (Env TcGblEnv TcLclEnv) ()
forall a. SrcSpan -> TcRn a -> TcRn a
setSrcSpan (SrcSpanAnnA -> SrcSpan
forall a. HasLoc a => a -> SrcSpan
locA SrcSpanAnnA
locn) (TcRnMessage -> IOEnv (Env TcGblEnv TcLclEnv) ()
addErrTc (TcRnMessage -> IOEnv (Env TcGblEnv TcLclEnv) ())
-> TcRnMessage -> IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -> b) -> a -> b
$ TyCon -> NonEmpty (LDefaultDecl GhcRn) -> TcRnMessage
dupDefaultDeclErr TyCon
cls ((GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])
-> GenLocated SrcSpanAnnA (DefaultDecl GhcRn)
forall a b c. (a, b, c) -> a
fstOf3 ((GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])
 -> GenLocated SrcSpanAnnA (DefaultDecl GhcRn))
-> NonEmpty
     (GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])
-> NonEmpty (GenLocated SrcSpanAnnA (DefaultDecl GhcRn))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (LDefaultDecl GhcRn, TyCon, [Type])
NonEmpty
  (GenLocated SrcSpanAnnA (DefaultDecl GhcRn), TyCon, [Type])
decls))
        IOEnv (Env TcGblEnv TcLclEnv) ()
-> IOEnv (Env TcGblEnv TcLclEnv) [ClassDefaults]
-> IOEnv (Env TcGblEnv TcLclEnv) [ClassDefaults]
forall a b.
IOEnv (Env TcGblEnv TcLclEnv) a
-> IOEnv (Env TcGblEnv TcLclEnv) b
-> IOEnv (Env TcGblEnv TcLclEnv) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [ClassDefaults] -> IOEnv (Env TcGblEnv TcLclEnv) [ClassDefaults]
forall a. a -> IOEnv (Env TcGblEnv TcLclEnv) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []

tc_default_ty :: LHsType GhcRn -> TcM Type
tc_default_ty :: LHsType GhcRn -> TcRn Type
tc_default_ty LHsType GhcRn
hs_ty
 = do   { ty <- String -> TcRn Type -> TcRn Type
forall a. String -> TcM a -> TcM a
solveEqualities String
"tc_default_ty" (TcRn Type -> TcRn Type) -> TcRn Type -> TcRn Type
forall a b. (a -> b) -> a -> b
$
                LHsType GhcRn -> TcRn Type
tcInferLHsType LHsType GhcRn
hs_ty
        ; ty <- zonkTcTypeToType ty   -- establish Type invariants
        ; checkValidType DefaultDeclCtxt ty
        ; return ty }

-- Check that the type is an instance of at least one of the default classes.
-- Beside the class type constructor, we take the already-supplied type
-- parameters and the expected kinds of the remaining parameters. We report
-- an error unless there's only one remaining parameter to fill and the given
-- type has the expected kind.
check_instance_any :: [(TyCon, [Type], [Kind])] -> Type -> TcM ()
check_instance_any :: [(TyCon, [Type], [Type])]
-> Type -> IOEnv (Env TcGblEnv TcLclEnv) ()
check_instance_any [(TyCon, [Type], [Type])]
deflt_clss Type
ty
 = do   { oks <- ((TyCon, [Type], [Type]) -> TcRnIf TcGblEnv TcLclEnv Bool)
-> [(TyCon, [Type], [Type])]
-> IOEnv (Env TcGblEnv TcLclEnv) [Bool]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (Type -> (TyCon, [Type], [Type]) -> TcRnIf TcGblEnv TcLclEnv Bool
check_instance Type
ty) [(TyCon, [Type], [Type])]
deflt_clss
        ; checkTc (or oks) (TcRnBadDefaultType ty (map fstOf3 deflt_clss))
        }

check_instance :: Type -> (TyCon, [Type], [Kind]) -> TcM Bool
-- Check that ty is an instance of cls
-- We only care about whether it worked or not; return a boolean
-- This checks that  cls :: k -> Constraint
-- with just one argument and no polymorphism; if we need to add
-- polymorphism we can make it more complicated.  For now we are
-- concerned with classes like
--    Num      :: Type -> Constraint
--    Foldable :: (Type->Type) -> Constraint
check_instance :: Type -> (TyCon, [Type], [Type]) -> TcRnIf TcGblEnv TcLclEnv Bool
check_instance Type
ty (TyCon
clsTyCon, [Type]
clsArgs, [Type
cls_argKind])
  | Type
cls_argKind HasDebugCallStack => Type -> Type -> Bool
Type -> Type -> Bool
`tcEqType` HasDebugCallStack => Type -> Type
Type -> Type
typeKind Type
ty
  = [Type] -> TcRnIf TcGblEnv TcLclEnv Bool
simplifyDefault [TyCon -> [Type] -> Type
mkTyConApp TyCon
clsTyCon ([Type]
clsArgs [Type] -> [Type] -> [Type]
forall a. [a] -> [a] -> [a]
++ [Type
ty])]
check_instance Type
_ (TyCon, [Type], [Type])
_
  = Bool -> TcRnIf TcGblEnv TcLclEnv Bool
forall a. a -> IOEnv (Env TcGblEnv TcLclEnv) a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False

defaultDeclCtxt :: SDoc
defaultDeclCtxt :: SDoc
defaultDeclCtxt = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"When checking the types in a default declaration"

dupDefaultDeclErr :: TyCon -> NonEmpty (LDefaultDecl GhcRn) -> TcRnMessage
dupDefaultDeclErr :: TyCon -> NonEmpty (LDefaultDecl GhcRn) -> TcRnMessage
dupDefaultDeclErr TyCon
cls (L SrcSpanAnnA
_ DefaultDecl {} :| [LDefaultDecl GhcRn]
dup_things)
  = TyCon -> [LDefaultDecl GhcRn] -> TcRnMessage
TcRnMultipleDefaultDeclarations TyCon
cls [LDefaultDecl GhcRn]
dup_things