Scala编译器构建错误JComboBox类型参数

时间:2011-11-09 16:27:57

标签: scala jcombobox build-error

所以我正在尝试编译scala编译器,我已经克服了许多问题,试图完成这项工作,但我目前陷入了quick.lib

这非常令人困惑,因为源代码直接来自scala团队,所以我知道它应该编译。还采用了我知道的旧版本在其他地方编译并测试了但是得到了同样的错误。

对此问题的任何帮助或正确方向的观点将不胜感激。

quick.lib:
[scalacfork] Compiling 103 files to C:\programming\scala\build\quick\classes\library
[scalacfork] C:\programming\scala\src\swing\scala\swing\ComboBox.scala:162: error: class JComboBox takes type parameters
[scalacfork]   override lazy val peer: JComboBox = new JComboBox(ComboBox.newConstantModel(items)) with SuperMixin
[scalacfork]                           ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ComboBox.scala:123: error: trait ComboBoxModel takes type parameters
[scalacfork]   def newConstantModel[A](items: Seq[A]): ComboBoxModel = {
[scalacfork]                                           ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ComboBox.scala:124: error: trait ComboBoxModel takes type parameters
[scalacfork]     new AbstractListModel with ComboBoxModel {
[scalacfork]                                ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ComboBox.scala:134: error: type mismatch;
[scalacfork]  found   : AnyRef
[scalacfork]  required: Nothing
[scalacfork]       def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
[scalacfork]                                                       ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ComboBox.scala:162: error: too many arguments for constructor Object: ()Object
[scalacfork]   override lazy val peer: JComboBox = new JComboBox(ComboBox.newConstantModel(items)) with SuperMixin
[scalacfork]                                           ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:32: error: trait ListCellRenderer takes type parameters
[scalacfork]     def wrap[A](r: ListCellRenderer): Renderer[A] = new Wrapped[A](r)
[scalacfork]                    ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:27: error: class JList takes type parameters
[scalacfork]   def wrap[A](c: JList) = new ListView[A] {
[scalacfork]                  ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:145: error: class JList takes type parameters
[scalacfork]   override lazy val peer: JList = new JList with SuperMixin
[scalacfork]                           ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:37: error: trait ListCellRenderer takes type parameters
[scalacfork]    class Wrapped[A](override val peer: ListCellRenderer) extends Renderer[A] {
[scalacfork]                                             ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:72: error: trait ListCellRenderer takes type parameters
[scalacfork]     def peer: ListCellRenderer = new ListCellRenderer {
[scalacfork]               ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:72: error: trait ListCellRenderer takes type parameters
[scalacfork]     def peer: ListCellRenderer = new ListCellRenderer {
[scalacfork]                                      ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:73: error: class JList takes type parameters
[scalacfork]       def getListCellRendererComponent(list: JList, a: Any, index: Int, isSelected: Boolean, focused: Boolean) = 
[scalacfork]                                              ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:126: error: trait ListCellRenderer takes type parameters
[scalacfork]     override lazy val peer: ListCellRenderer = new DefaultListCellRenderer
[scalacfork]                             ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:153: error: type mismatch;
[scalacfork]  found   : AnyRef
[scalacfork]  required: Nothing
[scalacfork]     def getElementAt(n: Int) = items(n).asInstanceOf[AnyRef]
[scalacfork]                                                     ^
[scalacfork] C:\programming\scala\src\swing\scala\swing\ListView.scala:195: error: too many arguments for constructor Object: ()Object
[scalacfork]     object indices extends Indices(peer.getSelectedIndices) {
[scalacfork]                    ^
[scalacfork] 15 errors found

1 个答案:

答案 0 :(得分:5)

您使用的是JDK7吗?关于“问题”的一个问题是JDK7在一些Swing API中添加了泛型,这与scala的工作方式不兼容。使用JDK6会有所帮助。

有关此问题的更多信息,请访问:https://groups.google.com/d/topic/scala-user/01CszZu8ga4/discussion