Why is code that returns a genericized Map generating a compiler warning when assigned to a generic Map?

后端 未结 2 1624
庸人自扰
庸人自扰 2021-01-23 21:32

I have a method with this signature:

   protected final Map buildOutputMappings(
                                 AbstractDataObject ado, M         


        
相关标签:
2条回答
  • 2021-01-23 21:40

    my guess is that you are not using generics correctly in the subclass, and the compiler is disabling generics for the class. thus the return type for the buildOutputMappings call is being converted to the raw type and the warning is being generated. is the parent class parameterized? does the subclass include types for the parent classes parameters?

    In short, your error is most likely a dropped type parameter somewhere in the subclass or parent class.

    0 讨论(0)
  • 2021-01-23 21:49

    I have a feeling that your actual return statement is not matching your returning the correct type as indicated by your method definition. I can't be sure because you don't have the code included.

    0 讨论(0)
提交回复
热议问题