[commit: ghc] master: Don't warn about missing methods for instances in signatures. (93e65c8)

git at git.haskell.org git at git.haskell.org
Tue Feb 14 21:57:56 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/93e65c8ab7b468d69bf24d9dc2f197d24e5166f4/ghc

>---------------------------------------------------------------

commit 93e65c8ab7b468d69bf24d9dc2f197d24e5166f4
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Tue Feb 14 13:16:04 2017 -0500

    Don't warn about missing methods for instances in signatures.
    
    Test Plan: validate
    
    Reviewers: bgamari, austin, dfeuer
    
    Reviewed By: dfeuer
    
    Subscribers: dfeuer, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3134


>---------------------------------------------------------------

93e65c8ab7b468d69bf24d9dc2f197d24e5166f4
 compiler/typecheck/TcClassDcl.hs                               |  4 +++-
 testsuite/tests/backpack/should_compile/all.T                  |  1 +
 testsuite/tests/backpack/should_compile/bkp52.bkp              | 10 ++++++++++
 .../backpack/should_compile/{bkp49.stderr => bkp52.stderr}     |  3 ++-
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcClassDcl.hs b/compiler/typecheck/TcClassDcl.hs
index 716aed3..3b9e6ac 100644
--- a/compiler/typecheck/TcClassDcl.hs
+++ b/compiler/typecheck/TcClassDcl.hs
@@ -516,7 +516,9 @@ warnMissingAT :: Name -> TcM ()
 warnMissingAT name
   = do { warn <- woptM Opt_WarnMissingMethods
        ; traceTc "warn" (ppr name <+> ppr warn)
-       ; warnTc (Reason Opt_WarnMissingMethods) warn  -- Warn only if -Wmissing-methods
+       ; hsc_src <- fmap tcg_src getGblEnv
+       -- Warn only if -Wmissing-methods AND not a signature
+       ; warnTc (Reason Opt_WarnMissingMethods) (warn && hsc_src /= HsigFile)
                 (text "No explicit" <+> text "associated type"
                     <+> text "or default declaration for     "
                     <+> quotes (ppr name)) }
diff --git a/testsuite/tests/backpack/should_compile/all.T b/testsuite/tests/backpack/should_compile/all.T
index 31bbfcf..683d913 100644
--- a/testsuite/tests/backpack/should_compile/all.T
+++ b/testsuite/tests/backpack/should_compile/all.T
@@ -43,6 +43,7 @@ test('bkp48', normal, backpack_compile, [''])
 test('bkp49', normal, backpack_compile, [''])
 test('bkp50', normal, backpack_compile, [''])
 test('bkp51', normal, backpack_compile, [''])
+test('bkp52', normal, backpack_compile, [''])
 
 test('T13149', expect_broken(13149), backpack_compile, [''])
 test('T13214', normal, backpack_compile, [''])
diff --git a/testsuite/tests/backpack/should_compile/bkp52.bkp b/testsuite/tests/backpack/should_compile/bkp52.bkp
new file mode 100644
index 0000000..b60cd70
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp52.bkp
@@ -0,0 +1,10 @@
+{-# LANGUAGE TypeFamilies #-}
+unit p where
+    module M where
+        class F a where
+            type T a :: *
+unit q where
+    dependency p
+    signature A where
+        import M
+        instance F Int
diff --git a/testsuite/tests/backpack/should_compile/bkp49.stderr b/testsuite/tests/backpack/should_compile/bkp52.stderr
similarity index 55%
copy from testsuite/tests/backpack/should_compile/bkp49.stderr
copy to testsuite/tests/backpack/should_compile/bkp52.stderr
index d8f64f0..5e67670 100644
--- a/testsuite/tests/backpack/should_compile/bkp49.stderr
+++ b/testsuite/tests/backpack/should_compile/bkp52.stderr
@@ -1,4 +1,5 @@
 [1 of 2] Processing p
-  [1 of 1] Compiling A[sig]           ( p/A.hsig, nothing )
+  Instantiating p
+  [1 of 1] Compiling M                ( p/M.hs, bkp52.out/p/M.o )
 [2 of 2] Processing q
   [1 of 1] Compiling A[sig]           ( q/A.hsig, nothing )



More information about the ghc-commits mailing list