Skip to content

Commit 93ee5af

Browse files
committed
Add example with recursive types and type capturing
1 parent 14e1079 commit 93ee5af

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/src/md/kotlin.core/type-system.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,28 @@ TODO(Need to think more about this part)
715715
> // False
716716
>
717717
> }
718+
>
719+
> interface Recursive<T : Recursive<T>>
720+
>
721+
> fun <T : Recursive<T>> probe(e: Recursive<T>): T = mk()
722+
>
723+
> fun test04() {
724+
> val rec: Recursive<*> = mk()
725+
>
726+
> probe(rec)
727+
>
728+
> // ?- Recursive<*> <: Recursive<T>
729+
> //
730+
> // Recursive<KS> <: Recursive<KT>
731+
> // where Nothing <: KS <: Recursive<KS>
732+
> // Nothing <: KT <: Recursive<KT>
733+
> // (from type capturing)
734+
> // KS ⪯ KT
735+
> // (from subtyping for parameterized types)
736+
> // KS =:= KT
737+
> // (from type containment rules)
738+
> // True
739+
> }
718740
> ```
719741
720742
#### Type containment

0 commit comments

Comments
 (0)