SafeHaskell: Don't throw -Wsafe warning if module is declared Safe
authorBen Gamari <ben@smart-cactus.org>
Fri, 14 Jun 2019 03:51:24 +0000 (23:51 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 24 Jun 2019 22:35:12 +0000 (18:35 -0400)
Fixes #16689.

(cherry picked from commit 29ec33cd3ee390e8006a88d34f5ea0ac236663d0)

compiler/main/HscMain.hs

index 9825ee4..879e6c7 100644 (file)
@@ -507,7 +507,9 @@ tcRnModule' sum save_rn_syntax mod = do
                  safe <- liftIO $ fst <$> readIORef (tcg_safeInfer tcg_res')
                  when safe $ do
                    case wopt Opt_WarnSafe dflags of
-                     True -> (logWarnings $ unitBag $
+                     True
+                       | safeHaskell dflags == Sf_Safe -> return ()
+                       | otherwise -> (logWarnings $ unitBag $
                               makeIntoWarning (Reason Opt_WarnSafe) $
                               mkPlainWarnMsg dflags (warnSafeOnLoc dflags) $
                               errSafe tcg_res')