Why this code won't compile? Tested on Scala 2.13.6. Is there a way to let scalac know that SizeOfType[Unit]#Size is actually Short?
trait SizeOfType[T] {
type Size
def getSize(): Size
}
object SizeOfType {
implicit def unit: SizeOfType[Unit] = new SizeOfType[Unit] {
type Size = Short
def getSize(): Short = 0
}
def test(implicit ev: SizeOfType[Unit]): Short = ev.getSize()
}
[error] type mismatch;
[error] found : ev.Size
[error] required: Short
[error] def test(implicit ev: SizeOfType[Unit]): Short = ev.getSize()