Mam problem z niejawnymi konwersjami i funkcjami wyższego rzędu. Wydaje się, że niejawne konwersje funkcji na funkcję drugiego rzędu działają tylko wtedy, gdy funkcja konwersji ma co najmniej dwa parametry.Niejawna konwersja funkcji do funkcji drugiego rzędu działa tylko wtedy, gdy funkcja konwersji ma co najmniej dwa parametry.
Works:
implicit def conv(foo: Integer => String): String => String = null
nie działa:
implicit def conv(foo: Integer => String): String => String => String = null
działa:
implicit def conv(foo: (Integer, Integer) => String): String => String => String = null
Pełny przykład z punktu awarii:
{
implicit def conv(foo: Integer => String): String => String = null
def baadf00d(foo: Integer): String = null
def deadbeef(foo: String => String) = null
deadbeef(conv(baadf00d))
deadbeef(baadf00d)
}
{
implicit def conv(foo: Integer => String): String => String => String = null
def baadf00d(foo: Integer): String = null
def deadbeef(foo: String => String => String) = null
deadbeef(conv(baadf00d))
deadbeef(baadf00d) // <-------- DOES NOT COMPILE!
}
{
implicit def conv(foo: (Integer, Integer) => String): String => String => String = null
def baadf00d(foo: Integer, bar: Integer): String = null
def deadbeef(foo: String => String => String) = null
deadbeef(conv(baadf00d))
deadbeef(baadf00d)
}
Czego mi brakuje?
Dzięki!
Wygląda niejawny rozdzielczości brodawki w Scali do mnie. Która wersja Scala to jest? – gzm0