diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-09-30 14:48:47 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-08 13:25:37 -0400 |
commit | bf02c26402cf926d41c006ab930ed9747e92a373 (patch) | |
tree | 484b0fce35c10a475509d6c07abbb82ddcb8dc6e /testsuite | |
parent | 6a5c249d54d542d765ddbd80161ef4796c781de1 (diff) | |
download | haskell-bf02c26402cf926d41c006ab930ed9747e92a373.tar.gz |
Mark newtype constructors as used in the Coercible solver (#10347)
Currently, newtype constructors are not marked as used when they are
accessed under the hood by uses of `coerce`, as described in #10347.
This fixes #10347 by co-opting the `tcg_keep` field of `TcGblEnv`
to track uses of newtype constructors in the `Coercible` solver.
See `Note [Tracking unused binding and imports]` in `TcRnTypes`.
Since #10347 is fixed, I was able to simplify the code in `TcDeriv`
slightly, as the hack described in
`Note [Newtype deriving and unused constructors]`
is no longer necessary.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T10347.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T10347.hs b/testsuite/tests/typecheck/should_compile/T10347.hs index ca9fdd98cc..702a000bf3 100644 --- a/testsuite/tests/typecheck/should_compile/T10347.hs +++ b/testsuite/tests/typecheck/should_compile/T10347.hs @@ -1,10 +1,13 @@ -{-# OPTIONS_GHC -fwarn-unused-binds #-} - -module T10347 (N, mkN) where +{-# OPTIONS_GHC -Wunused-imports -Wunused-top-binds #-} +module T10347 (N, mkN, mkSum) where import Data.Coerce +import Data.Monoid (Sum(Sum)) newtype N a = MkN Int mkN :: Int -> N a -mkN = coerce +mkN = coerce -- Should mark MkN (a locally defined constructor) as used + +mkSum :: Int -> Sum Int +mkSum = coerce -- Should mark Sum (an imported constructor) as used diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index ee38a1abea..7594265db6 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -476,7 +476,7 @@ test('T10632', normal, compile, ['-Wredundant-constraints']) test('T10642', normal, compile, ['']) test('T10744', normal, compile, ['']) test('update-existential', normal, compile, ['']) -test('T10347', expect_broken(10347), compile, ['']) +test('T10347', normal, compile, ['']) test('T11056', normal, compile, ['']) test('T10770a', expect_broken(10770), compile, ['']) test('T10770b', expect_broken(10770), compile, ['']) |