summaryrefslogtreecommitdiff
path: root/07-classes-and-objects.md
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-12 18:09:52 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-12 18:09:52 -0700
commitaa6e4b3abaf30072efe1e826470095bc27d68de8 (patch)
treee789dd9603a8bb0a63e22af073003251f17ff17e /07-classes-and-objects.md
parent192152808cbcbbb6fe657295a288ebe12456b93e (diff)
downloadscala-aa6e4b3abaf30072efe1e826470095bc27d68de8.tar.gz
scala-aa6e4b3abaf30072efe1e826470095bc27d68de8.tar.bz2
scala-aa6e4b3abaf30072efe1e826470095bc27d68de8.zip
SI-6195 stable members can only be overridden by stable members
Diffstat (limited to '07-classes-and-objects.md')
-rw-r--r--07-classes-and-objects.md16
1 files changed, 12 insertions, 4 deletions
diff --git a/07-classes-and-objects.md b/07-classes-and-objects.md
index 139599b7ef..012bbe44ff 100644
--- a/07-classes-and-objects.md
+++ b/07-classes-and-objects.md
@@ -350,16 +350,24 @@ $M'$:
- If $M$ and $M'$ are both concrete value definitions, then either none
of them is marked `lazy` or both must be marked `lazy`.
-A special rule concerns parameterless methods. If a paramterless
-method defined as `def $f$: $T$ = ...` or `def $f$ = ...` overrides a method of
-type $()T'$ which has an empty parameter list, then $f$ is also
-assumed to have an empty parameter list.
+A stable member can only be overridden by a stable member.
+For example, this is not allowed:
+
+```
+class X { val stable = 1}
+class Y extends X { override var stable = 1 } // error
+```
Another restriction applies to abstract type members: An abstract type
member with a [volatile type](#volatile-types) as its upper
bound may not override an abstract type member which does not have a
volatile upper bound.
+A special rule concerns parameterless methods. If a parameterless
+method defined as `def $f$: $T$ = ...` or `def $f$ = ...` overrides a method of
+type $()T'$ which has an empty parameter list, then $f$ is also
+assumed to have an empty parameter list.
+
An overriding method inherits all default arguments from the definition
in the superclass. By specifying default arguments in the overriding method
it is possible to add new defaults (if the corresponding parameter in the