Skip to content

Commit bd90883

Browse files
Added restrictions to inner and local classes
1 parent 6abcfff commit bd90883

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: docs/src/md/kotlin.core/declarations.md

+4
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ Inner classes cannot be declared in a [statement scope][Scopes and identifiers],
246246
247247
Inner classes cannot be declared in [object declarations][Object declaration], as object declarations also create a single named value of their type, which makes additional association unnecessary.
248248
249+
Inner classes cannot contain any nested classes, interfaces or objects (including companion objects but excluding object literals). Additional inner classes are allowed inside an inner class.
250+
249251
> Note: for information on how type parameters of parent and nested / inner classifiers interoperate, we delegate you to the [type system][Inner and nested type contexts] section of the specification.
250252
251253
> Note: unlike object declarations, in [object literals] only inner classes are allowed, as types of object literals are anonymous, making their nested classifiers available only through explicit receiver, effectively forcing them to be inner.
@@ -867,6 +869,8 @@ fun foo() {
867869
}
868870
```
869871
872+
Similar to object literals and [inner classes][Nested and inner classifiers], only inner classes are allowed in local classes. Interfaces, objects or nested classes are forbidden.
873+
870874
Enum classes and annotation classes cannot be declared locally.
871875
872876
#### Classifier initialization

0 commit comments

Comments
 (0)