views:

86

answers:

0

Types:

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

This works:

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

This doesn't:

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

with the following error:

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

I can annotate the return type of radioGroup to be Unit, but I don't understand 1) how the cases of radioGroup and label can be different; 2) why is there an extra arrow at the beginning of the "found" type in the error message.