【发布时间】:2020-12-30 13:22:52
【问题描述】:
为什么以下是不允许的? (2.12):
type Foo <: {def foo(): Unit}
type Bar <: {def bar(): Unit} with Foo
在我看来很自然,Bar 应该同时具有 foo() 和 bar()。
【问题讨论】:
-
Dotty 似乎允许这样做。
-
顺便说一下,
<:不是扩展(继承)而是子类型化。 cmi.ac.in/~madhavan/courses/pl2009/lecturenotes/lecture-notes/…
标签: scala types structural-typing compound-type