@@ -280,21 +280,36 @@ typeCheckModule (Module ss coms mn decls (Just exps)) = warnAndRethrow (addHint
280280 where
281281
282282 checkMemberExport :: (Type -> [DeclarationRef]) -> DeclarationRef -> Check ()
283+ checkMemberExport extract dr@(TypeRef name dctors) = do
284+ env <- getEnv
285+ case M.lookup (Qualified (Just mn) name) (typeSynonyms env) of
286+ Nothing -> return ()
287+ Just (_, ty) -> checkExport dr extract ty
288+ case dctors of
289+ Nothing -> return ()
290+ Just dctors' -> forM_ dctors' $ \dctor ->
291+ case M.lookup (Qualified (Just mn) dctor) (dataConstructors env) of
292+ Nothing -> return ()
293+ Just (_, _, ty, _) -> checkExport dr extract ty
294+ return ()
283295 checkMemberExport extract dr@(ValueRef name) = do
284296 ty <- lookupVariable mn (Qualified (Just mn) name)
285− case filter (not . exported) (extract ty) of
286− [] -> return ()
287− hidden -> throwError . errorMessage $ TransitiveExportError dr hidden
288− where
289− exported e = any (exports e) exps
290− exports (TypeRef pn1 _) (TypeRef pn2 _) = pn1 == pn2
291− exports (ValueRef id1) (ValueRef id2) = id1 == id2
292− exports (TypeClassRef pn1) (TypeClassRef pn2) = pn1 == pn2
293− exports (PositionedDeclarationRef _ _ r1) r2 = exports r1 r2
294− exports r1 (PositionedDeclarationRef _ _ r2) = exports r1 r2
295− exports _ _ = False
297+ checkExport dr extract ty
296298 checkMemberExport _ _ = return ()
297299
300+ checkExport :: DeclarationRef -> (Type -> [DeclarationRef]) -> Type -> Check ()
301+ checkExport dr extract ty = case filter (not . exported) (extract ty) of
302+ [] -> return ()
303+ hidden -> throwError . errorMessage $ TransitiveExportError dr hidden
304+ where
305+ exported e = any (exports e) exps
306+ exports (TypeRef pn1 _) (TypeRef pn2 _) = pn1 == pn2
307+ exports (ValueRef id1) (ValueRef id2) = id1 == id2
308+ exports (TypeClassRef pn1) (TypeClassRef pn2) = pn1 == pn2
309+ exports (PositionedDeclarationRef _ _ r1) r2 = exports r1 r2
310+ exports r1 (PositionedDeclarationRef _ _ r2) = exports r1 r2
311+ exports _ _ = False
312+
298313 -- Check that all the type constructors defined in the current module that appear in member types
299314 -- have also been exported from the module
300315 checkTypesAreExported :: DeclarationRef -> Check ()