diff options
| author | romes <rodrigo.m.mesquita@gmail.com> | 2022-02-15 09:34:23 +0000 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-18 05:10:58 -0400 |
| commit | 8561c1afdbbda73a31cb8f8f1e80d1f403673e9b (patch) | |
| tree | b659ad4c4dd83551c2a096c0e48ea91346352317 /compiler/GHC/Tc | |
| parent | 1a0dd0088247f9d4e403a460f0f6120184af3e15 (diff) | |
| download | haskell-8561c1afdbbda73a31cb8f8f1e80d1f403673e9b.tar.gz | |
TTG: Refactor HsBracket
Diffstat (limited to 'compiler/GHC/Tc')
| -rw-r--r-- | compiler/GHC/Tc/Gen/Expr.hs | 6 | ||||
| -rw-r--r-- | compiler/GHC/Tc/Gen/Splice.hs | 4 | ||||
| -rw-r--r-- | compiler/GHC/Tc/Types/Origin.hs | 2 | ||||
| -rw-r--r-- | compiler/GHC/Tc/Utils/Zonk.hs | 6 |
4 files changed, 7 insertions, 11 deletions
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs index 3043bed44c..6dadf6286c 100644 --- a/compiler/GHC/Tc/Gen/Expr.hs +++ b/compiler/GHC/Tc/Gen/Expr.hs @@ -861,8 +861,9 @@ tcExpr (HsSpliceE _ (HsSpliced _ mod_finalizers (HsSplicedExpr expr))) = do addModFinalizersWithLclEnv mod_finalizers tcExpr expr res_ty tcExpr (HsSpliceE _ splice) res_ty = tcSpliceExpr splice res_ty -tcExpr e@(HsBracket _ brack) res_ty = tcTypedBracket e brack res_ty -tcExpr e@(HsRnBracketOut _ brack ps) res_ty = tcUntypedBracket e brack ps res_ty +tcExpr e@(HsBracket brack body) res_ty = case brack of + HsBracketRnTyped _ -> tcTypedBracket e body res_ty + HsBracketRnUntyped _ ps -> tcUntypedBracket e body ps res_ty {- ************************************************************************ @@ -875,7 +876,6 @@ tcExpr e@(HsRnBracketOut _ brack ps) res_ty = tcUntypedBracket e brack ps res_ty tcExpr (HsOverLabel {}) ty = pprPanic "tcExpr:HsOverLabel" (ppr ty) tcExpr (SectionL {}) ty = pprPanic "tcExpr:SectionL" (ppr ty) tcExpr (SectionR {}) ty = pprPanic "tcExpr:SectionR" (ppr ty) -tcExpr (HsTcBracketOut x _ _ _) _ = dataConCantHappen x {- diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs index 2be524e1fc..674a3fc830 100644 --- a/compiler/GHC/Tc/Gen/Splice.hs +++ b/compiler/GHC/Tc/Gen/Splice.hs @@ -217,7 +217,7 @@ tcTypedBracket rn_expr brack@(TExpBr _ expr) res_ty rn_expr (unLoc (mkHsApp (mkLHsWrap (applyQuoteWrapper wrapper) (nlHsTyApp codeco [rep, expr_ty])) - (noLocA (HsTcBracketOut bracket_ty (Just wrapper) brack ps')))) + (noLocA (HsBracket (HsBracketTc bracket_ty (Just wrapper) ps') brack)))) meta_ty res_ty } tcTypedBracket _ other_brack _ = pprPanic "tcTypedBracket" (ppr other_brack) @@ -246,7 +246,7 @@ tcUntypedBracket rn_expr brack ps res_ty -- Unify the overall type of the bracket with the expected result -- type ; tcWrapResultO BracketOrigin rn_expr - (HsTcBracketOut expected_type brack_info brack ps') + (HsBracket (HsBracketTc expected_type brack_info ps') brack) expected_type res_ty } diff --git a/compiler/GHC/Tc/Types/Origin.hs b/compiler/GHC/Tc/Types/Origin.hs index ebbf802026..b8ec635bd4 100644 --- a/compiler/GHC/Tc/Types/Origin.hs +++ b/compiler/GHC/Tc/Types/Origin.hs @@ -706,8 +706,6 @@ exprCtOrigin (ExprWithTySig {}) = ExprSigOrigin exprCtOrigin (ArithSeq {}) = Shouldn'tHappenOrigin "arithmetic sequence" exprCtOrigin (HsPragE _ _ e) = lexprCtOrigin e exprCtOrigin (HsBracket {}) = Shouldn'tHappenOrigin "TH bracket" -exprCtOrigin (HsRnBracketOut {})= Shouldn'tHappenOrigin "HsRnBracketOut" -exprCtOrigin (HsTcBracketOut {})= panic "exprCtOrigin HsTcBracketOut" exprCtOrigin (HsSpliceE {}) = Shouldn'tHappenOrigin "TH splice" exprCtOrigin (HsProc {}) = Shouldn'tHappenOrigin "proc" exprCtOrigin (HsStatic {}) = Shouldn'tHappenOrigin "static expression" diff --git a/compiler/GHC/Tc/Utils/Zonk.hs b/compiler/GHC/Tc/Utils/Zonk.hs index 197a8d8104..0628ab428c 100644 --- a/compiler/GHC/Tc/Utils/Zonk.hs +++ b/compiler/GHC/Tc/Utils/Zonk.hs @@ -778,13 +778,11 @@ zonkExpr env (HsAppType ty e t) return (HsAppType new_ty new_e t) -- NB: the type is an HsType; can't zonk that! -zonkExpr _ (HsRnBracketOut x _ _) = dataConCantHappen x - -zonkExpr env (HsTcBracketOut ty wrap body bs) +zonkExpr env (HsBracket (HsBracketTc ty wrap bs) body) = do wrap' <- traverse zonkQuoteWrap wrap bs' <- mapM (zonk_b env) bs new_ty <- zonkTcTypeToTypeX env ty - return (HsTcBracketOut new_ty wrap' body bs') + return (HsBracket (HsBracketTc new_ty wrap' bs') body) where zonkQuoteWrap (QuoteWrapper ev ty) = do let ev' = zonkIdOcc env ev |
