diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 | ||||
-rw-r--r-- | test/files/neg/type-diagnostics.check | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 99c85f72f1..ebcd3c3777 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -145,11 +145,15 @@ trait TypeDiagnostics { def alternativesString(tree: Tree) = alternatives(tree) map (x => " " + methodTypeErrorString(x)) mkString ("", " <and>\n", "\n") - def missingParameterTypeMsg(fun: Tree, vparam: ValDef) = { + def missingParameterTypeMsg(fun: Tree, vparam: ValDef, pt: Type) = { + def anonMessage = ( + "\nThe argument types of an anonymous function must be fully known. (SLS 8.5)" + + "\nExpected type was: " + pt.toLongString + ) val suffix = if (!vparam.mods.isSynthetic) "" else " for expanded function" + (fun match { - case Function(_, Match(_, _)) => "\n(see SLS 8.5, \"Pattern Matching Anonymous Functions\")" + case Function(_, Match(_, _)) => anonMessage case _ => " " + fun }) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 155883299a..33db7424bc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2036,7 +2036,7 @@ trait Typers { self: Analyzer => } case _ => } - error(vparam.pos, missingParameterTypeMsg(fun, vparam)) + error(vparam.pos, missingParameterTypeMsg(fun, vparam, pt)) ErrorType } if (!vparam.tpt.pos.isDefined) vparam.tpt setPos vparam.pos.focus diff --git a/test/files/neg/type-diagnostics.check b/test/files/neg/type-diagnostics.check index 62d580a788..0ed9f4631b 100644 --- a/test/files/neg/type-diagnostics.check +++ b/test/files/neg/type-diagnostics.check @@ -14,7 +14,8 @@ type-diagnostics.scala:17: error: type mismatch; def f2[String](s: String) = strings(List(s)) ^ type-diagnostics.scala:21: error: missing parameter type for expanded function -(see SLS 8.5, "Pattern Matching Anonymous Functions") +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: ? val f = { case 5 => 10 } ^ four errors found |