Skip to content

Commit

Permalink
Merge pull request #1169 from iantabolt/with-chain-params
Browse files Browse the repository at this point in the history
Allow with-chain wrapping for all params #1125
  • Loading branch information
olafurpg committed May 9, 2018
2 parents 2b4038c + ed96622 commit 0bb92a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
Expand Up @@ -42,11 +42,8 @@ object `:parent:` {
object WithChain {
def unapply(t: Type.With): Option[Type.With] =
TreeOps.topTypeWith(t) match {
// self types
case (top: Type.With) `:parent:` (_: Term.Param) `:parent:` (_: Template) =>
Some(top)
// val/def/var/type definitions or declarations
case (top: Type.With) `:parent:` (_: Defn | _: Decl) =>
// self types, params, val/def/var/type definitions or declarations
case (top: Type.With) `:parent:` (_: Defn | _: Decl | _: Term.Param) =>
Some(top)
case _ => None
}
Expand Down
31 changes: 31 additions & 0 deletions scalafmt-tests/src/test/resources/default/TypeWith.stat
Expand Up @@ -45,3 +45,34 @@ trait NeedsServices {
with HasThrottles
with HasThrowableNotifier
}
<<< class param #1125
class NeedsServices(
services: Bag with
SomeOtherService.RequiredServices
with HasDynamicConfig with HasThrottles
with HasThrowableNotifier
)
>>>
class NeedsServices(
services: Bag
with SomeOtherService.RequiredServices
with HasDynamicConfig
with HasThrottles
with HasThrowableNotifier
)
<<< def param #1125
def sendRequest(services: Bag with
SomeOtherService.RequiredServices
with HasDynamicConfig with HasHttpService, request: Request
): Future[Response] = ???
>>>
def sendRequest(services: Bag
with SomeOtherService.RequiredServices
with HasDynamicConfig
with HasHttpService,
request: Request): Future[Response] = ???
<<< def param negative #1125
def sendRequest(services: Bag with Foo with Bar, request: Request): Future[Response] = ???
>>>
def sendRequest(services: Bag with Foo with Bar,
request: Request): Future[Response] = ???

0 comments on commit 0bb92a2

Please sign in to comment.