Skip to content

Commit

Permalink
Merge pull request #1623 from OlegYch/onlyImplicits
Browse files Browse the repository at this point in the history
Add an option to only add explicit result types to implicit definitions
  • Loading branch information
bjaglin authored Jul 4, 2022
2 parents 57042bd + 847e20f commit 638cba2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ final class ExplicitResultTypes(
defn.parent.exists(_.is[Template])

isImplicit && !isFinalLiteralVal || {
!onlyImplicits &&
hasParentWihTemplate &&
!defn.hasMod(mod"implicit") &&
!matchesSimpleDefinition() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ case class ExplicitResultTypesConfig(
" used `scala.language.reflectiveCalls` to access methods on structural types."
)
rewriteStructuralTypesToNamedSubclass: Boolean = true,
@Description("If true, adds result types only to implicit definitions.")
onlyImplicits: Boolean = false,
@Hidden()
symbolReplacements: Map[String, String] = Map.empty
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
rules = ExplicitResultTypes
ExplicitResultTypes.onlyImplicits = true
*/
package test.explicitResultTypes

object ExplicitResultTypesOnlyImplicits {
def complex = List(1).map(_ + 1)
implicit val default = complex
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package test.explicitResultTypes

object ExplicitResultTypesOnlyImplicits {
def complex = List(1).map(_ + 1)
implicit val default: List[Int] = complex
}

0 comments on commit 638cba2

Please sign in to comment.