The fact that list elements implements the 2 same ...
# compiler
m
The fact that list elements implements the 2 same interfaces seems to force
List<Any>
there. I guess because it could because
List<Named>
is as good of a solution than
List<Node>
? But in the context of
List<Node>
, I feel like this could be disambiguated_?_
d
Your analysis looks correct; if I remove Named as supertype of either Cat or Dog then the compiler stops complaining. The ambiguity is in the return type of List’s
+
operator which is probably in some sense “before” it decides the return type of
children
? So it seems like the compiler would have to do like an extra pass to then disambiguate it later. But I’m just guessing at this point.
👀 1