Don't warn about missing methods for instances in signatures.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Tue, 14 Feb 2017 18:16:04 +0000 (13:16 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 14 Feb 2017 21:57:31 +0000 (16:57 -0500)
Test Plan: validate

Reviewers: bgamari, austin, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, thomie

Differential Revision: https://phabricator.haskell.org/D3134

compiler/typecheck/TcClassDcl.hs
testsuite/tests/backpack/should_compile/all.T
testsuite/tests/backpack/should_compile/bkp52.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp52.stderr [new file with mode: 0644]

index 716aed3..3b9e6ac 100644 (file)
@@ -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)) }
index 31bbfcf..683d913 100644 (file)
@@ -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 (file)
index 0000000..b60cd70
--- /dev/null
@@ -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/bkp52.stderr b/testsuite/tests/backpack/should_compile/bkp52.stderr
new file mode 100644 (file)
index 0000000..5e67670
--- /dev/null
@@ -0,0 +1,5 @@
+[1 of 2] Processing p
+  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 )