nfrankel
10/06/2016, 7:58 PMpublic class MenuBar extends AbstractComponent implements LegacyComponent, Focusable {
public interface Command extends Serializable {
public void menuSelected(MenuBar.MenuItem selectedItem);
}
public MenuBar.MenuItem addItem(String caption, MenuBar.Command command) {
return addItem(caption, null, command);
}
// bla bla
}
now i want to create an extension method that accepts a lambda instead of a command:
fun MenuItem.menuItem(caption: String, icon: Resource? = null,
onClick: (MenuBar.MenuItem) -> Unit = {}) = addItem(caption, icon, onClick)
but the compiler complains:
Type mismatch: inferred type is (MenuBar.MenuItem) -> Unit but MenuBar.Command! was expected
i thought (and checked) that SAM conversions are automatic from kotlin to java
(https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions)
does anyone have a clue?