2011-11-09 74 views
3

所以我試圖編譯Scala編譯器,我已經克服了許多問題,試圖讓這個做,但我目前停留在quick.libScala編譯器生成錯誤的JComboBox類型參數

這是非常令人困惑源代碼是直接從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 

回答

5

您使用的是JDK7嗎? '問題'之一是JDK7爲一些Swing API添加了泛型,這與scala的工作方式不兼容。使用JDK6將有所幫助。

一點關於這個,可以發現在:https://groups.google.com/d/topic/scala-user/01CszZu8ga4/discussion

+0

我想這個回答我昨天的兩倍,但它不會讓我。原來的修復是切換到jdk6。爲了得到正確的答案,我做了很好的工作,但是我昨晚把它整理好了。只希望這個網站能讓我更快地回答我自己的問題= p很好的解釋,爲什麼它發生了。現在我明白了爲什麼。 – Blue42

+0

@ Blue42,在回答你自己的問題時你會鬆懈;) – Johnydep