我正在实现一个 Swing 组件,我想克服Reactor
. 所以我认为这会起作用:
trait Foo[A] extends scala.swing.Publisher {
final case class Bar(parent: Vector[A], children: A*) extends scala.swing.event.Event
}
trait Test {
val foo: Foo[Int]
foo.reactions += {
case foo.Bar(parent, children) => {
println(parent.sum - children)
}
}
}
不幸的是,这给了我两个编译器警告:
The outer reference in this type test cannot be checked at run time.
final case class Bar(parent: Vector[A], children: A*) extends scala.swing.event.Event
^
The outer reference in this type test cannot be checked at run time.
case foo.Bar(parent, children) => {
^
我应该忽略这些警告吗?我可以压制他们吗?我应该改变设计吗?