Fix imports of type operators.
Previously, we could only import a type operator with no subsequent list, i.e. import Foo ( (:.) ) was fine, but import Foo ( (:.)(..) ) import Foo ( (:.)((:.) ) import Foo ( (:.)(A, b) ) would all break. Brittany would attempt to output them as import Foo ( :.(..) ) import Foo ( :.((:.) ) import Foo ( :.(A, b) ) I believe the problem was that although `ieName <$> lie` was returning an `IEWrappedName` with the same contents as used in `layoutWrapped`, it had different location annotations; and the parentheses are apparently saved in the location annotations.pull/171/head
parent
8c5e0ef3b6
commit
a5a24b4220
|
@ -727,6 +727,9 @@ import Test ( T
|
|||
, T5(T5, t5)
|
||||
, T6((<|>))
|
||||
, (+)
|
||||
, (:.)
|
||||
, (:.)(..)
|
||||
, (:.)(T7, (:.), t7)
|
||||
)
|
||||
|
||||
#test hiding
|
||||
|
|
|
@ -79,4 +79,5 @@ module Test (type (++), (++), pattern Foo) where
|
|||
import Test ( type (++)
|
||||
, (++)
|
||||
, pattern Foo
|
||||
, pattern (:.)
|
||||
)
|
||||
|
|
|
@ -41,19 +41,19 @@ layoutIE :: ToBriDoc IE
|
|||
layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
||||
IEVar x -> layoutWrapped lie x
|
||||
IEThingAbs x -> layoutWrapped lie x
|
||||
IEThingAll _ -> docSeq [ienDoc, docLit $ Text.pack "(..)"]
|
||||
IEThingWith _ (IEWildcard _) _ _ ->
|
||||
docSeq [ienDoc, docLit $ Text.pack "(..)"]
|
||||
IEThingWith _ _ ns _ -> do
|
||||
IEThingAll x -> docSeq [layoutWrapped lie x, docLit $ Text.pack "(..)"]
|
||||
IEThingWith x (IEWildcard _) _ _ ->
|
||||
docSeq [layoutWrapped lie x, docLit $ Text.pack "(..)"]
|
||||
IEThingWith x _ ns _ -> do
|
||||
hasComments <- hasAnyCommentsBelow lie
|
||||
runFilteredAlternative $ do
|
||||
addAlternativeCond (not hasComments)
|
||||
$ docSeq
|
||||
$ [ienDoc, docLit $ Text.pack "("]
|
||||
$ [layoutWrapped lie x, docLit $ Text.pack "("]
|
||||
++ intersperse docCommaSep (map nameDoc ns)
|
||||
++ [docParenR]
|
||||
addAlternative $ docAddBaseY BrIndentRegular $ docPar
|
||||
ienDoc
|
||||
(layoutWrapped lie x)
|
||||
(layoutItems (splitFirstLast ns))
|
||||
where
|
||||
nameDoc = (docLit =<<) . lrdrNameToTextAnn . prepareName
|
||||
|
@ -75,7 +75,6 @@ layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
|||
]
|
||||
_ -> docEmpty
|
||||
where
|
||||
ienDoc = docLit =<< lrdrNameToTextAnn (ieName <$> lie)
|
||||
#if MIN_VERSION_ghc(8,2,0) /* ghc-8.2, 8.4, .. */
|
||||
layoutWrapped _ = \case
|
||||
L _ (IEName n) -> docLit =<< lrdrNameToTextAnn n
|
||||
|
|
Loading…
Reference in New Issue