From a4eaa4473376c7b325f3a625cb730cbf9217a706 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 11 Jan 2018 14:51:47 +0100 Subject: [PATCH 1/2] Fix #2495: Improve error message --- .../dotc/reporting/diagnostic/messages.scala | 9 ++++++--- compiler/test-resources/repl/errorThenValid | 5 ++++- compiler/test-resources/repl/i2495 | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 compiler/test-resources/repl/i2495 diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 4822be59b57f..1a62b6b1f62d 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -189,12 +189,15 @@ object messages { val msg = { val ofFun = if (MethodType.syntheticParamNames(args.length + 1) contains param.name) - i" of expanded function $tree" + i" of expanded function:\n$tree" else "" - i"""missing parameter type for parameter ${param.name}$ofFun, expected = $pt - |The argument types of an anonymous function must be fully known. (SLS 8.5)""" + i"""missing parameter type + | + |The argument types of an anonymous function must be fully known. (SLS 8.5) + |Expected type: $pt + |Missing type for parameter ${param.name}$ofFun""" } val explanation = diff --git a/compiler/test-resources/repl/errorThenValid b/compiler/test-resources/repl/errorThenValid index 832c3334f9ca..030d06caba39 100644 --- a/compiler/test-resources/repl/errorThenValid +++ b/compiler/test-resources/repl/errorThenValid @@ -1,7 +1,10 @@ scala> val xs = scala.collection.mutable.ListBuffer[Int] 1 | val xs = scala.collection.mutable.ListBuffer[Int] | ^ - |missing parameter type for parameter elems, expected = ? + |missing parameter type + | |The argument types of an anonymous function must be fully known. (SLS 8.5) + |Expected type: ? + |Missing type for parameter elems scala> val xs = scala.collection.mutable.ListBuffer[Int]() val xs: scala.collection.mutable.ListBuffer[Int] = ListBuffer() diff --git a/compiler/test-resources/repl/i2495 b/compiler/test-resources/repl/i2495 new file mode 100644 index 000000000000..f4445d8706f6 --- /dev/null +++ b/compiler/test-resources/repl/i2495 @@ -0,0 +1,16 @@ +scala> object TypeParam { sealed trait F[A]; case object FI extends F[Int]; case object FS extends F[String]; trait FFn { def apply[A](f: F[A]): A }; val test4: FFn = { case FI => 1; case FS => "" } } +1 | object TypeParam { sealed trait F[A]; case object FI extends F[Int]; case object FS extends F[String]; trait FFn { def apply[A](f: F[A]): A }; val test4: FFn = { case FI => 1; case FS => "" } } + | ^ + |missing parameter type + | + |The argument types of an anonymous function must be fully known. (SLS 8.5) + |Expected type: TypeParam.FFn + |Missing type for parameter x$1 of expanded function: + |x$1 => + | x$1 match + | { + | case FI => + | 1 + | case FS => + | "" + | } From a51091bd1c01525e79d64e544abc6004015e5e96 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 11 Jan 2018 17:12:30 +0100 Subject: [PATCH 2/2] Remove scripted test --- compiler/test-resources/repl/i2495 | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 compiler/test-resources/repl/i2495 diff --git a/compiler/test-resources/repl/i2495 b/compiler/test-resources/repl/i2495 deleted file mode 100644 index f4445d8706f6..000000000000 --- a/compiler/test-resources/repl/i2495 +++ /dev/null @@ -1,16 +0,0 @@ -scala> object TypeParam { sealed trait F[A]; case object FI extends F[Int]; case object FS extends F[String]; trait FFn { def apply[A](f: F[A]): A }; val test4: FFn = { case FI => 1; case FS => "" } } -1 | object TypeParam { sealed trait F[A]; case object FI extends F[Int]; case object FS extends F[String]; trait FFn { def apply[A](f: F[A]): A }; val test4: FFn = { case FI => 1; case FS => "" } } - | ^ - |missing parameter type - | - |The argument types of an anonymous function must be fully known. (SLS 8.5) - |Expected type: TypeParam.FFn - |Missing type for parameter x$1 of expanded function: - |x$1 => - | x$1 match - | { - | case FI => - | 1 - | case FS => - | "" - | }