From c3c2961674cfdb1fd7ca345e750fdc27b2858266 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 23 Jan 2003 16:13:43 +0000 Subject: [PATCH] [project @ 2003-01-23 16:13:43 by simonmar] We have to desugar polymorphic FFI declarations properly, too. (companion commit to rev. 1.84 of TcType.lhs). --- ghc/compiler/deSugar/DsCCall.lhs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/deSugar/DsCCall.lhs b/ghc/compiler/deSugar/DsCCall.lhs index beadd17..0fcfdd5 100644 --- a/ghc/compiler/deSugar/DsCCall.lhs +++ b/ghc/compiler/deSugar/DsCCall.lhs @@ -29,7 +29,8 @@ import ForeignCall ( ForeignCall, CCallTarget(..) ) import TcType ( tcSplitTyConApp_maybe ) import Type ( Type, isUnLiftedType, mkFunTys, mkFunTy, tyVarsOfType, mkForAllTys, mkTyConApp, - isPrimitiveType, splitTyConApp_maybe, splitNewType_maybe + isPrimitiveType, splitTyConApp_maybe, + splitNewType_maybe, splitForAllTy_maybe, ) import PrimOp ( PrimOp(..) ) @@ -309,6 +310,14 @@ resultWrapper result_ty in (maybe_ty, \e -> mkCoerce2 result_ty rep_ty (wrapper e)) + -- The type might contain foralls (eg. for dummy type arguments, + -- referring to 'Ptr a' is legal). + | Just (tyvar, rest) <- splitForAllTy_maybe result_ty + = let + (maybe_ty, wrapper) = resultWrapper rest + in + (maybe_ty, \e -> Lam tyvar (wrapper e)) + -- Data types with a single constructor, which has a single arg | Just (tycon, tycon_arg_tys, data_con, data_con_arg_tys) <- splitProductType_maybe result_ty, dataConSourceArity data_con == 1 -- 1.7.10.4