diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2013-09-08 16:38:52 +0200 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2013-10-24 00:52:01 +0200 |
commit | bc475036c4cae5e9534ee3f9985e4e7a848e4b67 (patch) | |
tree | 8e8009cc5ead2bc6b320da8827753f30916b9cad /src | |
parent | 951422163ab8fc47caa60acb66b670a371b5489e (diff) | |
download | scala-bc475036c4cae5e9534ee3f9985e4e7a848e4b67.tar.gz scala-bc475036c4cae5e9534ee3f9985e4e7a848e4b67.tar.bz2 scala-bc475036c4cae5e9534ee3f9985e4e7a848e4b67.zip |
SI-7605 Deprecate procedure syntax
This commit covers three cases:
- constructor definitions (def this {...})
- concrete method definitions (def foo {...})
- abstract method declarations (def foo)
The deprecation is currently hidden behind -Xfuture pending IDE support
for migrating users from procedures to methods.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 1d5f35b7d6..07938ec3df 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2512,7 +2512,11 @@ self => val vparamss = paramClauses(nme.CONSTRUCTOR, classContextBounds map (_.duplicate), ofCaseClass = false) newLineOptWhenFollowedBy(LBRACE) val rhs = in.token match { - case LBRACE => atPos(in.offset) { constrBlock(vparamss) } + case LBRACE => { + if (settings.future) + deprecationWarning(in.offset, "Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`.") + atPos(in.offset) { constrBlock(vparamss) } + } case _ => accept(EQUALS) ; atPos(in.offset) { constrExpr(vparamss) } } DefDef(mods, nme.CONSTRUCTOR, List(), vparamss, TypeTree(), rhs) @@ -2538,10 +2542,14 @@ self => var restype = fromWithinReturnType(typedOpt()) val rhs = if (isStatSep || in.token == RBRACE) { + if (settings.future) + deprecationWarning(in.lastOffset, "Procedure syntax is deprecated. Convert procedure to method by adding `: Unit`.") if (restype.isEmpty) restype = scalaUnitConstr newmods |= Flags.DEFERRED EmptyTree } else if (restype.isEmpty && in.token == LBRACE) { + if (settings.future) + deprecationWarning(in.offset, "Procedure syntax is deprecated. Convert procedure to method by adding `: Unit =`.") restype = scalaUnitConstr blockExpr() } else { |