merge upstream
[ghc-hetmet.git] / compiler / rename / RnEnv.lhs
index 4492b52..1301e61 100644 (file)
@@ -36,6 +36,7 @@ module RnEnv (
 
 import LoadIface       ( loadInterfaceForName, loadSrcInterface )
 import IfaceEnv                ( lookupOrig, newGlobalBinder, newIPName )
+import TcEnv           ( getHetMetLevel )
 import HsSyn
 import RdrHsSyn                ( extractHsTyRdrTyVars )
 import RdrName
@@ -785,14 +786,14 @@ lookupIfThenElse
 lookupSyntaxName :: Name                               -- The standard name
                 -> RnM (SyntaxExpr Name, FreeVars)     -- Possibly a non-standard name
 lookupSyntaxName std_name
-  = xoptM Opt_RebindableSyntax         `thenM` \ rebindable_on -> 
-    if not rebindable_on then normal_case 
-    else
-       -- Get the similarly named thing from the local environment
-    lookupOccRn (mkRdrUnqual (nameOccName std_name)) `thenM` \ usr_name ->
-    return (HsVar usr_name, unitFV usr_name)
-  where
-    normal_case = return (HsVar std_name, emptyFVs)
+  = do ec <- getHetMetLevel
+       std_name' <- return $ setNameDepth (length ec) std_name
+       rebindable_on <- xoptM Opt_RebindableSyntax
+       if not rebindable_on
+         then return (HsVar std_name', emptyFVs)
+         else do usr_name <- lookupOccRn (mkRdrUnqual (nameOccName std_name'))
+                 return (HsVar usr_name, unitFV usr_name)
+               -- Get the similarly named thing from the local environment
 
 lookupSyntaxTable :: [Name]                            -- Standard names
                  -> RnM (SyntaxTable Name, FreeVars)   -- See comments with HsExpr.ReboundNames