Skip to content

Commit 193b15a

Browse files
committed
expose function flag to expose (=>, ->, -=>, ==>)
1 parent e5b42ac commit 193b15a

File tree

8 files changed

+27
-15
lines changed

8 files changed

+27
-15
lines changed

ghcide/src/Development/IDE/GHC/Compat/Core.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,13 @@ import GHC.Core.DataCon hiding (dataConExTyCoVars)
431431
import qualified GHC.Core.DataCon as DataCon
432432
import GHC.Core.FamInstEnv hiding (pprFamInst)
433433
import GHC.Core.InstEnv
434-
import GHC.Types.Unique.FM
434+
import GHC.Types.Unique.FM
435435
import GHC.Core.PatSyn
436436
import GHC.Core.Predicate
437437
import GHC.Core.TyCo.Ppr
438438
import qualified GHC.Core.TyCo.Rep as TyCoRep
439439
import GHC.Core.TyCon
440-
import GHC.Core.Type
440+
import GHC.Core.Type
441441
import GHC.Core.Unify
442442
import GHC.Core.Utils
443443
import GHC.Driver.CmdLine (Warn (..))
@@ -597,7 +597,7 @@ pattern RealSrcLoc x y = SrcLoc.RealSrcLoc x y
597597
pattern AvailTC :: Name -> [Name] -> [FieldLabel] -> Avail.AvailInfo
598598
#if __GLASGOW_HASKELL__ >= 907
599599
pattern AvailTC n names pieces <- Avail.AvailTC n ((,[]) -> (names,pieces))
600-
#else
600+
#else
601601
pattern AvailTC n names pieces <- Avail.AvailTC n ((\gres -> foldr (\gre (names, pieces) -> case gre of
602602
Avail.NormalGreName name -> (name: names, pieces)
603603
Avail.FieldGreName label -> (names, label:pieces)) ([], []) gres) -> (names, pieces))
@@ -606,14 +606,14 @@ pattern AvailTC n names pieces <- Avail.AvailTC n ((\gres -> foldr (\gre (names,
606606
pattern AvailName :: Name -> Avail.AvailInfo
607607
#if __GLASGOW_HASKELL__ >= 907
608608
pattern AvailName n <- Avail.Avail n
609-
#else
609+
#else
610610
pattern AvailName n <- Avail.Avail (Avail.NormalGreName n)
611611
#endif
612612

613613
pattern AvailFL :: FieldLabel -> Avail.AvailInfo
614614
#if __GLASGOW_HASKELL__ >= 907
615615
pattern AvailFL fl <- (const Nothing -> Just fl) -- this pattern always fails as this field was removed in 9.7
616-
#else
616+
#else
617617
pattern AvailFL fl <- Avail.Avail (Avail.FieldGreName fl)
618618
#endif
619619

@@ -630,8 +630,8 @@ pattern ExposePackage s a mr <- DynFlags.ExposePackage s a _ mr
630630
pattern ExposePackage s a mr = DynFlags.ExposePackage s a mr
631631
#endif
632632

633-
pattern FunTy :: Type -> Type -> Type
634-
pattern FunTy arg res <- TyCoRep.FunTy {ft_arg = arg, ft_res = res}
633+
pattern FunTy :: FunTyFlag -> Type -> Type -> Type
634+
pattern FunTy af arg res <- TyCoRep.FunTy {ft_af = af, ft_arg = arg, ft_res = res}
635635

636636
-- type HasSrcSpan x a = (GenLocated SrcSpan a ~ x)
637637
-- type HasSrcSpan x = () :: Constraint

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ namesInType (TyVarTy n) = [varName n]
346346
namesInType (AppTy a b) = getTypes [a,b]
347347
namesInType (TyConApp tc ts) = tyConName tc : getTypes ts
348348
namesInType (ForAllTy b t) = varName (binderVar b) : namesInType t
349-
namesInType (FunTy a b) = getTypes [a,b]
349+
namesInType (FunTy _ a b) = getTypes [a,b]
350350
namesInType (CastTy t _) = namesInType t
351351
namesInType (LitTy _) = []
352352
namesInType _ = []

plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Mappings.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ toLspTokenType tk = case tk of
5353
-- not sure if this is correct choice
5454
TTypeFamily -> SemanticTokenTypes_Interface
5555

56-
-- TNothing -> Nothing
5756

5857
lspTokenReverseMap :: Map.Map SemanticTokenTypes HsSemanticTokenType
5958
lspTokenReverseMap = Map.fromList $ map (\x -> (toLspTokenType x, x)) $ enumFrom minBound
@@ -90,11 +89,12 @@ tyThingSemantic ty = case ty of
9089

9190
isFunType :: Type -> Bool
9291
isFunType a = case a of
93-
ForAllTy _ t -> isFunType t
94-
-- Development.IDE.GHC.Compat.Core.FunTy(pattern synonym) hides FunTyFlag which is used to distinguish
92+
ForAllTy _ t -> isFunType t
93+
-- Development.IDE.GHC.Compat.Core.FunTy(pattern synonym), FunTyFlag which is used to distinguish
9594
-- (->, =>, etc..)
96-
FunTy _ _ -> True
97-
_x -> isFunTy a
95+
FunTy FTF_T_T _ _ -> True
96+
FunTy _ _ rhs -> isFunType rhs
97+
_x -> isFunTy a
9898

9999
hieKindFunMasksKind :: HieKind a -> HieFunMaskKind a
100100
hieKindFunMasksKind hieKind = case hieKind of

plugins/hls-semantic-tokens-plugin/test/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ semanticTokensFunctionTests =
179179
[ goldenWithSemanticTokens "functions" "TFunction",
180180
goldenWithSemanticTokens "local functions" "TFunctionLocal",
181181
goldenWithSemanticTokens "function in let binding" "TFunctionLet"
182+
, goldenWithSemanticTokens "negative case non-function with constraint" "TNoneFunctionWithConstraint"
182183
]
183184

184185
main :: IO ()

plugins/hls-semantic-tokens-plugin/test/testdata/TFunction.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
6:1-2 TVariable "x"
99
6:6-7 TTypeVariable "a"
1010
7:1-2 TVariable "x"
11-
7:5-14 TFunction "undefined"
11+
7:5-14 TVariable "undefined"

plugins/hls-semantic-tokens-plugin/test/testdata/TInstanceClassMethodBind.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
5:10-12 TClass "Eq"
55
5:13-16 TTypeCon "Foo"
66
6:5-9 TClassMethod "(==)"
7-
6:12-21 TFunction "undefined"
7+
6:12-21 TVariable "undefined"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3:1-2 TVariable "x"
2+
3:7-9 TClass "Eq"
3+
3:10-11 TTypeVariable "a"
4+
3:16-17 TTypeVariable "a"
5+
4:1-2 TVariable "x"
6+
4:5-14 TVariable "undefined"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module TNoneFunctionWithConstraint where
2+
3+
x :: (Eq a) => a
4+
x = undefined
5+

0 commit comments

Comments
 (0)