hey guys i've a problem regarding SAM conversion b...
# announcements
n
hey guys i've a problem regarding SAM conversion between kotlin and java i've an inner interface defined in a class
Copy code
public 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:
Copy code
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?