-rnIdInfo (HsUnfold inline expr) = rnCoreExpr expr `thenRn` \ (expr', fvs) ->
- returnRn (HsUnfold inline expr', fvs)
-rnIdInfo (HsArity arity) = returnRn (HsArity arity, emptyFVs)
-rnIdInfo (HsUpdate update) = returnRn (HsUpdate update, emptyFVs)
-rnIdInfo HsNoCafRefs = returnRn (HsNoCafRefs, emptyFVs)
-rnIdInfo HsCprInfo = returnRn (HsCprInfo, emptyFVs)
-
-\end{code}
-
-@UfCore@ expressions.
-
-\begin{code}
-rnCoreExpr (UfType ty)
- = rnHsType (text "unfolding type") ty `thenRn` \ (ty', fvs) ->
- returnRn (UfType ty', fvs)
-
-rnCoreExpr (UfVar v)
- = lookupOccRn v `thenRn` \ v' ->
- returnRn (UfVar v', unitFV v')
-
-rnCoreExpr (UfLit l)
- = returnRn (UfLit l, emptyFVs)
-
-rnCoreExpr (UfLitLit l ty)
- = rnHsType (text "litlit") ty `thenRn` \ (ty', fvs) ->
- returnRn (UfLitLit l ty', fvs)
-
-rnCoreExpr (UfCCall cc ty)
- = rnHsType (text "ccall") ty `thenRn` \ (ty', fvs) ->
- returnRn (UfCCall cc ty', fvs)
-
-rnCoreExpr (UfTuple con args)
- = rnHsTupConWkr con `thenRn` \ (con', fvs1) ->
- mapFvRn rnCoreExpr args `thenRn` \ (args', fvs2) ->
- returnRn (UfTuple con' args', fvs1 `plusFV` fvs2)
-
-rnCoreExpr (UfApp fun arg)
- = rnCoreExpr fun `thenRn` \ (fun', fv1) ->
- rnCoreExpr arg `thenRn` \ (arg', fv2) ->
- returnRn (UfApp fun' arg', fv1 `plusFV` fv2)
-
-rnCoreExpr (UfCase scrut bndr alts)
- = rnCoreExpr scrut `thenRn` \ (scrut', fvs1) ->
- bindCoreLocalFVRn bndr ( \ bndr' ->
- mapFvRn rnCoreAlt alts `thenRn` \ (alts', fvs2) ->
- returnRn (UfCase scrut' bndr' alts', fvs2)
- ) `thenRn` \ (case', fvs3) ->
- returnRn (case', fvs1 `plusFV` fvs3)
-
-rnCoreExpr (UfNote note expr)
- = rnNote note `thenRn` \ (note', fvs1) ->
- rnCoreExpr expr `thenRn` \ (expr', fvs2) ->
- returnRn (UfNote note' expr', fvs1 `plusFV` fvs2)
-
-rnCoreExpr (UfLam bndr body)
- = rnCoreBndr bndr $ \ bndr' ->
- rnCoreExpr body `thenRn` \ (body', fvs) ->
- returnRn (UfLam bndr' body', fvs)
-
-rnCoreExpr (UfLet (UfNonRec bndr rhs) body)
- = rnCoreExpr rhs `thenRn` \ (rhs', fvs1) ->
- rnCoreBndr bndr ( \ bndr' ->
- rnCoreExpr body `thenRn` \ (body', fvs2) ->
- returnRn (UfLet (UfNonRec bndr' rhs') body', fvs2)
- ) `thenRn` \ (result, fvs3) ->
- returnRn (result, fvs1 `plusFV` fvs3)
-
-rnCoreExpr (UfLet (UfRec pairs) body)
- = rnCoreBndrs bndrs $ \ bndrs' ->
- mapFvRn rnCoreExpr rhss `thenRn` \ (rhss', fvs1) ->
- rnCoreExpr body `thenRn` \ (body', fvs2) ->
- returnRn (UfLet (UfRec (bndrs' `zip` rhss')) body', fvs1 `plusFV` fvs2)
+ ; new_name <- lookupLocatedTopBndrRn name
+ ; name_env <- getLocalRdrEnv
+
+ -- For H98 syntax, the tvs are the existential ones
+ -- For GADT syntax, the tvs are all the quantified tyvars
+ -- Hence the 'filter' in the ResTyH98 case only
+ ; let not_in_scope = not . (`elemLocalRdrEnv` name_env) . unLoc
+ arg_tys = hsConArgs details
+ implicit_tvs = case res_ty of
+ ResTyH98 -> filter not_in_scope $
+ get_rdr_tvs arg_tys
+ ResTyGADT ty -> get_rdr_tvs (ty : arg_tys)
+ tvs' = case expl of
+ Explicit -> tvs
+ Implicit -> userHsTyVarBndrs implicit_tvs
+
+ ; bindTyVarsRn doc tvs' $ \new_tyvars -> do
+ { new_context <- rnContext doc cxt
+ ; new_details <- rnConDetails doc details
+ ; new_res_ty <- rnConResult doc res_ty
+ ; let rv = ConDecl new_name expl new_tyvars new_context new_details new_res_ty
+ ; traceRn (text "****** - autrijus" <> ppr rv)
+ ; return rv } }