If I define it using the concrete type `String` do...
# codereview
p
If I define it using the concrete type
String
doesn’t complaint don’t know why but it works ¯\_(ツ)_/¯ thanks @anstaendig 👍
a
pguardiola: is that a function type from Java8? i mean is the second generic the return type?
p
Not Java 8
Copy code
public static <T> PropertyValue<Function<T, String>> lineColor(Function<T, String> function) {
    return new PaintPropertyValue<>("line-color", function);
  }
a
@pguardiola how does
Function<I, O>
look like?
It's because of Java's raw types https://stackoverflow.com/a/2770692/1266326
a
@pguardiola It has nothing to do with raw types, its just a mismatch of the Generics. Imagine the follow:
Copy code
public class Function<I, O> {
    public O getPropertyValue() { }
}

public static <T> PropertyValue<Function<T, String>> lineColor(Function<T, String> function) {
    return new PaintPropertyValue<>("line-color", function);
}

private fun foo(bar: Function<Any, Any>) {
  lineColor(bar)
}

foo(Function<String, Int>())
The
lineColor
-Method expects your Function<> to return a String on
getPropertyValue
, but our
bar
returns an Int. Passing
Function<String, Int>
into
foo()
is perfectly fine, but passing it into
lineColor
doesn't work because of the different types of
O
p
I know but in Java you're able to pass
Function
(without specifying explicitly the generic types) because of Java's raw types
a
Yeah, kotlin is more restricitve in that matter
p
Yeah because it's 👌implemented 😋
👍 1