- m_dc <- trIO$ tcRnRecoverDataCon hsc_env (infoPtr clos)
- case m_dc of
- Nothing -> panic "Can't find the DataCon for a term"
+ Right dcname <- dataConInfoPtrToName (infoPtr clos)
+ (_,mb_dc) <- tryTcErrs (tcLookupDataCon dcname)
+ case mb_dc of
+ Nothing -> do -- This can happen for private constructors compiled -O0
+ -- where the .hi descriptor does not export them
+ -- In such case, we return a best approximation:
+ -- ignore the unpointed args, and recover the pointeds
+ -- This preserves laziness, and should be safe.
+ let tag = showSDoc (ppr dcname)
+ vars <- replicateM (length$ elems$ ptrs clos)
+ (newVar (liftedTypeKind))
+ subTerms <- sequence [appArr (go tv tv) (ptrs clos) i
+ | (i, tv) <- zip [0..] vars]
+ return (Term tv (Left ('<' : tag ++ ">")) a subTerms)