I'm using WartRemover tool to avoid possible errors in my Scala 2.11 code.
Specifically, I want to know how to fix the "Product Type Inferred" error.
Looking at the repo documentation, I can only see the failure example, but I would like to know how I'm suppose to fix that error:
https://github.com/puffnfresh/wartremover#product.
Doing my homework, I end up with this other link that explains how to fix Type Inference Failures errors https://blog.cppcabrera.com/posts/scala-wart-remover.html. And I quote "If you see any of the warnings below, the fix is usually as simple as providing type annotations" but I don't understand what that means. I really need a concrete example.
Product
is a very abstract, high-level type, with very few constraints. When the inferred type isProduct
, that's usually an indication that you made a mistake. E.g. if you have:Then this will compile ok, giving you a
List[Product]
. But, just as whenAny
is inferred, this is probably a bug - you probably meant it to be aList[(Int, String, Float)]
and meant to have a third entry in the middle tuple.If you really do want a
List[Product]
, you can avoid getting warned about it by giving the type argument explicitly: