I was reading the section 20.7 of the book Programming in Scala and I was wondering why while this code compiles:
class Food
class Fish extends Food
class Gr
I believe bessy eat (new bessy.SuitableFood)
compiling is a bug (which was fixed in 2.11). Because another subtype of Animal
could have a SuitableFood
for which new
makes no sense, e.g. type SuitableFood = Food
or even type SuitableFood = Food with Int
(Food with Int
is a perfectly nice subtype of Food
!).