Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ trait ContextErrors {

def issueTypeError(err: AbsTypeError)(implicit context: Context): Unit = { context.issue(err) }

def typeErrorMsg(found: Type, req: Type) = "type mismatch" + foundReqMsg(found, req)
def typeErrorMsg(context: Context, found: Type, req: Type) =
if (context.openImplicits.nonEmpty && !settings.XlogImplicits.value) "type mismatch"
else "type mismatch" + foundReqMsg(found, req)
}

def notAnyRefMessage(found: Type): String = {
Expand Down Expand Up @@ -208,7 +210,7 @@ trait ContextErrors {
assert(!foundType.isErroneous, s"AdaptTypeError - foundType is Erroneous: $foundType")
assert(!req.isErroneous, s"AdaptTypeError - req is Erroneous: $req")

issueNormalTypeError(callee, withAddendum(callee.pos)(typeErrorMsg(foundType, req)))
issueNormalTypeError(callee, withAddendum(callee.pos)(typeErrorMsg(context, foundType, req)))
infer.explainTypes(foundType, req)
}

Expand Down Expand Up @@ -1106,7 +1108,7 @@ trait ContextErrors {
}

def NoBestExprAlternativeError(tree: Tree, pt: Type, lastTry: Boolean) = {
issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(tree.symbol.tpe, pt)))
issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(context, tree.symbol.tpe, pt)))
setErrorOnLastTry(lastTry, tree)
}

Expand Down Expand Up @@ -1373,7 +1375,7 @@ trait ContextErrors {
sm"""|Note that implicit conversions are not applicable because they are ambiguous:
|${coreMsg}are possible conversion functions from $found to $req"""
}
typeErrorMsg(found, req) + (
typeErrorMsg(context, found, req) + (
if (explanation == "") "" else "\n" + explanation
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ trait Implicits {

def pos = if (pos0 != NoPosition) pos0 else tree.pos

def failure(what: Any, reason: String, pos: Position = this.pos): SearchResult = {
@inline final def failure(what: Any, reason: => String, pos: Position = this.pos): SearchResult = {
if (settings.XlogImplicits)
reporter.echo(pos, what+" is not a valid implicit value for "+pt+" because:\n"+reason)
SearchFailure
Expand Down Expand Up @@ -673,7 +673,7 @@ trait Implicits {
val itree1 = if (isBlackbox(info.sym)) suppressMacroExpansion(itree0) else itree0
typingLog("considering", typeDebug.ptTree(itree1))

def fail(reason: String): SearchResult = failure(itree0, reason)
@inline def fail(reason: => String): SearchResult = failure(itree0, reason)
def fallback = typed1(itree1, EXPRmode, wildPt)
try {
val itree2 = if (!isView) fallback else pt match {
Expand Down Expand Up @@ -734,7 +734,7 @@ trait Implicits {
info.sym.fullLocationString, itree2.symbol.fullLocationString))
else {
val tvars = undetParams map freshVar
def ptInstantiated = pt.instantiateTypeParams(undetParams, tvars)
val ptInstantiated = pt.instantiateTypeParams(undetParams, tvars)

if (matchesPt(itree3.tpe, ptInstantiated, undetParams)) {
if (tvars.nonEmpty)
Expand Down