我有一个用 MVC 风格编写的项目。视图如下所示:
trait BaseView {
def asComponent(): Component // each view can be displayed on screen
}
class ConcreteView extends Panel with BaseView {
def asComponent(): Component = this //ConcreteView is itself Component because it extends Panel
}
可以更改此代码以使用从ConcreteView
to的隐式转换Component
?所以我可以在不调用方法的情况下使用ConcreteView
as Component
(由于隐式转换) ConcreteView#asComponent
?