You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/md/kotlin.core/declarations.md
-80
Original file line number
Diff line number
Diff line change
@@ -306,86 +306,6 @@ Inner classes cannot be declared in [object declarations][Object declaration], a
306
306
> }
307
307
> ```
308
308
309
-
##### Inheritance delegation
310
-
311
-
In a classifier (an object or a class) declaration $C$, any supertype $I$ inheritance may be *delegated to* an arbitrary value $v$ if:
312
-
313
-
-The supertype $I$ is an interfacetype;
314
-
- $v$ has type $T$ such that $T<:I$.
315
-
316
-
The inheritance delegation uses a syntax similar to [property delegation][Delegated property declaration] using the `by` keyword, but is specified in the classifier declaration header andis a very different concept.
317
-
If inherited using delegation, each method $M$ of $I$ (whether they have a default implementation ornot) is delegated to the corresponding method of $v$ asif it was overridden in $C$ with all the parameter values directly passed to the corresponding method in $v$, unless the body of $C$ itself has a suitable override of $M$ (see the [method overriding][Overriding] section).
318
-
319
-
The particular means on how $v$ is stored inside the classifier objectis platform-defined.
320
-
321
-
Due to the [initialization order of a classifier object][Classifier initialization], the expression used to construct $v$ can not access any of the classifier object properties or methods excluding the parameters of the primary constructor.
>Please note that the expression used as delegate is accessed exactly once when creating the object, e.g. if the delegate expression contains a mutable property access, this mutable property is accessed once during object construction and its subsequent changes do not affect the delegated interfacefunctions.
358
-
>See [classifier initialization section][Classifier initialization] for details on the evaluation order of classifier initialization entities.
359
-
>
360
-
>For example (assuming interface `I` from the previous example is defined):
361
-
>
362
-
> ```kotlin
363
-
>var mut =object:J {...}
364
-
>
365
-
>classD: I by mut // D delegates I to mutable property
Copy file name to clipboardExpand all lines: docs/src/md/kotlin.core/inheritance.md
+80
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,85 @@ As Kotlin is a language with single inheritance (only one supertype can be a cla
80
80
81
81
TODO(Examples)
82
82
83
+
### Inheritance delegation
84
+
85
+
In a classifier (an object or a class) declaration $C$, any supertype $I$ inheritance may be *delegated to* an arbitrary value $v$ if:
86
+
87
+
- The supertype $I$ is an interface type;
88
+
- $v$ has type $T$ such that $T <: I$.
89
+
90
+
The inheritance delegation uses a syntax similar to [property delegation][Delegated property declaration] using the `by` keyword, but is specified in the classifier declaration header and is a very different concept.
91
+
If inherited using delegation, each method $M$ of $I$ (whether they have a default implementation or not) is delegated to the corresponding method of $v$ as if it was overridden in $C$ with all the parameter values directly passed to the corresponding method in $v$, unless the body of $C$ itself has a suitable override of $M$ (see the [method overriding][Overriding] section).
92
+
93
+
The particular means on how $v$ is stored inside the classifier object is platform-defined.
94
+
95
+
Due to the [initialization order of a classifier object][Classifier initialization], the expression used to construct $v$ can not access any of the classifier object properties or methods excluding the parameters of the primary constructor.
>Please note that the expression used as delegate is accessed exactly once when creating the object, e.g. if the delegate expression contains a mutable property access, this mutable property is accessed once during object construction and its subsequent changes do not affect the delegated interfacefunctions.
132
+
>See [classifier initialization section][Classifier initialization] for details on the evaluation order of classifier initialization entities.
133
+
>
134
+
>For example (assuming interface `I` from the previous example is defined):
135
+
>
136
+
> ```kotlin
137
+
>var mut =object:J {...}
138
+
>
139
+
>classD: I by mut // D delegates I to mutable property
A callable declaration (that is, a [property][Property declaration] or [member function][Function declaration] declaration) inside a classifier declaration is said to be *overridable*if:
@@ -145,3 +224,4 @@ If the overriding declaration *does* have its visibility specified, it must not
145
224
>Note:if a declaration binds a new function to the same name as was introduced in the base class, but which does not subsume it, it is neither a compile-time error nor an overriding declaration.
146
225
>Inthis case these two declarations follow the normal rules of [overloading][Overload resolution].
147
226
>However, these declarations may still result in a compile-time error as a result of [conflicting overload][Conflicting overloads] detection.
0 commit comments