From 871df69f47f578c79cad7889f7e27d4b737baf4d Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 18 Feb 2021 16:22:58 +0000 Subject: [PATCH] Explain what consistitutes a more specific type Closes GH-457 --- language/oop5/variance.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/language/oop5/variance.xml b/language/oop5/variance.xml index 9890ef9332..1e6e0f2534 100644 --- a/language/oop5/variance.xml +++ b/language/oop5/variance.xml @@ -13,6 +13,28 @@ of its parent's method. Whereas, contravariance allows a parameter type to be less specific in a child method, than that of its parent. + + A type declaration is considered more specific in the following case: + + + + A type is removed from a union type + + + + + A class type is changed to a child class type + + + + + float is changed to int + + + + + A type class is considered less specific if the opposite is true. + Covariance