summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-10-28 17:16:55 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2015-10-30 09:45:47 +0000
commit9376249b6b78610db055a10d05f6592d6bbbea2f (patch)
tree67526c534565bcf9e20fd0872fc87a8be2e74f8a /testsuite
parent9b3a0588e7523db54443270005ba2c6016e56ab8 (diff)
downloadhaskell-9376249b6b78610db055a10d05f6592d6bbbea2f.tar.gz
Fix unused-import stuff in a better way
The fix for Trac #10890 in commit 1818b48, namely Fix incorrect import warnings when methods with identical names are imported was wrong, as demonstrated by the new test T10890_2. It suppressed far too many warnings! This patch fixes the original problem in a different way, by making RdrName.greUsedRdrName a bit cleverer. But this too is not really the Right Thing. I think the Right Thing is to store the /GRE/ in the tcg_used_rdrnames, not the /RdrName/. That would be a lot simpler and more direct. But one step at a time.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/module/mod177.stderr2
-rw-r--r--testsuite/tests/warnings/should_compile/T10890/T10890_2.hs17
-rw-r--r--testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr5
-rw-r--r--testsuite/tests/warnings/should_compile/T10890/T10890_2A.hs4
-rw-r--r--testsuite/tests/warnings/should_compile/T10890/T10890_2B.hs4
-rw-r--r--testsuite/tests/warnings/should_compile/T10890/all.T4
6 files changed, 35 insertions, 1 deletions
diff --git a/testsuite/tests/module/mod177.stderr b/testsuite/tests/module/mod177.stderr
index 21bf46cf9c..d695eead60 100644
--- a/testsuite/tests/module/mod177.stderr
+++ b/testsuite/tests/module/mod177.stderr
@@ -1,5 +1,5 @@
-mod177.hs:4:1: Warning:
+mod177.hs:5:1: warning:
The import of ‘Data.Maybe’ is redundant
except perhaps to import instances from ‘Data.Maybe’
To import instances alone, use: import Data.Maybe()
diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890_2.hs b/testsuite/tests/warnings/should_compile/T10890/T10890_2.hs
new file mode 100644
index 0000000000..7469639377
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10890/T10890_2.hs
@@ -0,0 +1,17 @@
+module T10890_2 where
+
+-- Previously GHC was printing this warning:
+--
+-- Main.hs:5:1: Warning:
+-- The import of ‘A.has’ from module ‘A’ is redundant
+--
+-- Main.hs:6:1: Warning:
+-- The import of ‘B.has’ from module ‘B’ is redundant
+
+import T10890_2A (A (has))
+import T10890_2B (B (has))
+
+data Blah = Blah
+
+instance A Blah where
+ has = Blah
diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr b/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr
new file mode 100644
index 0000000000..a693c47a03
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr
@@ -0,0 +1,5 @@
+
+T10890_2.hs:12:1: warning:
+ The import of ‘T10890_2B’ is redundant
+ except perhaps to import instances from ‘T10890_2B’
+ To import instances alone, use: import T10890_2B()
diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890_2A.hs b/testsuite/tests/warnings/should_compile/T10890/T10890_2A.hs
new file mode 100644
index 0000000000..82ee73cb26
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10890/T10890_2A.hs
@@ -0,0 +1,4 @@
+module T10890_2A where
+
+class A a where
+ has :: a
diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890_2B.hs b/testsuite/tests/warnings/should_compile/T10890/T10890_2B.hs
new file mode 100644
index 0000000000..f143e3032c
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T10890/T10890_2B.hs
@@ -0,0 +1,4 @@
+module T10890_2B where
+
+class B a where
+ has :: a
diff --git a/testsuite/tests/warnings/should_compile/T10890/all.T b/testsuite/tests/warnings/should_compile/T10890/all.T
index 3e323f0ed0..d5c6894517 100644
--- a/testsuite/tests/warnings/should_compile/T10890/all.T
+++ b/testsuite/tests/warnings/should_compile/T10890/all.T
@@ -5,3 +5,7 @@ test('T10890',
test('T10890_1',
extra_clean(['Base.o', 'Base.hi', 'Extends.o', 'Extends.hi']),
multimod_compile, ['T10890_1', '-v0 -fwarn-unused-imports'])
+
+test('T10890_2',
+ extra_clean(['T10890_2A.o', 'T10890_2A.hi', 'T10890_2B.o', 'T10890_2B.hi']),
+ multimod_compile, ['T10890_2', '-v0 -fwarn-unused-imports'])