[project @ 2001-12-06 10:45:42 by simonpj]
authorsimonpj <unknown>
Thu, 6 Dec 2001 10:45:43 +0000 (10:45 +0000)
committersimonpj <unknown>
Thu, 6 Dec 2001 10:45:43 +0000 (10:45 +0000)
commit61fae1d3fb61c5f53c3fbcb94afe7c548ad31591
treeb6f7d88797610980dcf504be8f98328f817269f7
parent94cf74b8ae28075496a67c1a83df630bc6cabc7c
[project @ 2001-12-06 10:45:42 by simonpj]
--------------------------
Fix the instance-decl wart
--------------------------

This commit implements the (proposed) H98 rule for
resolving the class-method name in an instance decl.

module M( C( op1, op2 ) ) where
-- NB: op3 not exported
  class C a where
    op1, op2, op3 :: a -> a

module N where
  import qualified M as P( C )
  import qualified M as Q hiding( op2 )

  instance P.C Int where
    op1 x = x
    -- op2, op3 both illegal here

The point is that
  a) only methods that can be named are legal
     in the instance decl
(so op2, op3 are not legal)
  b) but it doesn't matter *how* they can be named
(in this case Q.op1 is in scope, though
the class is called P.C)

The AvailEnv carries the information about what's in scope,
so we now have to carry it around in the monad, so that
instance decl bindings can see it.  Quite simple really.

Same deal for export lists. E.g.

module N( P.C( op1 ) ) where
  import qualified M as P( C )
  import qualified M as Q hiding( op2 )

Actually this is what GHC has always implemented!
ghc/compiler/hsSyn/HsTypes.lhs
ghc/compiler/main/HscTypes.lhs
ghc/compiler/rename/Rename.lhs
ghc/compiler/rename/RnBinds.lhs
ghc/compiler/rename/RnEnv.lhs
ghc/compiler/rename/RnHiFiles.lhs
ghc/compiler/rename/RnMonad.lhs
ghc/compiler/rename/RnNames.lhs
ghc/compiler/rename/RnSource.lhs
ghc/compiler/typecheck/TcDeriv.lhs