java - Incompatible types: Required: T Found: Object - IntelliJ -
there method (abbreviated) in project i'm working on:
public <t> t query( final extractor<t> extractor, final list result) { //... return extractor.extract(result) //... }
with extractor defined as:
public interface extractor<t> { t extract(list<map<string, object>> result); }
in eclipse there isn't error intellij refuses compile class incompatible types: required: t found: object
, way if cast return value t or return object instead , can't figure out why failing.
you need add type argument parameter:
query(final extractor<t> extractor, final list<map<string, object>> result){
the error message because of type mismatch(raw type). here docs raw type:
raw types show in legacy code because lots of api classes (such collections classes) not generic prior jdk 5.0. when using raw types, pre-generics behavior — box(in case list) gives objects. backward compatibility, assigning parameterized type raw type allowed
wiki
Comments
Post a Comment