Skip to content

Commit a4eaa44

Browse files
committed
Fix #2495: Improve error message
1 parent f595a1a commit a4eaa44

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,15 @@ object messages {
189189
val msg = {
190190
val ofFun =
191191
if (MethodType.syntheticParamNames(args.length + 1) contains param.name)
192-
i" of expanded function $tree"
192+
i" of expanded function:\n$tree"
193193
else
194194
""
195195

196-
i"""missing parameter type for parameter ${param.name}$ofFun, expected = $pt
197-
|The argument types of an anonymous function must be fully known. (SLS 8.5)"""
196+
i"""missing parameter type
197+
|
198+
|The argument types of an anonymous function must be fully known. (SLS 8.5)
199+
|Expected type: $pt
200+
|Missing type for parameter ${param.name}$ofFun"""
198201
}
199202

200203
val explanation =
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
scala> val xs = scala.collection.mutable.ListBuffer[Int]
22
1 | val xs = scala.collection.mutable.ListBuffer[Int]
33
| ^
4-
|missing parameter type for parameter elems, expected = ?
4+
|missing parameter type
5+
|
56
|The argument types of an anonymous function must be fully known. (SLS 8.5)
7+
|Expected type: ?
8+
|Missing type for parameter elems
69
scala> val xs = scala.collection.mutable.ListBuffer[Int]()
710
val xs: scala.collection.mutable.ListBuffer[Int] = ListBuffer()

compiler/test-resources/repl/i2495

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
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 => "" } }
2+
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 => "" } }
3+
| ^
4+
|missing parameter type
5+
|
6+
|The argument types of an anonymous function must be fully known. (SLS 8.5)
7+
|Expected type: TypeParam.FFn
8+
|Missing type for parameter x$1 of expanded function:
9+
|x$1 =>
10+
| x$1 match
11+
| {
12+
| case FI =>
13+
| 1
14+
| case FS =>
15+
| ""
16+
| }

0 commit comments

Comments
 (0)