| ... |
... |
@@ -175,6 +175,9 @@ Note [Instantiation variables are short lived] |
|
175
|
175
|
-- CAUTION: Any changes to tcApp should be reflected here
|
|
176
|
176
|
-- cf. T19167. the head is an expanded expression applied to a type
|
|
177
|
177
|
-- TODO: Use runInfer for tcExprSigma?
|
|
|
178
|
+-- Caution: Currently we assume that the expression is compiler generated/expanded
|
|
|
179
|
+-- Becuase that is that T19167 testcase generates. This function can possibly
|
|
|
180
|
+-- take in the rn_expr and its location to pass into tcValArgs
|
|
178
|
181
|
tcExprSigma :: Bool -> HsExpr GhcRn -> TcM (HsExpr GhcTc, TcSigmaType)
|
|
179
|
182
|
tcExprSigma inst rn_expr
|
|
180
|
183
|
= do { (fun@(rn_fun,fun_ctxt), rn_args) <- splitHsApps rn_expr
|
| ... |
... |
@@ -183,7 +186,7 @@ tcExprSigma inst rn_expr |
|
183
|
186
|
; code_orig <- getSrcCodeOrigin
|
|
184
|
187
|
; let fun_orig = srcCodeOriginCtOrigin rn_expr code_orig
|
|
185
|
188
|
; (inst_args, app_res_sigma) <- tcInstFun do_ql inst fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
|
|
186
|
|
- ; tc_args <- tcValArgs do_ql rn_fun inst_args
|
|
|
189
|
+ ; tc_args <- tcValArgs do_ql (rn_fun, generatedSrcSpan) inst_args
|
|
187
|
190
|
; let tc_expr = rebuildHsApps (tc_fun, fun_ctxt) tc_args
|
|
188
|
191
|
; return (tc_expr, app_res_sigma) }
|
|
189
|
192
|
|
| ... |
... |
@@ -396,18 +399,18 @@ tcApp :: HsExpr GhcRn |
|
396
|
399
|
-- See Note [tcApp: typechecking applications]
|
|
397
|
400
|
tcApp rn_expr exp_res_ty
|
|
398
|
401
|
= do { -- Step 1: Split the application chain
|
|
399
|
|
- (fun@(rn_fun, fun_loc), rn_args) <- splitHsApps rn_expr
|
|
|
402
|
+ (fun@(rn_fun, fun_lspan), rn_args) <- splitHsApps rn_expr
|
|
400
|
403
|
; inGenCode <- inGeneratedCode
|
|
401
|
404
|
; traceTc "tcApp {" $
|
|
402
|
405
|
vcat [ text "generated? " <+> ppr inGenCode
|
|
403
|
406
|
, text "rn_expr:" <+> ppr rn_expr
|
|
404
|
407
|
, text "rn_fun:" <+> ppr rn_fun
|
|
405
|
|
- , text "fun_loc:" <+> ppr fun_loc
|
|
|
408
|
+ , text "fun_lspan:" <+> ppr fun_lspan
|
|
406
|
409
|
, text "rn_args:" <+> ppr rn_args ]
|
|
407
|
410
|
|
|
408
|
411
|
-- Step 2: Infer the type of `fun`, the head of the application
|
|
409
|
412
|
; (tc_fun, fun_sigma) <- tcInferAppHead fun
|
|
410
|
|
- ; let tc_head = (tc_fun, fun_loc)
|
|
|
413
|
+ ; let tc_head = (tc_fun, fun_lspan)
|
|
411
|
414
|
-- inst_final: top-instantiate the result type of the application,
|
|
412
|
415
|
-- EXCEPT if we are trying to infer a sigma-type
|
|
413
|
416
|
inst_final = case exp_res_ty of
|
| ... |
... |
@@ -438,7 +441,7 @@ tcApp rn_expr exp_res_ty |
|
438
|
441
|
, text "fun_origin" <+> ppr fun_orig
|
|
439
|
442
|
, text "do_ql:" <+> ppr do_ql]
|
|
440
|
443
|
; (inst_args, app_res_rho)
|
|
441
|
|
- <- tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_loc) fun_sigma rn_args
|
|
|
444
|
+ <- tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
|
|
442
|
445
|
-- See (TCAPP1) and (TCAPP2) in
|
|
443
|
446
|
-- Note [tcApp: typechecking applications]
|
|
444
|
447
|
|
| ... |
... |
@@ -451,7 +454,7 @@ tcApp rn_expr exp_res_ty |
|
451
|
454
|
app_res_rho exp_res_ty
|
|
452
|
455
|
|
|
453
|
456
|
-- Step 4.2: typecheck the arguments
|
|
454
|
|
- ; tc_args <- tcValArgs NoQL rn_fun inst_args
|
|
|
457
|
+ ; tc_args <- tcValArgs NoQL (rn_fun, fun_lspan) inst_args
|
|
455
|
458
|
-- Step 4.3: wrap up
|
|
456
|
459
|
; finishApp tc_head tc_args app_res_rho res_wrap }
|
|
457
|
460
|
|
| ... |
... |
@@ -462,7 +465,7 @@ tcApp rn_expr exp_res_ty |
|
462
|
465
|
|
|
463
|
466
|
-- Step 5.2: typecheck the arguments, and monomorphise
|
|
464
|
467
|
-- any un-unified instantiation variables
|
|
465
|
|
- ; tc_args <- tcValArgs DoQL rn_fun inst_args
|
|
|
468
|
+ ; tc_args <- tcValArgs DoQL (rn_fun, fun_lspan) inst_args
|
|
466
|
469
|
-- Step 5.3: zonk to expose the polymorphism hidden under
|
|
467
|
470
|
-- QuickLook instantiation variables in `app_res_rho`
|
|
468
|
471
|
; app_res_rho <- liftZonkM $ zonkTcType app_res_rho
|
| ... |
... |
@@ -549,16 +552,16 @@ checkResultTy rn_expr (tc_fun, fun_loc) inst_args app_res_rho (Check res_ty) |
|
549
|
552
|
thing_inside
|
|
550
|
553
|
|
|
551
|
554
|
----------------
|
|
552
|
|
-tcValArgs :: QLFlag -> HsExpr GhcRn -> [HsExprArg 'TcpInst] -> TcM [HsExprArg 'TcpTc]
|
|
|
555
|
+tcValArgs :: QLFlag -> (HsExpr GhcRn, SrcSpan) -> [HsExprArg 'TcpInst] -> TcM [HsExprArg 'TcpTc]
|
|
553
|
556
|
-- Importantly, tcValArgs works left-to-right, so that by the time we
|
|
554
|
557
|
-- encounter an argument, we have monomorphised all the instantiation
|
|
555
|
558
|
-- variables that its type contains. All that is left to do is an ordinary
|
|
556
|
559
|
-- zonkTcType. See Note [Monomorphise instantiation variables].
|
|
557
|
|
-tcValArgs do_ql fun args = go do_ql 0 args
|
|
|
560
|
+tcValArgs do_ql (fun, fun_lspan) args = go do_ql 0 args
|
|
558
|
561
|
where
|
|
559
|
562
|
go _ _ [] = return []
|
|
560
|
563
|
go do_ql pos (arg : args) =
|
|
561
|
|
- do { arg' <- tcValArg do_ql pos' fun arg
|
|
|
564
|
+ do { arg' <- tcValArg do_ql pos' (fun, fun_lspan) arg
|
|
562
|
565
|
; args' <- go do_ql pos' args
|
|
563
|
566
|
; return (arg' : args') }
|
|
564
|
567
|
where
|
| ... |
... |
@@ -574,7 +577,7 @@ tcValArgs do_ql fun args = go do_ql 0 args |
|
574
|
577
|
= pos
|
|
575
|
578
|
|
|
576
|
579
|
|
|
577
|
|
-tcValArg :: QLFlag -> Int -> HsExpr GhcRn -> HsExprArg 'TcpInst -- Actual argument
|
|
|
580
|
+tcValArg :: QLFlag -> Int -> (HsExpr GhcRn, SrcSpan) -> HsExprArg 'TcpInst -- Actual argument
|
|
578
|
581
|
-> TcM (HsExprArg 'TcpTc) -- Resulting argument
|
|
579
|
582
|
tcValArg _ _ _ (EPrag l p) = return (EPrag l (tcExprPrag p))
|
|
580
|
583
|
tcValArg _ _ _ (ETypeArg l hty ty) = return (ETypeArg l hty ty)
|
| ... |
... |
@@ -583,10 +586,10 @@ tcValArg do_ql _ _ (EWrap (EHsWrap w)) = do { whenQL do_ql $ qlMonoHsWrapper w |
|
583
|
586
|
-- qlMonoHsWrapper: see Note [Monomorphise instantiation variables]
|
|
584
|
587
|
tcValArg _ _ _ (EWrap ew) = return (EWrap ew)
|
|
585
|
588
|
|
|
586
|
|
-tcValArg do_ql pos fun (EValArg { ea_loc_span = lspan
|
|
|
589
|
+tcValArg do_ql pos (fun, fun_lspan) (EValArg { ea_loc_span = lspan
|
|
587
|
590
|
, ea_arg = larg@(L arg_loc arg)
|
|
588
|
591
|
, ea_arg_ty = sc_arg_ty })
|
|
589
|
|
- = addArgCtxt pos fun larg $
|
|
|
592
|
+ = addArgCtxt pos (fun, fun_lspan) larg $
|
|
590
|
593
|
do { -- Crucial step: expose QL results before checking exp_arg_ty
|
|
591
|
594
|
-- So far as the paper is concerned, this step applies
|
|
592
|
595
|
-- the poly-substitution Theta, learned by QL, so that we
|
| ... |
... |
@@ -601,6 +604,7 @@ tcValArg do_ql pos fun (EValArg { ea_loc_span = lspan |
|
601
|
604
|
NoQL -> return sc_arg_ty
|
|
602
|
605
|
; traceTc "tcValArg {" $
|
|
603
|
606
|
vcat [ text "lspan:" <+> ppr lspan
|
|
|
607
|
+ , text "fun_lspan" <+> ppr fun_lspan
|
|
604
|
608
|
, text "sigma_type" <+> ppr (mkCheckExpType exp_arg_ty)
|
|
605
|
609
|
, text "arg:" <+> ppr larg
|
|
606
|
610
|
]
|
| ... |
... |
@@ -615,7 +619,7 @@ tcValArg do_ql pos fun (EValArg { ea_loc_span = lspan |
|
615
|
619
|
, ea_arg = L arg_loc arg'
|
|
616
|
620
|
, ea_arg_ty = noExtField }) }
|
|
617
|
621
|
|
|
618
|
|
-tcValArg _ pos fun (EValArgQL {
|
|
|
622
|
+tcValArg _ pos (fun, fun_lspan) (EValArgQL {
|
|
619
|
623
|
eaql_wanted = wanted
|
|
620
|
624
|
, eaql_loc_span = lspan
|
|
621
|
625
|
, eaql_arg_ty = sc_arg_ty
|
| ... |
... |
@@ -626,7 +630,7 @@ tcValArg _ pos fun (EValArgQL { |
|
626
|
630
|
, eaql_args = inst_args
|
|
627
|
631
|
, eaql_encl = arg_influences_enclosing_call
|
|
628
|
632
|
, eaql_res_rho = app_res_rho })
|
|
629
|
|
- = addArgCtxt pos fun larg $
|
|
|
633
|
+ = addArgCtxt pos (fun, fun_lspan) larg $
|
|
630
|
634
|
do { -- Expose QL results to tcSkolemise, as in EValArg case
|
|
631
|
635
|
Scaled mult exp_arg_ty <- liftZonkM $ zonkScaledTcType sc_arg_ty
|
|
632
|
636
|
|
| ... |
... |
@@ -635,6 +639,8 @@ tcValArg _ pos fun (EValArgQL { |
|
635
|
639
|
, text "args:" <+> ppr inst_args
|
|
636
|
640
|
, text "mult:" <+> ppr mult
|
|
637
|
641
|
, text "fun" <+> ppr fun
|
|
|
642
|
+ , text "app_lspan" <+> ppr lspan
|
|
|
643
|
+ , text "head_lspan" <+> ppr fun_lspan
|
|
638
|
644
|
, text "tc_head" <+> ppr tc_head])
|
|
639
|
645
|
|
|
640
|
646
|
; ds_flag <- getDeepSubsumptionFlag
|
| ... |
... |
@@ -653,7 +659,7 @@ tcValArg _ pos fun (EValArgQL { |
|
653
|
659
|
; unless arg_influences_enclosing_call $ -- Don't repeat
|
|
654
|
660
|
qlUnify app_res_rho exp_arg_rho -- the qlUnify
|
|
655
|
661
|
|
|
656
|
|
- ; tc_args <- tcValArgs DoQL rn_fun inst_args
|
|
|
662
|
+ ; tc_args <- tcValArgs DoQL (rn_fun, snd tc_head) inst_args
|
|
657
|
663
|
; app_res_rho <- liftZonkM $ zonkTcType app_res_rho
|
|
658
|
664
|
; res_wrap <- checkResultTy rn_expr tc_head inst_args
|
|
659
|
665
|
app_res_rho (mkCheckExpType exp_arg_rho)
|
| ... |
... |
@@ -696,20 +702,20 @@ tcInstFun :: QLFlag |
|
696
|
702
|
-- Generally speaking we pass in True; in Fig 5 of the paper
|
|
697
|
703
|
-- |-inst returns a rho-type
|
|
698
|
704
|
-> CtOrigin
|
|
699
|
|
- -> (HsExpr GhcTc, HsExpr GhcRn, SrcSpan)
|
|
|
705
|
+ -> (HsExpr GhcTc, HsExpr GhcRn, SrcSpan) -- ANI: TODO, move HsExpr GhcRn, SrcSpan to CtOrigin
|
|
700
|
706
|
-> TcSigmaType -> [HsExprArg 'TcpRn]
|
|
701
|
707
|
-> TcM ( [HsExprArg 'TcpInst]
|
|
702
|
708
|
, TcSigmaType ) -- Does not instantiate trailing invisible foralls
|
|
703
|
709
|
-- This crucial function implements the |-inst judgement in Fig 4, plus the
|
|
704
|
710
|
-- modification in Fig 5, of the QL paper:
|
|
705
|
711
|
-- "A quick look at impredicativity" (ICFP'20).
|
|
706
|
|
-tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
|
|
|
712
|
+tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
|
|
707
|
713
|
= do { traceTc "tcInstFun" (vcat [ text "origin" <+> ppr fun_orig
|
|
708
|
714
|
, text "tc_fun" <+> ppr tc_fun
|
|
709
|
715
|
, text "fun_sigma" <+> ppr fun_sigma
|
|
710
|
716
|
, text "args:" <+> ppr rn_args
|
|
711
|
717
|
, text "do_ql" <+> ppr do_ql
|
|
712
|
|
- , text "ctx" <+> ppr fun_ctxt])
|
|
|
718
|
+ , text "ctx" <+> ppr fun_lspan])
|
|
713
|
719
|
; setQLInstLevel do_ql $ -- See (TCAPP1) and (TCAPP2) in
|
|
714
|
720
|
-- Note [tcApp: typechecking applications]
|
|
715
|
721
|
go 1 [] fun_sigma rn_args }
|
| ... |
... |
@@ -786,7 +792,7 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args |
|
786
|
792
|
= do { (_inst_tvs, wrap, fun_rho) <-
|
|
787
|
793
|
-- addHeadCtxt: important for the class constraints
|
|
788
|
794
|
-- that may be emitted from instantiating fun_sigma
|
|
789
|
|
- setSrcSpan fun_ctxt $
|
|
|
795
|
+ setSrcSpan fun_lspan $
|
|
790
|
796
|
instantiateSigma fun_orig fun_conc_tvs tvs theta body2
|
|
791
|
797
|
-- See Note [Representation-polymorphism checking built-ins]
|
|
792
|
798
|
-- in GHC.Tc.Utils.Concrete.
|
| ... |
... |
@@ -881,7 +887,7 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args |
|
881
|
887
|
(Just $ HsExprTcThing tc_fun)
|
|
882
|
888
|
(n_val_args, fun_sigma) fun_ty
|
|
883
|
889
|
|
|
884
|
|
- ; arg' <- quickLookArg do_ql pos ctxt rn_fun arg arg_ty
|
|
|
890
|
+ ; arg' <- quickLookArg do_ql pos ctxt (rn_fun, fun_lspan) arg arg_ty
|
|
885
|
891
|
; let acc' = arg' : addArgWrap wrap acc
|
|
886
|
892
|
; go (pos+1) acc' res_ty rest_args }
|
|
887
|
893
|
|
| ... |
... |
@@ -931,7 +937,7 @@ looks_like_type_arg EValArg{ ea_arg = L _ e } = |
|
931
|
937
|
_ -> False
|
|
932
|
938
|
looks_like_type_arg _ = False
|
|
933
|
939
|
|
|
934
|
|
-addArgCtxt :: Int -> HsExpr GhcRn -> LHsExpr GhcRn
|
|
|
940
|
+addArgCtxt :: Int -> (HsExpr GhcRn, SrcSpan) -> LHsExpr GhcRn
|
|
935
|
941
|
-> TcM a -> TcM a
|
|
936
|
942
|
-- There are 2 cases:
|
|
937
|
943
|
-- 1. In the normal case, we add an informative context (<=> `inGeneratedCode` is `False`)
|
| ... |
... |
@@ -942,7 +948,7 @@ addArgCtxt :: Int -> HsExpr GhcRn -> LHsExpr GhcRn |
|
942
|
948
|
-- (iii) if arg_loc is RealSrcLoc then update tcl_loc and add "In the expression: arg" to ErrCtxtStack
|
|
943
|
949
|
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
|
|
944
|
950
|
-- See Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do
|
|
945
|
|
-addArgCtxt arg_no fun (L arg_loc arg) thing_inside
|
|
|
951
|
+addArgCtxt arg_no (fun, fun_lspan) (L arg_loc arg) thing_inside
|
|
946
|
952
|
= do { in_generated_code <- inGeneratedCode
|
|
947
|
953
|
; err_ctx <- getErrCtxt
|
|
948
|
954
|
; env0 <- liftZonkM tcInitTidyEnv
|
| ... |
... |
@@ -951,12 +957,14 @@ addArgCtxt arg_no fun (L arg_loc arg) thing_inside |
|
951
|
957
|
, text "arg: " <+> ppr (arg, arg_no)
|
|
952
|
958
|
, text "arg_loc:" <+> ppr arg_loc
|
|
953
|
959
|
, text "fun:" <+> ppr fun
|
|
954
|
|
- , text "err_ctx" <+> vcat (fmap (\ (x, y) -> case x of
|
|
955
|
|
- MkErrCtxt (ExpansionCodeCtxt{}) _ -> text "<EXPN>" <+> pprErrCtxtMsg y
|
|
956
|
|
- _ -> text "<USER>" <+> pprErrCtxtMsg y)
|
|
957
|
|
- (take 4 (zip err_ctx err_ctx_msg)))
|
|
|
960
|
+ , text "fun_lspan" <+> ppr fun_lspan
|
|
|
961
|
+ , text "err_ctx" <+> vcat (fmap (\ (x, y) ->
|
|
|
962
|
+ case x of
|
|
|
963
|
+ MkErrCtxt (ExpansionCodeCtxt{}) _ -> text "<EXPN>" <+> pprErrCtxtMsg y
|
|
|
964
|
+ _ -> text "<USER>" <+> pprErrCtxtMsg y)
|
|
|
965
|
+ (take 4 (zip err_ctx err_ctx_msg)))
|
|
958
|
966
|
])
|
|
959
|
|
- ; if in_generated_code
|
|
|
967
|
+ ; if in_generated_code && isGeneratedSrcSpan fun_lspan
|
|
960
|
968
|
then updCtxtForArg (L arg_loc arg) $
|
|
961
|
969
|
thing_inside
|
|
962
|
970
|
else do setSrcSpanA arg_loc $
|
| ... |
... |
@@ -1745,24 +1753,26 @@ This turned out to be more subtle than I expected. Wrinkles: |
|
1745
|
1753
|
|
|
1746
|
1754
|
-}
|
|
1747
|
1755
|
|
|
1748
|
|
-quickLookArg :: QLFlag -> Int -> SrcSpan -> HsExpr GhcRn
|
|
|
1756
|
+quickLookArg :: QLFlag -> Int
|
|
|
1757
|
+ -> SrcSpan -- ^ location span of the whole application
|
|
|
1758
|
+ -> (HsExpr GhcRn, SrcSpan) -- ^ Head of the application chain and its source span
|
|
1749
|
1759
|
-> LHsExpr GhcRn -- ^ Argument
|
|
1750
|
1760
|
-> Scaled TcSigmaTypeFRR -- ^ Type expected by the function
|
|
1751
|
1761
|
-> TcM (HsExprArg 'TcpInst)
|
|
1752
|
1762
|
-- See Note [Quick Look at value arguments]
|
|
1753
|
|
-quickLookArg NoQL _ ctxt _ larg orig_arg_ty
|
|
1754
|
|
- = skipQuickLook ctxt larg orig_arg_ty
|
|
1755
|
|
-quickLookArg DoQL pos ctxt fun larg orig_arg_ty
|
|
|
1763
|
+quickLookArg NoQL _ app_lspan _ larg orig_arg_ty
|
|
|
1764
|
+ = skipQuickLook app_lspan larg orig_arg_ty
|
|
|
1765
|
+quickLookArg DoQL pos app_lspan fun_and_lspan larg orig_arg_ty
|
|
1756
|
1766
|
= do { is_rho <- tcIsDeepRho (scaledThing orig_arg_ty)
|
|
1757
|
1767
|
; traceTc "qla" (ppr orig_arg_ty $$ ppr is_rho)
|
|
1758
|
1768
|
; if not is_rho
|
|
1759
|
|
- then skipQuickLook ctxt larg orig_arg_ty
|
|
1760
|
|
- else quickLookArg1 pos ctxt fun larg orig_arg_ty }
|
|
|
1769
|
+ then skipQuickLook app_lspan larg orig_arg_ty
|
|
|
1770
|
+ else quickLookArg1 pos app_lspan fun_and_lspan larg orig_arg_ty }
|
|
1761
|
1771
|
|
|
1762
|
1772
|
skipQuickLook :: SrcSpan -> LHsExpr GhcRn -> Scaled TcRhoType
|
|
1763
|
1773
|
-> TcM (HsExprArg 'TcpInst)
|
|
1764
|
|
-skipQuickLook ctxt larg arg_ty
|
|
1765
|
|
- = return (EValArg { ea_loc_span = ctxt
|
|
|
1774
|
+skipQuickLook app_lspan larg arg_ty
|
|
|
1775
|
+ = return (EValArg { ea_loc_span = app_lspan
|
|
1766
|
1776
|
, ea_arg = larg
|
|
1767
|
1777
|
, ea_arg_ty = arg_ty })
|
|
1768
|
1778
|
|
| ... |
... |
@@ -1800,14 +1810,14 @@ isGuardedTy ty |
|
1800
|
1810
|
| Just {} <- tcSplitAppTy_maybe ty = True
|
|
1801
|
1811
|
| otherwise = False
|
|
1802
|
1812
|
|
|
1803
|
|
-quickLookArg1 :: Int -> SrcSpan -> HsExpr GhcRn -> LHsExpr GhcRn
|
|
|
1813
|
+quickLookArg1 :: Int -> SrcSpan -> (HsExpr GhcRn, SrcSpan) -> LHsExpr GhcRn
|
|
1804
|
1814
|
-> Scaled TcRhoType -- Deeply skolemised
|
|
1805
|
1815
|
-> TcM (HsExprArg 'TcpInst)
|
|
1806
|
1816
|
-- quickLookArg1 implements the "QL Argument" judgement in Fig 5 of the paper
|
|
1807
|
|
-quickLookArg1 pos ctxt fun larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho)
|
|
1808
|
|
- = addArgCtxt pos fun larg $ -- Context needed for constraints
|
|
|
1817
|
+quickLookArg1 pos app_lspan (fun, fun_lspan) larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho)
|
|
|
1818
|
+ = addArgCtxt pos (fun, fun_lspan) larg $ -- Context needed for constraints
|
|
1809
|
1819
|
-- generated by calls in arg
|
|
1810
|
|
- do { ((rn_fun, fun_ctxt), rn_args) <- splitHsApps arg
|
|
|
1820
|
+ do { ((rn_fun, fun_lspan), rn_args) <- splitHsApps arg
|
|
1811
|
1821
|
|
|
1812
|
1822
|
-- Step 1: get the type of the head of the argument
|
|
1813
|
1823
|
; (fun_ue, mb_fun_ty) <- tcCollectingUsage $ tcInferAppHead_maybe rn_fun
|
| ... |
... |
@@ -1823,15 +1833,15 @@ quickLookArg1 pos ctxt fun larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho) |
|
1823
|
1833
|
, text "args:" <+> ppr rn_args ]
|
|
1824
|
1834
|
|
|
1825
|
1835
|
; case mb_fun_ty of {
|
|
1826
|
|
- Nothing -> skipQuickLook ctxt larg sc_arg_ty ; -- fun is too complicated
|
|
|
1836
|
+ Nothing -> skipQuickLook app_lspan larg sc_arg_ty ; -- fun is too complicated
|
|
1827
|
1837
|
Just (tc_fun, fun_sigma) ->
|
|
1828
|
1838
|
|
|
1829
|
1839
|
-- step 2: use |-inst to instantiate the head applied to the arguments
|
|
1830
|
|
- do { let tc_head = (tc_fun, fun_ctxt)
|
|
|
1840
|
+ do { let tc_head = (tc_fun, fun_lspan)
|
|
1831
|
1841
|
; do_ql <- wantQuickLook rn_fun
|
|
1832
|
1842
|
; ((inst_args, app_res_rho), wanted)
|
|
1833
|
1843
|
<- captureConstraints $
|
|
1834
|
|
- tcInstFun do_ql True (exprCtOrigin arg) (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
|
|
|
1844
|
+ tcInstFun do_ql True (exprCtOrigin arg) (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
|
|
1835
|
1845
|
-- We must capture type-class and equality constraints here, but
|
|
1836
|
1846
|
-- not equality constraints. See (QLA6) in Note [Quick Look at
|
|
1837
|
1847
|
-- value arguments]
|
| ... |
... |
@@ -1863,7 +1873,7 @@ quickLookArg1 pos ctxt fun larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho) |
|
1863
|
1873
|
|
|
1864
|
1874
|
; traceTc "quickLookArg done }" (ppr rn_fun)
|
|
1865
|
1875
|
|
|
1866
|
|
- ; return (EValArgQL { eaql_loc_span = ctxt
|
|
|
1876
|
+ ; return (EValArgQL { eaql_loc_span = app_lspan
|
|
1867
|
1877
|
, eaql_arg_ty = sc_arg_ty
|
|
1868
|
1878
|
, eaql_larg = larg
|
|
1869
|
1879
|
, eaql_tc_fun = tc_head
|