@@ -15,8 +15,8 @@ import config.Printers.{checks, noPrinter}
1515import Decorators ._
1616import OverridingPairs .isOverridingPair
1717import 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` }
2020import config .Printers .refcheck
2121import reporting ._
2222import Constants .Constant
@@ -264,8 +264,8 @@ object RefChecks {
264264 * 1.10. If O is inline (and deferred, otherwise O would be final), M must be inline
265265 * 1.11. If O is a Scala-2 macro, M must be a Scala-2 macro.
266266 * 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.
269269 * 2. Check that only abstract classes have deferred members
270270 * 3. Check that concrete classes do not have deferred definitions
271271 * that are not implemented in a subclass.
@@ -448,10 +448,6 @@ object RefChecks {
448448 overrideError(" cannot be used here - classes can only override abstract types" )
449449 else if other.isEffectivelyFinal then // (1.2)
450450 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}" )
455451 else if (member.is(ExtensionMethod ) && ! other.is(ExtensionMethod )) // (1.3)
456452 overrideError(" is an extension method, cannot override a normal method" )
457453 else if (other.is(ExtensionMethod ) && ! member.is(ExtensionMethod )) // (1.3)
@@ -520,6 +516,15 @@ object RefChecks {
520516 overrideError(i " needs to be declared with @targetName( ${" \" " }${other.targetName}${" \" " }) so that external names match " )
521517 else
522518 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)
523528 else if ! other.isExperimental && member.hasAnnotation(defn.ExperimentalAnnot ) then // (1.12)
524529 overrideError(" may not override non-experimental member" )
525530 else if other.hasAnnotation(defn.DeprecatedOverridingAnnot ) then
0 commit comments