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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -