Skip to content

Put the generic-default type in the Class

This is an internal GHC refactoring ticket. Consider

{-# LANGUAGE DefaultSignatures #-}
class C a where
  op :: a -> a -> Bool
  default op :: Ord a => a -> a -> Bool
  op x y = x < y

The Class object for C has a ClassOpItem that specifies

  • the name op
  • the type of the method a -> a -> Bool
  • that op has a generic-default signature

BUT it does not contain the actual signature Ord a => a -> a -> Bool. That's really wrong; it is certainly part of the definition of the class, and we should print it out when we say :info C in ghci.

Instead this type is kept solely in the top-level generic-default Id binding. But that means that default-method Ids and generic-default method Ids are treated differently; see gen_dm_ids in tcTyClDecl1 in TcTyClsDecls, and mkDefaultMethodIds in TcTyDecls.

We should treat them uniformly. I know how but have too much in flight to do it immediately.

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information