I\'m having a little problem understanding variance of methods when overloading.
While this perfectly works due to covariance in the return type
class Bl
The relevant snippets of the spec:
Method Types
A method type is denoted internally as
(Ps)U, where(Ps)is a sequence of parameter names and types(p1 :T1,...,pn :Tn)for somen≥0andUis a (value or method) type. This type represents named methods that take arguments namedp1, ..., pnof typesT1,...,Tnand that return a result of typeU.Method types do not exist as types of values. If a method name is used as a value, its type is implicitly converted to a corresponding function type (§6.26).
Overriding
A member
Mof classCthat matches (§5.1.3) a non-private memberM′of a base class ofCis said to override that member. In this case the binding of the overriding memberMmust subsume (§3.5.2) the binding of the overridden memberM′.
Conformance
If
Ti ≡ Ti′fori = 1, ..., nandUconforms toU′then the method type(p1 : T1,...,pn :Tn)Uconforms to(p1′ :T1′,...,pn′ :Tn′)U′.
Subsumes
A declaration or definition in some compound type of class type
Csubsumes another declaration of the same name in some compound type or class typeC′, if one of the following holds.
- A value declaration or definition that defines a name x with type T subsumes a value or method declaration that defines
xwith typeT′, providedT <: T′.