summaryrefslogtreecommitdiff
path: root/compiler/coreSyn/CoreFVs.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/coreSyn/CoreFVs.hs')
-rw-r--r--compiler/coreSyn/CoreFVs.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/coreSyn/CoreFVs.hs b/compiler/coreSyn/CoreFVs.hs
index 28a4a9e57a..ff2b82fd87 100644
--- a/compiler/coreSyn/CoreFVs.hs
+++ b/compiler/coreSyn/CoreFVs.hs
@@ -110,10 +110,7 @@ exprFreeVars = fvVarSet . exprFVs
-- Note that this *does* include type variables free in the types of free term
-- variables (see #15211).
mkExprInScopeSet :: CoreExpr -> InScopeSet
-mkExprInScopeSet e = mkInScopeSet $ fvVarSet $ closeOverTypes (exprFreeVarsList e)
-
-closeOverTypes :: [Var] -> FV
-closeOverTypes vars = mapUnionFV (tyCoFVsOfType . varType) vars `unionFV` FV.mkFVs vars
+mkExprInScopeSet e = mkInScopeSet $ exprFreeVars e
-- | Find all locally-defined free Ids or type variables in an expression
-- returning a composable FV computation. See Note [FV naming conventions] in FV
@@ -264,7 +261,11 @@ expr_fvs (Type ty) fv_cand in_scope acc =
tyCoFVsOfType ty fv_cand in_scope acc
expr_fvs (Coercion co) fv_cand in_scope acc =
tyCoFVsOfCo co fv_cand in_scope acc
-expr_fvs (Var var) fv_cand in_scope acc = FV.unitFV var fv_cand in_scope acc
+expr_fvs (Var v) fv_cand in_scope acc@(acc_list, acc_set)
+ | not (fv_cand v) = acc
+ | v `elemVarSet` in_scope = acc
+ | v `elemVarSet` acc_set = acc
+ | otherwise = tyCoFVsOfType (idType v) fv_cand emptyVarSet (v:acc_list, extendVarSet acc_set v)
expr_fvs (Lit _) fv_cand in_scope acc = emptyFV fv_cand in_scope acc
expr_fvs (Tick t expr) fv_cand in_scope acc =
(tickish_fvs t `unionFV` expr_fvs expr) fv_cand in_scope acc