Description
When compiling the following code:
case class Test[T](v: T)
type LongComplictedType
type B = LongComplictedType
def v: Int = Test(??? : B)
Dotty produces the error message:
1 |def v: Int = Test(??? : B)
| ^^^^^^^^^^^^^
| found: Test[LongComplictedType]
| required: Int
Note that Dotty completely dealiases the type (i.e., found: Test[LongComplictedType]
, instead of found: Test[B]
). In error messages issued by scalac, you get the type as it is denoted in the code (which is potentially an alias), and you get an "which expands to" line with the dealiased type:
1: error: type mismatch;
found : Test[B]
(which expands to) Test[LongComplictedType]
required: Int
def v: Int = Test(??? : B)
I'd argue that the Scala error messages are better to read since you are also shown the aliased types that do not match (type aliases are often defined to abstract away complexity and thus, it should be easier to interpret the type for the developer reading the error message).
I think the reason is that Dotty infers the type of Test(??? : B)
as Test[LongComplictedType]
instead of Test[B]
. Further, it could also be useful to show both the type as denoted in the code and the expanded type.