Function.identity returns different type?
    Timo Kinnunen 
    timo.kinnunen at gmail.com
       
    Wed Feb 26 02:14:00 PST 2014
    
    
  
Hi, 
What’s the deal here, how come the “asIf” version - same as “asIn” except the method “asGiven” inlined away - doesn’t compile?
  static <T> T asIn(T t) {    return asGiven(Function.identity(), t);  }
  static <T> T asIf(T t) {    return Function.identity().apply(t);  }
  static <S, T> T asGiven(Function<S, T> given, S s) {    return given.apply(s);  }
The compile error I get is:
error: incompatible types: Object cannot be converted to T
But there’s no mention Object in the code…
-- 
Have a nice day,
Timo.
Sent from Windows Mail
    
    
More information about the lambda-dev
mailing list