我有一些隐式方法来创建通用表列(javafx)。 这一切都很好:
trait TableColumnTrait[T] {def createColumn(key: String, displayName: String): TableColumn[PricingRow, T]}
然后是前..
sealed class PricingStage[PT] extends LoggingTrait {
implicit object TableColumnString extends TableColumnTrait[String] {
override def createColumn(key: String, displayName: String): TableColumn[PricingRow, String] = {
info("createColumn for String (" + key + ", " + displayName + ")")
new TableColumn[PricingRow, String](displayName)
}
}
但是,在PricingStage中,我想将创建的列存储在地图中,以便我声明:
var columns = Map[String, TableColumn[PricingRow, TableColumn[PricingRow, PT]]]()
private def createColumn[T: TableColumnTrait](key: String, displayName: String) = {
val column = implicitly[TableColumnTrait[T]].createColumn(key, displayName)
columns += key -> column
pricingTable.getColumns().addAll(column)
}
但是编译器抱怨道:
描述资源路径位置类型不匹配;发现: javafx.scene.control.TableColumn [org.cobra.client.main.PricingRow,T] 需要: javafx.scene.control.TableColumn [org.cobra.client.main.PricingRow,javafx.scene.control.TableColumn [org.cobra.client.main.PricingRow,PT]] PricingStage.scala / Cobra / client / org / cobra / client / main line 47斯卡拉问题
有什么想法吗?