diff options
author | Jarrod Janssen <jrodjanssen@gmail.com> | 2017-01-02 15:09:53 -0600 |
---|---|---|
committer | Jarrod Janssen <jrodjanssen@gmail.com> | 2017-01-02 15:56:11 -0600 |
commit | 2fd8ea88e7f732482afa795eab0a74be5cc36663 (patch) | |
tree | bf13d6210f57526d11bc170f40fdf7994e88fe7f /compiler/src/dotty/tools/dotc/reporting/diagnostic | |
parent | 39c27b6a8aaa2c7303db54011082246ada06c0a0 (diff) | |
download | dotty-2fd8ea88e7f732482afa795eab0a74be5cc36663.tar.gz dotty-2fd8ea88e7f732482afa795eab0a74be5cc36663.tar.bz2 dotty-2fd8ea88e7f732482afa795eab0a74be5cc36663.zip |
Add error message for unbound wildcard type.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/reporting/diagnostic')
-rw-r--r-- | compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 43 |
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"} + |""" + } } |