[project @ 2002-04-23 08:52:16 by simonpj]
authorsimonpj <unknown>
Tue, 23 Apr 2002 08:52:16 +0000 (08:52 +0000)
committersimonpj <unknown>
Tue, 23 Apr 2002 08:52:16 +0000 (08:52 +0000)
Without -fglasow-exts, quantify over all mentioned type vars in type sigs

ghc/compiler/rename/RnTypes.lhs

index 4ef0582..afe921d 100644 (file)
@@ -19,6 +19,7 @@ import RdrName        ( elemRdrEnv )
 import NameSet ( FreeVars )
 import Unique  ( Uniquable(..) )
 
+import CmdLineOpts     ( DynFlag(Opt_GlasgowExts) )
 import List            ( nub )
 import ListSetOps      ( removeDupsEq )
 import Outputable
@@ -64,11 +65,17 @@ rnHsType doc (HsForAllTy Nothing ctxt ty)
        -- Given the signature  C => T  we universally quantify 
        -- over FV(T) \ {in-scope-tyvars} 
   = getLocalNameEnv            `thenRn` \ name_env ->
+    doptRn Opt_GlasgowExts     `thenRn` \ opt_GlasgowExts ->
     let
        mentioned_in_tau  = extractHsTyRdrTyVars ty
        mentioned_in_ctxt = extractHsCtxtRdrTyVars ctxt
        mentioned         = nub (mentioned_in_tau ++ mentioned_in_ctxt)
-       forall_tyvars     = filter (not . (`elemRdrEnv` name_env)) mentioned
+
+       -- Don't quantify over type variables that are in scope,
+       -- when GlasgowExts is on
+       forall_tyvars
+          | opt_GlasgowExts = filter (not . (`elemRdrEnv` name_env)) mentioned
+          | otherwise       = mentioned
     in
     rnForAll doc (map UserTyVar forall_tyvars) ctxt ty