summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2012-05-16 15:24:59 +0200
committerLukas Rytz <lukas.rytz@epfl.ch>2012-05-18 10:58:14 +0200
commit4669ac180e58daf97ac7f73af4622434b439631d (patch)
treed1397c1b58e6863cf33174be038ad3bafa250e18 /src
parentb48aa909cefc4811e208f491d22d664538d75bad (diff)
downloadscala-4669ac180e58daf97ac7f73af4622434b439631d.tar.gz
scala-4669ac180e58daf97ac7f73af4622434b439631d.tar.bz2
scala-4669ac180e58daf97ac7f73af4622434b439631d.zip
better feedback for SI-5044
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala11
2 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 0c1638b76f..769cc6dbc1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -1034,6 +1034,12 @@ trait ContextErrors {
setError(arg)
} else arg
}
+
+ def WarnAfterNonSilentRecursiveInference(param: Symbol, arg: Tree)(implicit context: Context) = {
+ val note = "type-checking the invocation of "+ param.owner +" checks if the named argument expression '"+ param.name + " = ...' is a valid assignment\n"+
+ "in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for "+ param.name +"."
+ context.warning(arg.pos, note)
+ }
def UnknownParameterNameNamesDefaultError(arg: Tree, name: Name)(implicit context: Context) = {
issueNormalTypeError(arg, "unknown parameter name: " + name)
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index bef6f13bc3..efc6526fe0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -478,7 +478,14 @@ trait NamesDefaults { self: Analyzer =>
// instead of arg, but can't do that because eventually setType(ErrorType)
// is called, and EmptyTree can only be typed NoType. Thus we need to
// disable conforms as a view...
- try typer.silent(_.typed(arg, subst(paramtpe))) match {
+ val errsBefore = reporter.ERROR.count
+ try typer.silent { tpr =>
+ val res = tpr.typed(arg, subst(paramtpe))
+ // better warning for SI-5044: if `silent` was not actually silent give a hint to the user
+ if (errsBefore < reporter.ERROR.count)
+ WarnAfterNonSilentRecursiveInference(param, arg)(context)
+ res
+ } match {
case SilentResultValue(t) => !t.isErroneous // #4041
case _ => false
}
@@ -487,7 +494,7 @@ trait NamesDefaults { self: Analyzer =>
// CyclicReferences. Fix for #3685
case cr @ CyclicReference(sym, _) =>
(sym.name == param.name) && sym.accessedOrSelf.isVariable && {
- NameClashError(sym, arg)(typer.context)
+ NameClashError(sym, arg)(context)
true
}
}