summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2013-08-20 18:19:33 +0200
committerSimon Ochsenreither <simon@ochsenreither.de>2013-09-25 15:16:12 +0200
commit96ff8c5d0b49a0c6c7353c57abe9bc10e6aed70f (patch)
treecd55b66d53c99df3af445366bd86faed7e6adfae /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parentbda48577d022811be58ce2b7f9e46890543ad45b (diff)
downloadscala-96ff8c5d0b49a0c6c7353c57abe9bc10e6aed70f.tar.gz
scala-96ff8c5d0b49a0c6c7353c57abe9bc10e6aed70f.tar.bz2
scala-96ff8c5d0b49a0c6c7353c57abe9bc10e6aed70f.zip
SI-7629 Deprecate view bounds
This introduces a warning(/error with -Xfuture) with a general migration advice. The IDE can use the warning to offer a quick fix with the specific refactoring necessary.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index a894e38ab4..c9e209f53b 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -2257,9 +2257,10 @@ self =>
}
if (contextBoundBuf ne null) {
while (in.token == VIEWBOUND) {
- contextBoundBuf += atPos(in.skipToken()) {
- makeFunctionTypeTree(List(Ident(pname)), typ())
- }
+ val msg = "Use an implicit parameter instead.\nExample: Instead of `def f[A <% Int](a: A)` use `def f[A](a: A)(implicit ev: A => Int)`."
+ if (settings.future)
+ deprecationWarning(in.offset, s"View bounds are deprecated. $msg")
+ contextBoundBuf += atPos(in.skipToken())(makeFunctionTypeTree(List(Ident(pname)), typ()))
}
while (in.token == COLON) {
contextBoundBuf += atPos(in.skipToken()) {
@@ -2690,7 +2691,8 @@ self =>
classContextBounds = contextBoundBuf.toList
val tstart = (in.offset :: classContextBounds.map(_.pos.startOrPoint)).min
if (!classContextBounds.isEmpty && mods.isTrait) {
- syntaxError("traits cannot have type parameters with context bounds `: ...' nor view bounds `<% ...'", skipIt = false)
+ val viewBoundsExist = if (settings.future) "" else " nor view bounds `<% ...'"
+ syntaxError(s"traits cannot have type parameters with context bounds `: ...'$viewBoundsExist", skipIt = false)
classContextBounds = List()
}
val constrAnnots = if (!mods.isTrait) constructorAnnotations() else Nil