Scala Function Variance and Overriding

后端 未结 4 554
野性不改
野性不改 2021-02-04 18:09

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         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 18:42

    Well in your second example the signature of tester() in Test declares a Fasel argument but with the overriden signature of FooTest tester() is declared with a Bla as argument. Since Fasel is a subtype of Bla by their extends hierarchy this is probably wrong.

提交回复
热议问题