Commit 8f6d2927 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Fix #12064 by making IfaceClass typechecking more lazy.



Summary:
Comes with a test based off of prog006.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2221

GHC Trac Issues: #12064
parent d7933cbc
......@@ -426,20 +426,23 @@ tc_iface_decl _parent ignore_prags
tc_sig :: IfaceClassOp -> IfL TcMethInfo
tc_sig (IfaceClassOp occ rdr_ty dm)
= do { op_name <- lookupIfaceTop occ
; ~(op_ty, dm') <- forkM (mk_op_doc op_name rdr_ty) $
do { ty <- tcIfaceType rdr_ty
; dm' <- tc_dm dm
; return (ty, dm') }
; let doc = mk_op_doc op_name rdr_ty
; op_ty <- forkM (doc <+> text "ty") $ tcIfaceType rdr_ty
-- Must be done lazily for just the same reason as the
-- type of a data con; to avoid sucking in types that
-- it mentions unless it's necessary to do so
; dm' <- tc_dm doc dm
; return (op_name, op_ty, dm') }
tc_dm :: Maybe (DefMethSpec IfaceType) -> IfL (Maybe (DefMethSpec Type))
tc_dm Nothing = return Nothing
tc_dm (Just VanillaDM) = return (Just VanillaDM)
tc_dm (Just (GenericDM ty)) = do { ty' <- tcIfaceType ty
; return (Just (GenericDM ty')) }
tc_dm :: SDoc
-> Maybe (DefMethSpec IfaceType)
-> IfL (Maybe (DefMethSpec Type))
tc_dm _ Nothing = return Nothing
tc_dm _ (Just VanillaDM) = return (Just VanillaDM)
tc_dm doc (Just (GenericDM ty))
= do { -- Must be done lazily to avoid sucking in types
; ty' <- forkM (doc <+> text "dm") $ tcIfaceType ty
; return (Just (GenericDM ty')) }
tc_at cls (IfaceAT tc_decl if_def)
= do ATyCon tc <- tc_iface_decl (Just cls) ignore_prags tc_decl
......
......@@ -363,7 +363,7 @@ tcRnModuleTcRnM hsc_env hsc_src
Nothing -> return tcg_env) ;
-- The new type env is already available to stuff slurped from
-- interface files, via TcEnv.updateGlobalTypeEnv
-- interface files, via TcEnv.setGlobalTypeEnv
-- It's important that this includes the stuff in checkHiBootIface,
-- because the latter might add new bindings for boot_dfuns,
-- which may be mentioned in imported unfoldings
......
{-# LANGUAGE ExistentialQuantification #-}
module T12064 where
import T12064a
data D = forall n. K n => DCon n
module T12064a where
import {-# SOURCE #-} T12064
class K a where
kfun :: D -> a
......@@ -515,3 +515,5 @@ test('T11811', normal, compile, [''])
test('T11793', normal, compile, [''])
test('T11348', normal, compile, [''])
test('T11947', normal, compile, [''])
test('T12064', extra_clean(['T12064.hi-boot', 'T12064.o-boot', 'T11062a.hi', 'T11062a.o']),
multimod_compile, ['T12064', '-v0'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment