From b775f4f58098d7f79155b3fe00c0bdb0eabf3d84 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 9 Dec 2016 09:53:30 -0800 Subject: SI-10097 Adapt unless -Xsource:2.13 For 2.12 migration, insert missing case class param section, strip caseaccessor from implicit paramsection, and deprecate the adaptation. --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 440e45c577..c35c0a1019 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2262,11 +2262,20 @@ self => } if (ofCaseClass) { if (vds.isEmpty) - syntaxError(in.lastOffset, s"case classes must have a parameter list; try 'case class ${owner.encoded + syntaxError(start, s"case classes must have a parameter list; try 'case class ${owner.encoded }()' or 'case object ${owner.encoded}'") - else if (vds.head.nonEmpty && vds.head.head.mods.isImplicit) - syntaxError(in.lastOffset, s"case classes must have a non-implicit parameter list; try 'case class ${ + else if (vds.head.nonEmpty && vds.head.head.mods.isImplicit) { + if (settings.isScala213) + syntaxError(start, s"case classes must have a non-implicit parameter list; try 'case class ${ owner.encoded}()${ vds.map(vs => "(...)").mkString }'") + else { + deprecationWarning(start, s"case classes should have a non-implicit parameter list; adapting to 'case class ${ + owner.encoded}()${ vds.map(vs => "(...)").mkString }'", "2.12.2") + vds.insert(0, List.empty[ValDef]) + vds(1) = vds(1).map(vd => copyValDef(vd)(mods = vd.mods & ~Flags.CASEACCESSOR)) + if (implicitSection != -1) implicitSection += 1 + } + } } if (implicitSection != -1 && implicitSection != vds.length - 1) syntaxError(implicitOffset, "an implicit parameter section must be last") -- cgit v1.2.3