File tree 1 file changed +7
-6
lines changed
src/dotty/tools/dotc/parsing 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -1762,17 +1762,18 @@ object Parsers {
1762
1762
* DefSig ::= id [DefTypeParamClause] ParamClauses
1763
1763
*/
1764
1764
def defDefOrDcl (mods : Modifiers ): Tree = atPos(tokenRange) {
1765
- def scala2ProcedureSyntax =
1766
- testScala2Mode( " Procedure syntax no longer supported; `: Unit =' should be inserted here " ) && {
1767
- patch(source, Position (in.lastOffset),
1768
- if (in.token == LBRACE ) " : Unit = " else " : Unit " )
1765
+ def scala2ProcedureSyntax ( resultTypeStr : String ) = {
1766
+ val toInsert = if (in.token == LBRACE ) s " $resultTypeStr = " else " : Unit "
1767
+ testScala2Mode( s " Procedure syntax no longer supported; ` $toInsert ' should be inserted here " ) && {
1768
+ patch(source, Position (in.lastOffset), toInsert )
1769
1769
true
1770
1770
}
1771
+ }
1771
1772
if (in.token == THIS ) {
1772
1773
in.nextToken()
1773
1774
val vparamss = paramClauses(nme.CONSTRUCTOR )
1774
1775
val rhs = {
1775
- if (! (in.token == LBRACE && scala2ProcedureSyntax)) accept(EQUALS )
1776
+ if (! (in.token == LBRACE && scala2ProcedureSyntax( " " ) )) accept(EQUALS )
1776
1777
atPos(in.offset) { constrExpr() }
1777
1778
}
1778
1779
makeConstructor(Nil , vparamss, rhs).withMods(mods)
@@ -1789,7 +1790,7 @@ object Parsers {
1789
1790
}
1790
1791
else if (! tpt.isEmpty)
1791
1792
EmptyTree
1792
- else if (scala2ProcedureSyntax) {
1793
+ else if (scala2ProcedureSyntax( " : Unit " ) ) {
1793
1794
tpt = scalaUnit
1794
1795
if (in.token == LBRACE ) expr()
1795
1796
else EmptyTree
You can’t perform that action at this time.
0 commit comments