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)
|
, T5(T5, t5)
|
||||||
, T6((<|>))
|
, T6((<|>))
|
||||||
, (+)
|
, (+)
|
||||||
|
, (:.)
|
||||||
|
, (:.)(..)
|
||||||
|
, (:.)(T7, (:.), t7)
|
||||||
)
|
)
|
||||||
|
|
||||||
#test hiding
|
#test hiding
|
||||||
|
|
|
@ -79,4 +79,5 @@ module Test (type (++), (++), pattern Foo) where
|
||||||
import Test ( type (++)
|
import Test ( type (++)
|
||||||
, (++)
|
, (++)
|
||||||
, pattern Foo
|
, pattern Foo
|
||||||
|
, pattern (:.)
|
||||||
)
|
)
|
||||||
|
|
|
@ -41,19 +41,19 @@ layoutIE :: ToBriDoc IE
|
||||||
layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
||||||
IEVar x -> layoutWrapped lie x
|
IEVar x -> layoutWrapped lie x
|
||||||
IEThingAbs x -> layoutWrapped lie x
|
IEThingAbs x -> layoutWrapped lie x
|
||||||
IEThingAll _ -> docSeq [ienDoc, docLit $ Text.pack "(..)"]
|
IEThingAll x -> docSeq [layoutWrapped lie x, docLit $ Text.pack "(..)"]
|
||||||
IEThingWith _ (IEWildcard _) _ _ ->
|
IEThingWith x (IEWildcard _) _ _ ->
|
||||||
docSeq [ienDoc, docLit $ Text.pack "(..)"]
|
docSeq [layoutWrapped lie x, docLit $ Text.pack "(..)"]
|
||||||
IEThingWith _ _ ns _ -> do
|
IEThingWith x _ ns _ -> do
|
||||||
hasComments <- hasAnyCommentsBelow lie
|
hasComments <- hasAnyCommentsBelow lie
|
||||||
runFilteredAlternative $ do
|
runFilteredAlternative $ do
|
||||||
addAlternativeCond (not hasComments)
|
addAlternativeCond (not hasComments)
|
||||||
$ docSeq
|
$ docSeq
|
||||||
$ [ienDoc, docLit $ Text.pack "("]
|
$ [layoutWrapped lie x, docLit $ Text.pack "("]
|
||||||
++ intersperse docCommaSep (map nameDoc ns)
|
++ intersperse docCommaSep (map nameDoc ns)
|
||||||
++ [docParenR]
|
++ [docParenR]
|
||||||
addAlternative $ docAddBaseY BrIndentRegular $ docPar
|
addAlternative $ docAddBaseY BrIndentRegular $ docPar
|
||||||
ienDoc
|
(layoutWrapped lie x)
|
||||||
(layoutItems (splitFirstLast ns))
|
(layoutItems (splitFirstLast ns))
|
||||||
where
|
where
|
||||||
nameDoc = (docLit =<<) . lrdrNameToTextAnn . prepareName
|
nameDoc = (docLit =<<) . lrdrNameToTextAnn . prepareName
|
||||||
|
@ -75,7 +75,6 @@ layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
||||||
]
|
]
|
||||||
_ -> docEmpty
|
_ -> docEmpty
|
||||||
where
|
where
|
||||||
ienDoc = docLit =<< lrdrNameToTextAnn (ieName <$> lie)
|
|
||||||
#if MIN_VERSION_ghc(8,2,0) /* ghc-8.2, 8.4, .. */
|
#if MIN_VERSION_ghc(8,2,0) /* ghc-8.2, 8.4, .. */
|
||||||
layoutWrapped _ = \case
|
layoutWrapped _ = \case
|
||||||
L _ (IEName n) -> docLit =<< lrdrNameToTextAnn n
|
L _ (IEName n) -> docLit =<< lrdrNameToTextAnn n
|
||||||
|
|
Loading…
Reference in New Issue