Commit 154889db authored by Ryan Scott's avatar Ryan Scott Committed by Marge Bot
Browse files

Add regression test for #22151

Issue #22151 was coincidentally fixed in commit
aed1974e (`Refactor the treatment of loopy
superclass dicts`). This adds a regression test to ensure that the issue
remains fixed.

Fixes #22151.
parent f058e367
Pipeline #61807 canceled with stages
in 14 seconds
{-# LANGUAGE UndecidableInstances #-}
module T22151 where
import Control.Monad.IO.Class (MonadIO(liftIO))
class (Applicative m, Monad m) => C m where
m :: m ()
-- This should not emit a -Wredundant-constraints warning. This is because
-- GHC should not expand the superclasses of the Given constraint `MonadIO m`
-- given that it is not Paterson-smaller than the instance head `C m`. (See
-- Note [Recursive superclasses] in GHC.Tc.TyCl.Instance for more on what
-- "Paterson-smaller" means.) As a result, we must provide the `Applicative m`
-- and `Monad m` constraints explicitly.
instance (Applicative m, Monad m, MonadIO m) => C m where
m = liftIO (pure ())
......@@ -53,4 +53,5 @@ test('DerivingTypeable', normal, compile, ['-Wderiving-typeable'])
test('T18862a', normal, compile, [''])
test('T18862b', normal, compile, [''])
test('T20312', normal, compile,['-Wall'])
test('T22151', normal, compile, ['-Wredundant-constraints'])
test('T22759', normal, compile, [''])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment