aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala43
1 files changed, 43 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
index b55b7e868..25db28e4a 100644
--- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
+++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala
@@ -923,4 +923,47 @@ object messages {
|"""
}
+ case class UnboundWildcardType()(implicit ctx: Context) extends Message(35) {
+ val kind = "Syntax"
+ val msg = "Unbound wildcard type"
+ val explanation =
+ hl"""|The wildcard type syntax (`_`) was used where it could not be bound.
+ |Replace `_` with a non-wildcard type. If the type doesn't matter,
+ |try replacing `_` with ${"Any"}.
+ |
+ |Examples:
+ |
+ |- Parameter lists
+ |
+ | Instead of:
+ | ${"def foo(x: _) = ..."}
+ |
+ | Use ${"Any"} if the type doesn't matter:
+ | ${"def foo(x: Any) = ..."}
+ |
+ |- Type arguments
+ |
+ | Instead of:
+ | ${"val foo = List[_](1, 2)"}
+ |
+ | Use:
+ | ${"val foo = List[Int](1, 2)"}
+ |
+ |- Type bounds
+ |
+ | Instead of:
+ | ${"def foo[T <: _](x: T) = ..."}
+ |
+ | Remove the bounds if the type doesn't matter:
+ | ${"def foo[T](x: T) = ..."}
+ |
+ |- ${"val"} and ${"def"} types
+ |
+ | Instead of:
+ | ${"val foo: _ = 3"}
+ |
+ | Use:
+ | ${"val foo: Int = 3"}
+ |"""
+ }
}