| ... |
... |
@@ -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
|