Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Tc/Gen/App.hs
    ... ... @@ -178,14 +178,17 @@ Note [Instantiation variables are short lived]
    178 178
     -- take in the rn_expr and its location to pass into tcValArgs
    
    179 179
     tcExprSigma :: Bool -> HsExpr GhcRn -> TcM (HsExpr GhcTc, TcSigmaType)
    
    180 180
     tcExprSigma inst rn_expr
    
    181
    -  = do { (fun@(rn_fun,fun_ctxt), rn_args) <- splitHsApps rn_expr
    
    181
    +  = do { (fun@(rn_fun,fun_lspan), rn_args) <- splitHsApps rn_expr
    
    182 182
            ; do_ql <- wantQuickLook rn_fun
    
    183 183
            ; (tc_fun, fun_sigma) <- tcInferAppHead fun
    
    184 184
            ; code_orig <- getSrcCodeOrigin
    
    185
    -       ; let fun_orig = srcCodeOriginCtOrigin rn_expr code_orig
    
    186
    -       ; (inst_args, app_res_sigma) <- tcInstFun do_ql inst (fun_orig, rn_fun, fun_ctxt) tc_fun fun_sigma rn_args
    
    187
    -       ; tc_args <- tcValArgs do_ql (rn_fun, generatedSrcSpan) inst_args
    
    188
    -       ; let tc_expr = rebuildHsApps (tc_fun, fun_ctxt) tc_args
    
    185
    +       ; let fun_orig | isGoodSrcSpan fun_lspan
    
    186
    +                      = exprCtOrigin rn_fun
    
    187
    +                      | otherwise
    
    188
    +                      = srcCodeOriginCtOrigin rn_fun code_orig
    
    189
    +       ; (inst_args, app_res_sigma) <- tcInstFun do_ql inst (fun_orig, rn_fun, fun_lspan) tc_fun fun_sigma rn_args
    
    190
    +       ; tc_args <- tcValArgs do_ql (rn_fun, fun_lspan) inst_args
    
    191
    +       ; let tc_expr = rebuildHsApps (tc_fun, fun_lspan) tc_args
    
    189 192
            ; return (tc_expr, app_res_sigma) }
    
    190 193
     
    
    191 194
     
    
    ... ... @@ -2239,7 +2242,7 @@ tcTagToEnum :: (HsExpr GhcTc, SrcSpan) -> [HsExprArg 'TcpTc]
    2239 2242
                 -> TcM (HsExpr GhcTc)
    
    2240 2243
     -- tagToEnum# :: forall a. Int# -> a
    
    2241 2244
     -- See Note [tagToEnum#]   Urgh!
    
    2242
    -tcTagToEnum (tc_fun, fun_ctxt) tc_args res_ty
    
    2245
    +tcTagToEnum (tc_fun, fun_lspan) tc_args res_ty
    
    2243 2246
       | [val_arg] <- dropWhile (not . isHsValArg) tc_args
    
    2244 2247
       = do { res_ty <- liftZonkM $ zonkTcType res_ty
    
    2245 2248
     
    
    ... ... @@ -2261,14 +2264,14 @@ tcTagToEnum (tc_fun, fun_ctxt) tc_args res_ty
    2261 2264
            ; let rep_ty  = mkTyConApp rep_tc rep_args
    
    2262 2265
                  tc_fun' = mkHsWrap (WpTyApp rep_ty) tc_fun
    
    2263 2266
                  df_wrap = mkWpCastR (mkSymCo coi)
    
    2264
    -             tc_expr = rebuildHsApps (tc_fun', fun_ctxt) [val_arg]
    
    2267
    +             tc_expr = rebuildHsApps (tc_fun', fun_lspan) [val_arg]
    
    2265 2268
            ; return (mkHsWrap df_wrap tc_expr) }}}}}
    
    2266 2269
     
    
    2267 2270
       | otherwise
    
    2268 2271
       = failWithTc TcRnTagToEnumMissingValArg
    
    2269 2272
     
    
    2270 2273
       where
    
    2271
    -    vanilla_result = return (rebuildHsApps (tc_fun, fun_ctxt) tc_args)
    
    2274
    +    vanilla_result = return (rebuildHsApps (tc_fun, fun_lspan) tc_args)
    
    2272 2275
     
    
    2273 2276
         check_enumeration ty' tc
    
    2274 2277
           | -- isTypeDataTyCon: see wrinkle (W1) in
    

  • compiler/GHC/Tc/Gen/Head.hs
    ... ... @@ -457,7 +457,7 @@ tcInferAppHead :: (HsExpr GhcRn, SrcSpan)
    457 457
     --
    
    458 458
     -- See Note [tcApp: typechecking applications] in GHC.Tc.Gen.App
    
    459 459
     tcInferAppHead (fun,fun_lspan)
    
    460
    -  = addLExprCtxt fun_lspan fun $
    
    460
    +  = setSrcSpan fun_lspan $
    
    461 461
         do { mb_tc_fun <- tcInferAppHead_maybe fun
    
    462 462
            ; case mb_tc_fun of
    
    463 463
                 Just (fun', fun_sigma) -> return (fun', fun_sigma)
    
    ... ... @@ -471,10 +471,10 @@ tcInferAppHead_maybe fun =
    471 471
         case fun of
    
    472 472
           HsVar _ nm                  -> Just <$> tcInferId nm
    
    473 473
           XExpr (HsRecSelRn f)        -> Just <$> tcInferRecSelId f
    
    474
    -      XExpr (ExpandedThingRn _ e) -> Just <$> -- (addExpansionErrCtxt o (srcCodeOriginErrCtxMsg o) $
    
    474
    +      XExpr (ExpandedThingRn o e) -> Just <$> (addExpansionErrCtxt o (srcCodeOriginErrCtxMsg o) $
    
    475 475
                                                   -- We do not want to instantiate c.f. T19167
    
    476 476
                                                   tcExprSigma False e
    
    477
    -                                              -- )
    
    477
    +                                              )
    
    478 478
           ExprWithTySig _ e hs_ty     -> Just <$> tcExprWithSig e hs_ty
    
    479 479
           HsOverLit _ lit             -> Just <$> tcInferOverLit lit
    
    480 480
           _                           -> return Nothing