aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
diff options
context:
space:
mode:
authorThiago Pereira <thiago@Thiagos-Mac-mini.local>2016-10-23 21:19:00 -0200
committerThiago Pereira <thiago.pereira@vivareal.com>2016-10-25 14:33:58 -0200
commit97b0af746ac3f2eb2fe7078b5aa5d596439fbfb5 (patch)
treedfda2c26c4088e27fdd7e61f216e854894f7d2a9 /src/dotty/tools/dotc/reporting/diagnostic/messages.scala
parentf1284b48d48ec16840e3e018e060edc50d4d1bb7 (diff)
downloaddotty-97b0af746ac3f2eb2fe7078b5aa5d596439fbfb5.tar.gz
dotty-97b0af746ac3f2eb2fe7078b5aa5d596439fbfb5.tar.bz2
dotty-97b0af746ac3f2eb2fe7078b5aa5d596439fbfb5.zip
Add error message - Comments.scala:128
This commit adds the semantic object for the ```definition not found``` error. It is part of the (https://github.com/lampepfl/dotty/issues/1589)[https://github.com/lampepfl/dotty/issues/1589]
Diffstat (limited to 'src/dotty/tools/dotc/reporting/diagnostic/messages.scala')
-rw-r--r--src/dotty/tools/dotc/reporting/diagnostic/messages.scala39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index 303ab0437..b0ce5b132 100644
--- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -543,5 +543,42 @@ object messages {
|
|""".stripMargin
}
-
+
+ case class ProperDefinitionNotFound()(implicit ctx: Context) extends Message(20) {
+ val kind = "Definition Not Found"
+ val msg = hl"""|Proper definition was not found in ${"@usecase"}"""
+
+ val noUsecase = "def map[B, That](f: A => B)(implicit bf: CanBuildFrom[List[A], B, That]): That"
+
+ val usecase =
+ """|/** Map from List[A] => List[B]
+ | *
+ | * @usecase def map[B](f: A => B): List[B]
+ | */
+ |def map[B, That](f: A => B)(implicit bf: CanBuildFrom[List[A], B, That]): That""".stripMargin
+
+ val explanation = {
+ hl"""|${"@usecase"} are only supported for ${"def"}s. They exist because with Scala's
+ |advanced type-system, we sometimes end up with seemingly scary signatures.
+ |
+ |Let's see an example using the `map`function:
+ |
+ |${"List(1, 2, 3).map(2 * _) // res: List(2, 4, 6)"}
+ |
+ |It's very straight forward to understand and use, but has such a scary signature:
+ |
+ |$noUsecase
+ |
+ |In order to mitigate this and ease the usage of such functions we have the ${"@usecase"}
+ |annotation for docstrings. Which can be used like this:
+ |
+ |$usecase
+ |
+ |Now when creating the docs, the method signature is substituted by the
+ |${"@usecase"} with a reader-friendly version. The compiler makes sure that it is valid.
+ |
+ |Because of this, you must use ${"def"} when defining ${"@usecase"}.""".stripMargin
+ }
+ }
+
}