diff options
Diffstat (limited to 'testsuite/tests/warnings')
9 files changed, 75 insertions, 2 deletions
diff --git a/testsuite/tests/warnings/should_compile/T10890/A.hs b/testsuite/tests/warnings/should_compile/T10890/A.hs new file mode 100644 index 0000000000..c88ccc5b68 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/A.hs @@ -0,0 +1,4 @@ +module A where + +class A a where + has :: a diff --git a/testsuite/tests/warnings/should_compile/T10890/B.hs b/testsuite/tests/warnings/should_compile/T10890/B.hs new file mode 100644 index 0000000000..cfc279019a --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/B.hs @@ -0,0 +1,4 @@ +module B where + +class B a where + has :: a diff --git a/testsuite/tests/warnings/should_compile/T10890/Base.hs b/testsuite/tests/warnings/should_compile/T10890/Base.hs new file mode 100644 index 0000000000..f56bd9ad60 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/Base.hs @@ -0,0 +1,6 @@ +module Base (AClass(..), BClass()) where + +import Extends (BClass ()) + +class AClass a where + has :: a diff --git a/testsuite/tests/warnings/should_compile/T10890/Extends.hs b/testsuite/tests/warnings/should_compile/T10890/Extends.hs new file mode 100644 index 0000000000..a81013e490 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/Extends.hs @@ -0,0 +1,4 @@ +module Extends where + +class BClass b where + has :: b diff --git a/testsuite/tests/warnings/should_compile/T10890/Makefile b/testsuite/tests/warnings/should_compile/T10890/Makefile new file mode 100644 index 0000000000..1c39d1c1fe --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/Makefile @@ -0,0 +1,3 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890.hs b/testsuite/tests/warnings/should_compile/T10890/T10890.hs new file mode 100644 index 0000000000..a6c0751927 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/T10890.hs @@ -0,0 +1,23 @@ +module Main 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 A (A (has)) +import B (B (has)) + +data Blah = Blah + +instance A Blah where + has = Blah + +instance B Blah where + has = Blah + +main :: IO () +main = return () diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890_1.hs b/testsuite/tests/warnings/should_compile/T10890/T10890_1.hs new file mode 100644 index 0000000000..7614ee3fa5 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/T10890_1.hs @@ -0,0 +1,22 @@ +module Main where + +import Base +import Extends + +-- Previously GHC was giving this false positive: +-- +-- T10890_1.hs:4:1: Warning: +-- The import of ‘Extends’ is redundant +-- except perhaps to import instances from ‘Extends’ +-- To import instances alone, use: import Extends() + +data Bar = Bar + +instance AClass Bar where + has = Bar + +instance BClass Bar where + has = Bar + +main :: IO () +main = return () diff --git a/testsuite/tests/warnings/should_compile/T10890/all.T b/testsuite/tests/warnings/should_compile/T10890/all.T new file mode 100644 index 0000000000..3e323f0ed0 --- /dev/null +++ b/testsuite/tests/warnings/should_compile/T10890/all.T @@ -0,0 +1,7 @@ +test('T10890', + extra_clean(['A.o', 'A.hi', 'B.o', 'B.hi']), + multimod_compile, ['T10890', '-v0 -fwarn-unused-imports']) + +test('T10890_1', + extra_clean(['Base.o', 'Base.hi', 'Extends.o', 'Extends.hi']), + multimod_compile, ['T10890_1', '-v0 -fwarn-unused-imports']) diff --git a/testsuite/tests/warnings/should_compile/T9178.stderr b/testsuite/tests/warnings/should_compile/T9178.stderr index c1e99bc516..d22f428763 100644 --- a/testsuite/tests/warnings/should_compile/T9178.stderr +++ b/testsuite/tests/warnings/should_compile/T9178.stderr @@ -1,8 +1,8 @@ [1 of 2] Compiling T9178DataType ( T9178DataType.hs, T9178DataType.o ) [2 of 2] Compiling T9178 ( T9178.hs, T9178.o ) -T9178.hs:8:10: warning: - Orphan instance: instance [safe] Show T9178_Type +T9178.hs:8:1: warning: + Orphan instance: instance Show T9178_Type To avoid this move the instance declaration to the module of the class or of the type, or wrap the type with a newtype and declare the instance on the new type. |