Fix newtype deriving properly (un-doing Audreys patch)
authorsimonpj@microsoft.com <unknown>
Mon, 25 Sep 2006 12:13:51 +0000 (12:13 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 25 Sep 2006 12:13:51 +0000 (12:13 +0000)
commit171d4582f4b9a8e0f11f8738079accbb22bafdcb
treee9e9d42e1fa23dc65b560f7057309c481b57ed93
parent57610c7b3369dfc0fcf1ee311a1ed10cfe13f7d4
Fix newtype deriving properly (un-doing Audreys patch)

The newtype-deriving mechanism generates a HsSyn case expression looking
like this
case (d `cast` co) of { ... }
That is, the case expression scrutinises a dictionary.  This is
otherwise never seen in HsSyn, and it made the desugarer
(Check.get_unused_cons) crash in tcTyConAppTyCon.

It would really be better to generate Core in TcInstDecls (the newtype
deriving part) but I'm not going to do that today.  Instead, I made
Check.get_unused_cons a bit more robust.

Audrey tried to fix this over the weekend, but her fix was, alas, utterly
bogus, which caused mysterious failures later.  I completely undid this
change.

Anyway it should work now!
compiler/deSugar/Check.lhs
compiler/typecheck/TcClassDcl.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcType.lhs