You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming that you didn't find any case where something compiled with AnyRef, but was rejected when using Object (or the other way around), I'd say that this isn't a bug.
I guess the main question is: Should we prefer displaying AnyRef over Object? Always, or are there any exceptions?
scala 2.13.11> class A; class B; List(new A, new B)
^
warning: a type was inferred to be `Object`; this may indicate a programming error.
class A
class B
val res0: List[Object] = List(A@1bb172dd, B@1cdd31a4)
not sure whether to label this "fixed in Scala 3" — Scala 3 infers a union type instead. (And, not sure how dealiasing and printing interact with other in Scala 3.)
This is a terrible example of using Lower Bounds but it does reveal a behaviour that seemed unexpected.
In this example, I would expect that that the compiler would infer:
But the compiler actually infers:
The text was updated successfully, but these errors were encountered: