import RnExpr
import HsSyn
import HsPragmas
-import HsTypes ( getTyVarName )
+import HsTypes ( getTyVarName, pprHsContext )
import RdrName ( RdrName, isRdrDataCon, rdrNameOcc, isRdrTyVar, mkRdrNameWkr )
import RdrHsSyn ( RdrNameContext, RdrNameHsType, RdrNameConDecl,
extractRuleBndrsTyVars, extractHsTyRdrTyVars,
)
import NameSet
import OccName ( mkDefaultMethodOcc )
-import BasicTypes ( TopLevelFlag(..) )
import FiniteMap ( elemFM )
import PrelInfo ( derivableClassKeys, cCallishClassKeys,
deRefStablePtr_RDR, makeStablePtr_RDR,
import SrcLoc ( SrcLoc )
import CmdLineOpts ( opt_GlasgowExts, opt_WarnUnusedMatches ) -- Warn of unused for-all'd tyvars
import Unique ( Uniquable(..) )
-import UniqFM ( lookupUFM )
import ErrUtils ( Message )
import CStrings ( isCLabelString )
import Maybes ( maybeToBool, catMaybes )
rnHsType doc (HsForAllTy (Just forall_tyvars) ctxt tau)
-- Explicit quantification.
- -- Check that the forall'd tyvars are a subset of the
- -- free tyvars in the tau-type part
- -- That's only a warning... unless the tyvar is constrained by a
- -- context in which case it's an error
+ -- Check that the forall'd tyvars are actually
+ -- mentioned in the type, and produce a warning if not
= let
mentioned_in_tau = extractHsTyRdrTyVars tau
mentioned_in_ctxt = extractHsCtxtRdrTyVars ctxt
mentioned = nub (mentioned_in_tau ++ mentioned_in_ctxt)
- tys_of_pred (HsPClass clas tys) = tys
- tys_of_pred (HsPIParam n ty) = [ty]
forall_tyvar_names = map getTyVarName forall_tyvars
- -- explicitly quantified but not mentioned in ctxt or tau
+ -- Explicitly quantified but not mentioned in ctxt or tau
warn_guys = filter (`notElem` mentioned) forall_tyvar_names
-
in
mapRn_ (forAllWarn doc tau) warn_guys `thenRn_`
rnForAll doc forall_tyvars ctxt tau
= sep [hsep [ptext SLIT("Duplicate class assertion"),
quotes (ppr assertion),
ptext SLIT("in the context:")],
- nest 4 (ppr ctxt <+> ptext SLIT("..."))]
+ nest 4 (pprHsContext ctxt <+> ptext SLIT("..."))]
naughtyCCallContextErr (HsPClass clas _)
= sep [ptext SLIT("Can't use class") <+> quotes (ppr clas),