@@ -15,8 +15,8 @@ import config.Printers.{checks, noPrinter}
15
15
import Decorators ._
16
16
import OverridingPairs .isOverridingPair
17
17
import typer .ErrorReporting ._
18
- import config .Feature .{warnOnMigration , migrateTo3 }
19
- import config .SourceVersion .`3.0`
18
+ import config .Feature .{warnOnMigration , migrateTo3 , sourceVersion }
19
+ import config .SourceVersion .{ `3.0` , `future` }
20
20
import config .Printers .refcheck
21
21
import reporting ._
22
22
import Constants .Constant
@@ -264,8 +264,8 @@ object RefChecks {
264
264
* 1.10. If O is inline (and deferred, otherwise O would be final), M must be inline
265
265
* 1.11. If O is a Scala-2 macro, M must be a Scala-2 macro.
266
266
* 1.12. If O is non-experimental, M must be non-experimental.
267
- * 1.13 If O is a val parameter, M must be a val parameter that passes on its
268
- * value to O.
267
+ * 1.13 Under -source future, if O is a val parameter, M must be a val parameter
268
+ * that passes its on to O.
269
269
* 2. Check that only abstract classes have deferred members
270
270
* 3. Check that concrete classes do not have deferred definitions
271
271
* that are not implemented in a subclass.
@@ -448,10 +448,6 @@ object RefChecks {
448
448
overrideError(" cannot be used here - classes can only override abstract types" )
449
449
else if other.isEffectivelyFinal then // (1.2)
450
450
overrideError(i " cannot override final member ${other.showLocated}" )
451
- else if other.is(ParamAccessor ) &&
452
- ! (member.is(ParamAccessor ) && ParamForwarding .inheritedAccessor(member) == other)
453
- then // (1.13)
454
- overrideError(i " cannot override val parameter ${other.showLocated}" )
455
451
else if (member.is(ExtensionMethod ) && ! other.is(ExtensionMethod )) // (1.3)
456
452
overrideError(" is an extension method, cannot override a normal method" )
457
453
else if (other.is(ExtensionMethod ) && ! member.is(ExtensionMethod )) // (1.3)
@@ -520,6 +516,15 @@ object RefChecks {
520
516
overrideError(i " needs to be declared with @targetName( ${" \" " }${other.targetName}${" \" " }) so that external names match " )
521
517
else
522
518
overrideError(" cannot have a @targetName annotation since external names would be different" )
519
+ else if other.is(ParamAccessor )
520
+ && ! (member.is(ParamAccessor ) && ParamForwarding .inheritedAccessor(member) == other)
521
+ then // (1.13)
522
+ if sourceVersion.isAtLeast(`future`) then
523
+ overrideError(i " cannot override val parameter ${other.showLocated}" )
524
+ else
525
+ report.deprecationWarning(
526
+ i " overriding val parameter ${other.showLocated} is deprecated, will be illegal in a future version " ,
527
+ member.srcPos)
523
528
else if ! other.isExperimental && member.hasAnnotation(defn.ExperimentalAnnot ) then // (1.12)
524
529
overrideError(" may not override non-experimental member" )
525
530
else if other.hasAnnotation(defn.DeprecatedOverridingAnnot ) then
0 commit comments