Hannes Siebenhandl pushed to branch wip/fendor/has-field-hie at Glasgow Haskell Compiler / GHC

WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.

Deleted commits:

4 changed files:

Changes:

  • compiler/GHC/Iface/Ext/Types.hs
    ... ... @@ -616,17 +616,23 @@ data EvBindDep
    616 616
           -- ^ 'Name' of the record selector
    
    617 617
           Name
    
    618 618
           -- ^ 'Name' of the parent type.
    
    619
    +  | TypeableEvidence
    
    620
    +    -- ^ Evidence of a @Typeable@ constraint.
    
    621
    +      Name
    
    622
    +      -- ^ Name of the type the evidence was generated for.
    
    619 623
       deriving (Eq, Ord)
    
    620 624
     
    
    621 625
     instance Outputable EvBindDep where
    
    622 626
       ppr = \ case
    
    623 627
         EvidenceVar n -> ppr n
    
    624 628
         RecordField sel parent -> ppr sel <+> text "of Record" <+> ppr parent
    
    629
    +    TypeableEvidence n -> ppr n <+> text "bound by Typeable"
    
    625 630
     
    
    626 631
     evBindDepName :: EvBindDep -> Name
    
    627 632
     evBindDepName = \ case
    
    628 633
       EvidenceVar n -> n
    
    629 634
       RecordField selector _record -> selector
    
    635
    +  TypeableEvidence n -> n
    
    630 636
     
    
    631 637
     evBindDepHieName :: EvBindDep -> HieName
    
    632 638
     evBindDepHieName = toHieName . evBindDepName
    
    ... ... @@ -640,11 +646,15 @@ instance Binary EvBindDep where
    640 646
           putByte bh 1
    
    641 647
           put_ bh n
    
    642 648
           put_ bh sel
    
    649
    +    TypeableEvidence n -> do
    
    650
    +      putByte bh 2
    
    651
    +      put_ bh n
    
    643 652
     
    
    644 653
       get bh =
    
    645 654
         getByte bh >>= \ case
    
    646 655
           0 -> EvidenceVar <$> get bh
    
    647 656
           1 -> RecordField <$> get bh <*> get bh
    
    657
    +      2 -> TypeableEvidence <$> get bh
    
    648 658
           t -> fail $ "EvBindDep: Unknown tag: " ++ show t
    
    649 659
     
    
    650 660
     -- | Eq/Ord instances compare on the converted HieName,
    

  • testsuite/tests/hiefile/should_run/HieTypeable.hs
    1
    +module Main where
    
    2
    +
    
    3
    +import Data.Dynamic
    
    4
    +import Data.Typeable
    
    5
    +import TestUtils
    
    6
    +
    
    7
    +data Thing = Thing {field1 :: Char, field2 :: Bool}
    
    8
    +  deriving (Show, Eq)
    
    9
    +
    
    10
    +castFromDynamic :: Dynamic -> Maybe Thing
    
    11
    +castFromDynamic d = fromDynamic d
    
    12
    +                 -- ^ this is the point
    
    13
    +
    
    14
    +rep :: Thing -> TypeRep
    
    15
    +rep d = typeOf d
    
    16
    +      -- ^ this is the point
    
    17
    +
    
    18
    +points =
    
    19
    +  [ (11,21)
    
    20
    +  , (15,10)
    
    21
    +  ]
    
    22
    +
    
    23
    +main = do
    
    24
    +  (df, hf) <- readTestHie "HieTypeable.hie"
    
    25
    +  let refmap = generateReferencesMap $ getAsts $ hie_asts hf
    
    26
    +
    
    27
    +  traverse (explainEv df hf refmap) points
    
    28
    +  return ()

  • testsuite/tests/hiefile/should_run/HieTypeable.stdout
    1
    +==========================
    
    2
    +At point (11,21), we found:
    
    3
    +==========================
    
    4
    +┌
    
    5
    +│ $dTypeable at HieTypeable.hs:1:1, of type: Typeable Thing
    
    6
    +│     is an evidence variable bound by a let, depending on: [$dTypeable]
    
    7
    +│           with scope: ModuleScope
    
    8
    +│           
    
    9
    +│     Defined at <no location info>
    
    10
    +└
    
    11
    +|
    
    12
    +`- ┌
    
    13
    +   │ $dTypeable at HieTypeable.hs:1:1, of type: Typeable Thing
    
    14
    +   │     is an evidence variable bound by a let, depending on: []
    
    15
    +   │           with scope: ModuleScope
    
    16
    +   │           
    
    17
    +   │     Defined at <no location info>
    
    18
    +   └
    
    19
    +
    
    20
    +==========================
    
    21
    +At point (15,10), we found:
    
    22
    +==========================
    
    23
    +┌
    
    24
    +│ $dTypeable at HieTypeable.hs:1:1, of type: Typeable Thing
    
    25
    +│     is an evidence variable bound by a let, depending on: []
    
    26
    +│           with scope: ModuleScope
    
    27
    +│           
    
    28
    +│     Defined at <no location info>
    
    29
    +└
    
    30
    +

  • testsuite/tests/hiefile/should_run/all.T
    ... ... @@ -12,3 +12,4 @@ test('HieGadtConSigs', [extra_run_opts('"' + config.libdir + '"'), extra_files([
    12 12
     test('T25709', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
    
    13 13
     test('HasFieldQueries', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
    
    14 14
     test('NoFieldSelectorQueries', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
    
    15
    +test('HieTypeable', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])