[project @ 2001-09-07 12:44:30 by simonpj]
authorsimonpj <unknown>
Fri, 7 Sep 2001 12:44:30 +0000 (12:44 +0000)
committersimonpj <unknown>
Fri, 7 Sep 2001 12:44:30 +0000 (12:44 +0000)
commit991a868b891c98cd58baf59cab423355a6b7025e
treea500cab0762795ae20176a4611d27c4038f155fd
parent66a9fc6c62d7ff54ab334bcf919a42a8ee4624dd
[project @ 2001-09-07 12:44:30 by simonpj]
----------------------------------------
Make dict funs and default methods
into LocalIds only at their binding site
----------------------------------------
        [part of 3 related commits]

There's a long comment about this with MkId.mkDefaultMethodId,
which I reproduce below.

While I was at it, I renamed setIdNoDiscard to setIdLocalExported.
Which is hardly an improvement, I'm afraid.  This renaming touches
Var.lhs, Id.lhs, SimplCore.lhs
in a trivial way.

---------------------

Dict funs and default methods are *not* ImplicitIds.  Their definition
involves user-written code, so we can't figure out their strictness etc
based on fixed info, as we can for constructors and record selectors (say).

We build them as GlobalIds, but when in the module where they are
bound, we turn the Id at the *binding site* into an exported LocalId.
This ensures that they are taken to account by free-variable finding
and dependency analysis (e.g. CoreFVs.exprFreeVars).   The simplifier
will propagate the LocalId to all occurrence sites.

Why shouldn't they be bound as GlobalIds?  Because, in particular, if
they are globals, the specialiser floats dict uses above their defns,
which prevents good simplifications happening.  Also the strictness
analyser treats a occurrence of a GlobalId as imported and assumes it
contains strictness in its IdInfo, which isn't true if the thing is
bound in the same module as the occurrence.

It's OK for dfuns to be LocalIds, because we form the instance-env to
pass on to the next module (md_insts) in CoreTidy, afer tidying
and globalising the top-level Ids.

BUT make sure they are *exported* LocalIds (setIdLocalExported) so
that they aren't discarded by the occurrence analyser.
ghc/compiler/basicTypes/Id.lhs
ghc/compiler/basicTypes/Var.lhs
ghc/compiler/simplCore/SimplCore.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcInstDcls.lhs