diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-09-27 13:25:48 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-09-27 13:25:48 -0700 |
commit | 5a8cd09819f58adcb866722f48b00066d23e7a82 (patch) | |
tree | e36fec3033a0d276369e6c4a5e7814a8c77d3626 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | 091f3ba3a8a427d69f7cc7d2fafeebb38126ec93 (diff) | |
parent | 96ff8c5d0b49a0c6c7353c57abe9bc10e6aed70f (diff) | |
download | scala-5a8cd09819f58adcb866722f48b00066d23e7a82.tar.gz scala-5a8cd09819f58adcb866722f48b00066d23e7a82.tar.bz2 scala-5a8cd09819f58adcb866722f48b00066d23e7a82.zip |
Merge pull request #2909 from soc/SI-7629-deprecate-view-bounds
SI-7629 Deprecate view bounds
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 10 |
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 a7790bec43..0ba4719d37 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 |