diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs index 9cffbc254d3808a4a91e50f53bf6638e032c23d8..07078a6c880663e4a151f29d3aaac870f68b9d4b 100644 --- a/compiler/typecheck/TcExpr.hs +++ b/compiler/typecheck/TcExpr.hs @@ -170,7 +170,7 @@ tcExpr1 e ty | Check ty' <- ty -- if the type has sigma vars, -- the expression *must* be a guarding argument - , not (tcNoSigmaTyVars ty) + , not (tcNoSigmaTyVars ty') = do { is_guarding <- tcIsGuardingArg e ; if is_guarding then tcExpr e ty @@ -1308,7 +1308,7 @@ tcArgs fun orig_fun_ty fun_orig orig_args res_ty herald go _ _ fun_ty [] deferred_args | Check res_ty' <- res_ty - , tcNoSigmaTyVars res_ty' + , tcExpNoSigmaTyVars res_ty = do { wrap <- tcSubTypeO fun_orig GenSigCtxt fun_ty res_ty -- zonk the types to make the information visible ; deferred_args' <- forM deferred_args (\(arg_expr, arg_info) -> @@ -1375,7 +1375,7 @@ tcArgs fun orig_fun_ty fun_orig orig_args res_ty herald ; (wrap, [arg_ty], res_ty) <- matchActualFunTysPart herald fun_orig (Just (unLoc fun)) 1 fun_ty acc_args orig_expr_args_arity next_val_args - res_ty_is_fully_known + (tcExpNoSigmaTyVars res_ty) -- wrap :: fun_ty "->" arg_ty -> res_ty -- ; arg' <- tcArg fun arg arg_ty n -- defer it until the end ; let defer_this_arg = (HsValArg arg, Just (arg_ty, n)) @@ -1429,6 +1429,11 @@ tcArgs fun orig_fun_ty fun_orig orig_args res_ty herald text "Cannot apply expression of type" <+> quotes (ppr ty) $$ text "to a visible type argument" <+> quotes (ppr arg) } +tcExpNoSigmaTyVars :: ExpRhoType -> Bool +tcExpNoSigmaTyVars (Check ty') + = tcNoSigmaTyVars ty' +tcExpNoSigmaTyVars _ = False + tcIsGuardingArg :: HsExpr GhcRn -> TcM Bool tcIsGuardingArg (HsVar _ (L _ name)) = do { (_, ty) <- tcInferId name @@ -1446,7 +1451,7 @@ tcIsGuardingArg (SectionL {}) = return True tcIsGuardingArg (OpApp {}) = return True -tcIsGuardingArg +tcIsGuardingArg _ = return False {- Note [Required quantifiers in the type of a term]