Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / simplCore / should_compile / T14270a.hs
1 {-# LANGUAGE TypeApplications, ScopedTypeVariables, GADTs, RankNTypes,
2 PolyKinds, KindSignatures #-}
3 {-# OPTIONS_GHC -O2 #-} -- We are provoking a bug in SpecConstr
4
5 module T14270a where
6
7 import Data.Kind
8 import Data.Proxy
9
10 data T a = T1 (T a) | T2
11
12 data K (a :: k) where
13 K1 :: K (a :: Type)
14 K2 :: K a
15
16 f :: T (a :: Type) -> Bool
17 f (T1 x) = f x
18 f T2 = True
19
20 g :: forall (a :: k). K a -> T a -> Bool
21 g kv x = case kv of
22 K1 -> f @a T2 -- f @a (T1 x) gives a different crash
23 k2 -> True
24
25 -- The point here is that the call to f looks like
26 -- f @(a |> co) (T2 @(a |> co))
27 -- where 'co' is bound by the pattern match on K1
28 -- See Note [SpecConstr and casts] in SpecConstr