Make HscTypes.tyThingId respond not panic on ADataCon
authorsimonpj@microsoft.com <unknown>
Tue, 4 Dec 2007 15:29:03 +0000 (15:29 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 4 Dec 2007 15:29:03 +0000 (15:29 +0000)
compiler/main/HscTypes.lhs

index 0a6ad3d..5e6a33e 100644 (file)
@@ -96,7 +96,7 @@ import Type
 
 import Class           ( Class, classSelIds, classATs, classTyCon )
 import TyCon
-import DataCon         ( DataCon, dataConImplicitIds )
+import DataCon         ( DataCon, dataConImplicitIds, dataConWrapId )
 import PrelNames       ( gHC_PRIM )
 import Packages hiding ( Version(..) )
 import DynFlags                ( DynFlags(..), isOneShot, HscTarget (..) )
@@ -959,8 +959,9 @@ tyThingDataCon (ADataCon dc) = dc
 tyThingDataCon other        = pprPanic "tyThingDataCon" (pprTyThing other)
 
 tyThingId :: TyThing -> Id
-tyThingId (AnId id) = id
-tyThingId other     = pprPanic "tyThingId" (pprTyThing other)
+tyThingId (AnId id)     = id
+tyThingId (ADataCon dc) = dataConWrapId dc
+tyThingId other         = pprPanic "tyThingId" (pprTyThing other)
 \end{code}
 
 %************************************************************************