diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-05-06 07:21:33 (GMT) |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-05-06 07:26:10 (GMT) |
commit | 990ce8c95bf99e79c728f90aa68bff101867c073 (patch) | |
tree | c34f801f3b200b55479f8e9e0acccf21713e6131 | |
parent | 94f2ee1e03d5a4baf29d2893b0efd2bd155b0bc2 (diff) | |
download | ghc-990ce8c95bf99e79c728f90aa68bff101867c073.zip ghc-990ce8c95bf99e79c728f90aa68bff101867c073.tar.gz ghc-990ce8c95bf99e79c728f90aa68bff101867c073.tar.bz2 |
Use tcExtendGlobalValEnv for default methods
We add the default method Ids to the global type envt in
tcAddImplicits; and then again in tcInstDcls2 (for reasons
explained there). But for some reason in the latter case
we added them to the /local/ type envt, via tcExtendLetEnv.
This patch just uses tcExtendGlobalValEnv consistently
for both.
(I found this when reviewing slightly-awkward code from Facundo's
static-form error-message patch; turned out that the awkwardness
came back to this inconsistency in the handling of default
methods.)
-rw-r--r-- | compiler/typecheck/TcInstDcls.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs index 483d322..59ddaee 100644 --- a/compiler/typecheck/TcInstDcls.hs +++ b/compiler/typecheck/TcInstDcls.hs @@ -731,8 +731,9 @@ tcInstDecls2 tycl_decls inst_decls -- (b) instance declarations ; let dm_ids = collectHsBindsBinders dm_binds -- Add the default method Ids (again) + -- (they were arready added in TcTyDecls.tcAddImplicits) -- See Note [Default methods and instances] - ; inst_binds_s <- tcExtendLetEnv TopLevel TopLevel dm_ids $ + ; inst_binds_s <- tcExtendGlobalValEnv dm_ids $ mapM tcInstDecl2 inst_decls -- Done @@ -742,7 +743,7 @@ tcInstDecls2 tycl_decls inst_decls See Note [Default methods and instances] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The default method Ids are already in the type environment (see Note -[Default method Ids and Template Haskell] in TcTyClsDcls), BUT they +[Default method Ids and Template Haskell] in TcTyDcls), BUT they don't have their InlinePragmas yet. Usually that would not matter, because the simplifier propagates information from binding site to use. But, unusually, when compiling instance decls we *copy* the |