summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2017-02-27 23:48:30 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2017-03-02 15:59:02 -0800
commitfb5cd9d6d6185afe6d4ef2f3df3f895b6d0abf4c (patch)
treeba77538afca8be56c6c4ea77e6f7afda817df418 /testsuite/tests
parente71068617d15b0fea65fe24e20c0ab0db9fc660f (diff)
downloadhaskell-fb5cd9d6d6185afe6d4ef2f3df3f895b6d0abf4c.tar.gz
Properly represent abstract classes in Class and IfaceDecl
Summary: Previously, abstract classes looked very much like normal classes, except that they happened to have no methods, superclasses or ATs, and they came from boot files. This patch gives abstract classes a proper representation in Class and IfaceDecl, by moving the things which are never defined for abstract classes into ClassBody/IfaceClassBody. Because Class is abstract, this change had ~no disruption to any of the code in GHC; if you ask about the methods of an abstract class, we'll just give you an empty list. This also fixes a bug where abstract type classes were incorrectly treated as representationally injective (they're not!) Fixes #13347, and a TODO in the code. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, bgamari, austin Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D3236
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/typecheck/should_compile/Makefile6
-rw-r--r--testsuite/tests/typecheck/should_compile/Tc271.hs10
-rw-r--r--testsuite/tests/typecheck/should_compile/Tc271.hs-boot5
-rw-r--r--testsuite/tests/typecheck/should_compile/Tc271a.hs5
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
5 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/Makefile b/testsuite/tests/typecheck/should_compile/Makefile
index 7af8ae146d..cb8269ae15 100644
--- a/testsuite/tests/typecheck/should_compile/Makefile
+++ b/testsuite/tests/typecheck/should_compile/Makefile
@@ -50,3 +50,9 @@ Tc267:
'$(TEST_HC)' $(TEST_HC_OPTS) -c Tc267b.hs-boot
'$(TEST_HC)' $(TEST_HC_OPTS) -c Tc267a.hs
'$(TEST_HC)' $(TEST_HC_OPTS) -c Tc267b.hs
+
+Tc271:
+ $(RM) -f Tc271.hi-boot Tc271.o-boot Tc271a.hi Tc271a.o Tc271.hi Tc271.o
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c Tc271.hs-boot
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c Tc271a.hs
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c Tc271.hs
diff --git a/testsuite/tests/typecheck/should_compile/Tc271.hs b/testsuite/tests/typecheck/should_compile/Tc271.hs
new file mode 100644
index 0000000000..5f0c3f0a1a
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/Tc271.hs
@@ -0,0 +1,10 @@
+module Tc271 where
+
+import Tc271a
+
+class K a where
+ f :: a -> a
+ g :: a -> a
+
+h :: K a => a -> a
+h = f . g . h2
diff --git a/testsuite/tests/typecheck/should_compile/Tc271.hs-boot b/testsuite/tests/typecheck/should_compile/Tc271.hs-boot
new file mode 100644
index 0000000000..9f15065a11
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/Tc271.hs-boot
@@ -0,0 +1,5 @@
+module Tc271 where
+
+class K a where
+
+h :: K a => a -> a
diff --git a/testsuite/tests/typecheck/should_compile/Tc271a.hs b/testsuite/tests/typecheck/should_compile/Tc271a.hs
new file mode 100644
index 0000000000..b5fd136599
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/Tc271a.hs
@@ -0,0 +1,5 @@
+module Tc271a where
+import {-# SOURCE #-} Tc271
+
+h2 :: K a => a -> a
+h2 = h
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index e9aacd8678..837a0d7995 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -343,6 +343,7 @@ test('Tc267', [extra_files(['Tc267a.hs', 'Tc267b.hs', 'Tc267a.hs-boot', 'Tc267b.
test('tc268', normal, compile, [''])
test('tc269', normal, compile, [''])
test('tc270', normal, compile, [''])
+test('Tc271', [extra_files(['Tc271a.hs', 'Tc271.hs', 'Tc271.hs-boot'])], run_command, ['$MAKE -s --no-print-directory Tc271'])
test('GivenOverlapping', normal, compile, [''])
test('GivenTypeSynonym', normal, compile, [''])