Skip to content

Commit

Permalink
Update FAQ on how to debug "implicit not found" errors now that splai…
Browse files Browse the repository at this point in the history
…n was integrated into the Scala compiler (#1079)

* Include the `-Vimplicits` flag in example project's Scala 2.13 build

* Update FAQ now that splain was integrated into the Scala compiler

* Rename `lintFlags` to `versionSpecificFlags`
  • Loading branch information
jcazevedo committed Jun 20, 2021
1 parent 8f59973 commit d9d0559
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 5 additions & 3 deletions docs/docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ ConfigSource.default.load[Conf]

In PureConfig, the derivation of config readers and writers is done by chaining implicits - the converters of larger
structures (like `Conf`) depend on the implicit converters of smaller ones (like `Boolean` or `Custom`). However, the
Scala compiler for Scala 2.x is not helpful in case one of those upstream dependencies is missing, limiting itself to
showing the message above.
Scala compiler for Scala 2.x is not helpful by default in case one of those upstream dependencies is missing, limiting
itself to showing the message above.

To more efficiently debug these "implicit not found" errors, we recommend using [splain](https://github.com/tek/splain).
Please refer to the project's documentation for instructions on how to include the compiler plugin.
splain was integrated into the compiler in [Scala 2.13.6](https://github.com/scala/scala/releases/tag/v2.13.6) and can
be enabled with the `-Vimplicits` scalac flag. For Scala 2.13 versions prior to 2.13.6 or Scala 2.12 versions, please
refer to the project's documentation for instructions on how to include the compiler plugin.

When code using PureConfig derived converters is compiled using the compiler plugin recommended above, you will get a
more thorough error message. In this particular case, the message will be quite large because there are some alternative
Expand Down
11 changes: 5 additions & 6 deletions example/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ libraryDependencies += "com.github.pureconfig" %% "pureconfig" % pureconfigVersi

crossScalaVersions := Seq("2.12.14", "2.13.6")

val lintFlags =
val versionSpecificFlags =
Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) =>
// Excluding -byname-implicit is required for Scala 2.13 due to https://github.com/scala/bug/issues/12072
"-Xlint:_,-byname-implicit"
Seq("-Xlint:_,-byname-implicit", "-Vimplicits")
case _ =>
"-Xlint:_"
Seq("-Xlint:_")
}
}

Expand All @@ -34,8 +34,7 @@ scalacOptions ++= Seq(
"-unchecked",
"-Xfatal-warnings",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
lintFlags.value
)
"-Ywarn-value-discard"
) ++ versionSpecificFlags.value

scalafmtOnCompile := true

0 comments on commit d9d0559

Please sign in to comment.