Skip to content

Commit

Permalink
Add example with recursive types and type capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-phoenix committed Sep 9, 2020
1 parent 14e1079 commit 93ee5af
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/src/md/kotlin.core/type-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,28 @@ TODO(Need to think more about this part)
> // False
>
> }
>
> interface Recursive<T : Recursive<T>>
>
> fun <T : Recursive<T>> probe(e: Recursive<T>): T = mk()
>
> fun test04() {
> val rec: Recursive<*> = mk()
>
> probe(rec)
>
> // ?- Recursive<*> <: Recursive<T>
> //
> // Recursive<KS> <: Recursive<KT>
> // where Nothing <: KS <: Recursive<KS>
> // Nothing <: KT <: Recursive<KT>
> // (from type capturing)
> // KS ⪯ KT
> // (from subtyping for parameterized types)
> // KS =:= KT
> // (from type containment rules)
> // True
> }
> ```
#### Type containment
Expand Down

0 comments on commit 93ee5af

Please sign in to comment.