diff options
Diffstat (limited to '07-classes-and-objects.md')
-rw-r--r-- | 07-classes-and-objects.md | 16 |
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 |