From fb5cd9d6d6185afe6d4ef2f3df3f895b6d0abf4c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 27 Feb 2017 23:48:30 -0800 Subject: 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 Test Plan: validate Reviewers: simonpj, bgamari, austin Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D3236 --- testsuite/tests/typecheck/should_compile/Makefile | 6 ++++++ testsuite/tests/typecheck/should_compile/Tc271.hs | 10 ++++++++++ testsuite/tests/typecheck/should_compile/Tc271.hs-boot | 5 +++++ testsuite/tests/typecheck/should_compile/Tc271a.hs | 5 +++++ testsuite/tests/typecheck/should_compile/all.T | 1 + 5 files changed, 27 insertions(+) create mode 100644 testsuite/tests/typecheck/should_compile/Tc271.hs create mode 100644 testsuite/tests/typecheck/should_compile/Tc271.hs-boot create mode 100644 testsuite/tests/typecheck/should_compile/Tc271a.hs (limited to 'testsuite/tests') 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, ['']) -- cgit v1.2.1