File tree 6 files changed +24
-5
lines changed
src/compiler/scala/tools/nsc/ast/parser
6 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -2262,11 +2262,19 @@ self =>
2262
2262
}
2263
2263
if (ofCaseClass) {
2264
2264
if (vds.isEmpty)
2265
- syntaxError(in.lastOffset , s " case classes must have a parameter list; try 'case class ${owner.encoded
2265
+ syntaxError(start , s " case classes must have a parameter list; try 'case class ${owner.encoded
2266
2266
}()' or 'case object ${owner.encoded}' " )
2267
- else if (vds.head.nonEmpty && vds.head.head.mods.isImplicit)
2268
- syntaxError(in.lastOffset, s " case classes must have a non-implicit parameter list; try 'case class ${
2267
+ else if (vds.head.nonEmpty && vds.head.head.mods.isImplicit) {
2268
+ if (settings.future)
2269
+ syntaxError(start, s " case classes must have a non-implicit parameter list; try 'case class ${
2269
2270
owner.encoded}() ${ vds.map(vs => " (...)" ).mkString }' " )
2271
+ else {
2272
+ deprecationWarning(start, s " case classes should have a non-implicit parameter list; adapting to 'case class ${
2273
+ owner.encoded}() ${ vds.map(vs => " (...)" ).mkString }' " , " 2.12.2" )
2274
+ vds.insert(0 , List .empty[ValDef ])
2275
+ if (implicitSection != - 1 ) implicitSection += 1
2276
+ }
2277
+ }
2270
2278
}
2271
2279
if (implicitSection != - 1 && implicitSection != vds.length - 1 )
2272
2280
syntaxError(implicitOffset, " an implicit parameter section must be last" )
Original file line number Diff line number Diff line change 1
1
t10097.scala:2: error: case classes must have a non-implicit parameter list; try 'case class C()(...)'
2
2
case class C(implicit val c: Int)
3
- ^
3
+ ^
4
4
t10097.scala:4: error: case classes must have a non-implicit parameter list; try 'case class D()(...)(...)'
5
5
case class D(implicit c: Int)(s: String)
6
- ^
6
+ ^
7
7
t10097.scala:4: error: an implicit parameter section must be last
8
8
case class D(implicit c: Int)(s: String)
9
9
^
Original file line number Diff line number Diff line change
1
+ -Xfuture
Original file line number Diff line number Diff line change
1
+ t10097b.scala:2: warning: case classes should have a non-implicit parameter list; adapting to 'case class C()(...)'
2
+ case class C(implicit val c: Int)
3
+ ^
4
+ error: No warnings can be incurred under -Xfatal-warnings.
5
+ one warning found
6
+ one error found
Original file line number Diff line number Diff line change
1
+ -deprecation -Xfatal-warnings
Original file line number Diff line number Diff line change
1
+
2
+ case class C (implicit val c : Int )
3
+
You can’t perform that action at this time.
0 commit comments