summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-07-23 13:38:33 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-08-11 11:54:06 -0700
commit26aebfac0c6db18483d0db67bcd7f8faf7684f0d (patch)
tree8b61eba527e82c72e2cdb1899ad51b10ef29faa3 /src/compiler/scala/tools/nsc/typechecker/Implicits.scala
parente7876d5c41bbea0ee4679815edb5dc1ecef4c6a9 (diff)
downloadscala-26aebfac0c6db18483d0db67bcd7f8faf7684f0d.tar.gz
scala-26aebfac0c6db18483d0db67bcd7f8faf7684f0d.tar.bz2
scala-26aebfac0c6db18483d0db67bcd7f8faf7684f0d.zip
SI-7690 ghost error message fails compile
I won't even try to explain the error reporting code, because it would have no basis in reality. However this change appears to fix the symptom reported.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 100112fec1..c87de8839f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -60,6 +60,8 @@ trait Implicits {
* @return A search result
*/
def inferImplicit(tree: Tree, pt: Type, reportAmbiguous: Boolean, isView: Boolean, context: Context, saveAmbiguousDivergent: Boolean, pos: Position): SearchResult = {
+ // Note that the isInvalidConversionTarget seems to make a lot more sense right here, before all the
+ // work is performed, than at the point where it presently exists.
val shouldPrint = printTypings && !context.undetparams.isEmpty
val rawTypeStart = if (Statistics.canEnable) Statistics.startCounter(rawTypeImpl) else null
val findMemberStart = if (Statistics.canEnable) Statistics.startCounter(findMemberImpl) else null
@@ -1335,12 +1337,18 @@ trait Implicits {
}
}
if (result.isSuccess && isView) {
+ def maybeInvalidConversionError(msg: String) {
+ // We have to check context.ambiguousErrors even though we are calling "issueAmbiguousError"
+ // which ostensibly does exactly that before issuing the error. Why? I have no idea. Test is pos/t7690.
+ if (context.ambiguousErrors)
+ context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, msg))
+ }
if (isInvalidConversionTarget(pt)) {
- context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, "the result type of an implicit conversion must be more specific than AnyRef"))
+ maybeInvalidConversionError("the result type of an implicit conversion must be more specific than AnyRef")
result = SearchFailure
}
else if (isInvalidConversionSource(pt)) {
- context.issueAmbiguousError(AmbiguousImplicitTypeError(tree, "an expression of type Null is ineligible for implicit conversion"))
+ maybeInvalidConversionError("an expression of type Null is ineligible for implicit conversion")
result = SearchFailure
}
}