[project @ 2002-02-13 15:19:17 by simonpj]
authorsimonpj <unknown>
Wed, 13 Feb 2002 15:19:21 +0000 (15:19 +0000)
committersimonpj <unknown>
Wed, 13 Feb 2002 15:19:21 +0000 (15:19 +0000)
commit711e4d7a4d65472a3a1fb35bcad8e1c9a109c728
treed91657c63b69b5abd83ef6f43c52f973aab636a3
parente70309951a888dfa8629b2e07dbc30795550f868
[project @ 2002-02-13 15:19:17 by simonpj]
----------------------------------
Do the Right Thing for TyCons where we
can't see all their constructors.
----------------------------------

Inside a TyCon, three things can happen

1. GHC knows all the constructors, and has them to hand.
   (Nowadays, there may be zero constructors.)

2. GHC knows all the constructors, but has declined to slurp
   them all in, to avoid sucking in more declarations than
   necessary.  All we remember is the number of constructors,
   so we can get the return convention right.

3. GHC doesn't know anything. This happens *only* for decls
   coming from .hi-boot files, where the programmer declines to
   supply a representation.

Until now, these three cases have been conflated together.  Matters
are worse now that a TyCon really can have zero constructors.  In
fact, by confusing (3) with (1) we can actually generate bogus code.

With this commit, the dataCons field of a TyCon is of type:

data DataConDetails datacon
  = DataCons [datacon] -- Its data constructors, with fully polymorphic types
-- A type can have zero constructors

  | Unknown -- We're importing this data type from an hi-boot file
-- and we don't know what its constructors are

  | HasCons Int -- In a quest for compilation speed we have imported
-- only the number of constructors (to get return
-- conventions right) but not the constructors themselves

This says exactly what is going on.  There are lots of consequential small
changes.
21 files changed:
ghc/compiler/basicTypes/DataCon.lhs
ghc/compiler/ghci/InteractiveUI.hs
ghc/compiler/hsSyn/HsDecls.lhs
ghc/compiler/main/HscStats.lhs
ghc/compiler/main/HscTypes.lhs
ghc/compiler/main/MkIface.lhs
ghc/compiler/parser/Parser.y
ghc/compiler/parser/RdrHsSyn.lhs
ghc/compiler/prelude/PrelRules.lhs
ghc/compiler/prelude/TysWiredIn.lhs
ghc/compiler/rename/ParseIface.y
ghc/compiler/rename/RnHsSyn.lhs
ghc/compiler/rename/RnIfaces.lhs
ghc/compiler/rename/RnSource.lhs
ghc/compiler/simplCore/SimplUtils.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcTyClsDecls.lhs
ghc/compiler/typecheck/TcTyDecls.lhs
ghc/compiler/types/Generics.lhs
ghc/compiler/types/TyCon.lhs
ghc/compiler/types/Variance.lhs