Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to -Vimplicits; errors now show complete implicit search tree #9944

Merged
merged 1 commit into from Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/compiler/scala/tools/nsc/typechecker/splain/SplainData.scala
Expand Up @@ -14,6 +14,7 @@ package scala.tools.nsc
package typechecker
package splain

import scala.annotation.tailrec
import scala.util.matching.Regex

trait SplainData {
Expand Down Expand Up @@ -68,10 +69,20 @@ trait SplainData {
}

object ImplicitError {
def unapplyCandidate(e: ImplicitError): Tree =
e.candidate match {
case TypeApply(fun, _) => fun
case a => a
def unapplyCandidate(e: ImplicitError): Tree = unapplyRecursively(e.candidate)

@tailrec
private def unapplyRecursively(tree: Tree): Tree =
tree match {
case TypeApply(fun, _) => unapplyRecursively(fun)
case Apply(fun, _) => unapplyRecursively(fun)
case a => a
}

def cleanCandidate(e: ImplicitError): String =
unapplyCandidate(e).toString match {
case ImplicitError.candidateRegex(suf) => suf
case a => a
}

def candidateName(e: ImplicitError): String =
Expand All @@ -83,12 +94,6 @@ trait SplainData {

val candidateRegex: Regex = """.*\.this\.(.*)""".r

def cleanCandidate(e: ImplicitError): String =
unapplyCandidate(e).toString match {
case candidateRegex(suf) => suf
case a => a
}

def shortName(ident: String): String = ident.substring(ident.lastIndexOf(".") + 1)
}
}