From 2ea56ce7efd2b49fa92b4520268c704103846f0f Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Mon, 25 Jul 2022 01:10:00 +0400 Subject: [PATCH] Note about type variance --- docs/sophia_features.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/sophia_features.md b/docs/sophia_features.md index f79c531..50851bf 100644 --- a/docs/sophia_features.md +++ b/docs/sophia_features.md @@ -191,7 +191,15 @@ contract interface X : Z = entrypoint z() = 1 ``` -The following subtyping rules apply: +#### Subtyping + +The subtyping rules below, mention the variance of a type, which is defined in [Wikipedia](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) as follows: + +>Variance refers to how subtyping between more complex types relates to subtyping between their components. + +You can refer to the Wikipedia page for further understanding of type variance. + +In Sophia, the following subtyping rules apply: - A function type `(Args1) => Ret1` is a subtype of `(Args2) => Ret2` when `Ret1` is a subtype of `Ret2` and each argument type from `Args2` is a subtype of its