lintStgExpr (StgCase scrut _ _ bndr _ alts_type alts) = runMaybeT $ do
    _ <- MaybeT $ lintStgExpr scrut

    in_scope <- MaybeT $ liftM Just $
     case alts_type of
        AlgAlt tc    -> check_bndr tc >> return True
        PrimAlt tc   -> check_bndr tc >> return True
        UbxTupAlt _  -> return False -- Binder is always dead in this case
        PolyAlt      -> return True

    MaybeT $ addInScopeVars [bndr | in_scope] $
             lintStgAlts alts scrut_ty
  where
    scrut_ty          = idType bndr
    UnaryRep scrut_rep = repType scrut_ty -- Not used if scrutinee is unboxed tuple
    check_bndr tc = case tyConAppTyCon_maybe scrut_rep of
                        Just bndr_tc -> checkL (tc == bndr_tc) bad_bndr
                        Nothing      -> addErrL bad_bndr
                  where
                     bad_bndr = mkDefltMsg bndr tc
lintStgExpr (StgCase scrut _ _ bndr _ alts_type alts) = runMaybeT $ do
    _ <- MaybeT $ lintStgExpr scrut

    in_scope <- MaybeT $ liftM Just $
     case alts_type of
        AlgAlt tc    -> check_bndr tc >> return True
        PrimAlt tc   -> check_bndr tc >> return True
        UbxTupAlt _  -> return False -- Binder is always dead in this case
        PolyAlt      -> return True

    MaybeT $ addInScopeVars [bndr | in_scope] $
             lintStgAlts alts scrut_ty
  where
    scrut_ty          = idType bndr
    UnaryRep scrut_rep = repType scrut_ty -- Not used if scrutinee is unboxed tuple
    check_bndr tc = case tyConAppTyCon_maybe scrut_rep of
                        Just bndr_tc -> checkL (tc == bndr_tc) bad_bndr
                        Nothing      -> addErrL bad_bndr
                  where
                     bad_bndr = mkDefltMsg bndr tc
lintStgExpr (StgCase scrut _ _ bndr _ alts_type alts) = runMaybeT $ do
    _ <- MaybeT $ lintStgExpr scrut

    in_scope <- MaybeT $ liftM Just $
     case alts_type of
        AlgAlt tc    -> check_bndr tc >> return True
        PrimAlt tc   -> check_bndr tc >> return True
        UbxTupAlt _  -> return False -- Binder is always dead in this case
        PolyAlt      -> return True

    MaybeT $ addInScopeVars [bndr | in_scope] $
             lintStgAlts alts scrut_ty
  where
    scrut_ty          = idType bndr
    UnaryRep scrut_rep = repType scrut_ty -- Not used if scrutinee is unboxed tuple
    check_bndr tc = case tyConAppTyCon_maybe scrut_rep of
                        Just bndr_tc -> checkL (tc == bndr_tc) bad_bndr
                        Nothing      -> addErrL bad_bndr
                  where
                     bad_bndr = mkDefltMsg bndr tc