Scala 2.8奇怪的类型错误

时间:2010-05-20 12:20:25

标签: scala scala-2.8

类型:

def radioGroup[T](values: Array[T], textProvider: T => String)(setups:(RadioGroup[T] => Unit)*)(parent: Composite): RadioGroup[T]
def label(setups:(Label => Unit)*)(parent:Composite): Label

def contains(setups : (Composite => Unit)*) : Composite // "Pimp my library" on Composite

这有效:

new Composite(parent, SWT.NONE).contains(
  label() // should have type Composite => Label
)

这不是:

new Composite(parent, SWT.NONE).contains(
  radioGroup(Array(1,2), (_:Int).toString)() 
   // should have type Composite => RadioGroup[Int]
)

出现以下错误:

polymorphic expression cannot be instantiated to expected type;
found   : => (org.eclipse.swt.widgets.Composite) => main.scala.RadioGroup[Int]
required: (org.eclipse.swt.widgets.Composite) => Unit

我可以将radioGroup的返回类型注释为Unit,但我不明白1)radioGrouplabel的情况如何不同; 2)为什么错误消息中“找到”类型的开头有一个额外的箭头。

0 个答案:

没有答案
相关问题