Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Possible false positive for inferred type #24

Closed
dinoboy197 opened this issue Sep 17, 2015 · 4 comments
Closed

Possible false positive for inferred type #24

dinoboy197 opened this issue Sep 17, 2015 · 4 comments

Comments

@dinoboy197
Copy link

val base = scala.collection.mutable.Map[String, Any](
  "review_id" -> "abcd"
)

linter reports:
Inferred type scala.collection.mutable.Map[String,Any]. (This might not be what you've intended)

I did certainly intend to have a Map[String, Any].

@jawshooah
Copy link

The problem is that the type of base is still inferred, since it is not explicitly annotated.

Seems like the solution is this:

import scala.collection.mutable.{ Map => MutableMap }

val base: MutableMap[String, Any] = MutableMap(
  "review_id" -> "abcd"
)

@HairyFotr
Copy link
Owner

This does work, but the type is obvious above so I'll try to fix the check. I think I have a few similar examples stashed somewhere...

Can't promise when I'll find the time to do it though, sorry.

@dinoboy197
Copy link
Author

@HairyFotr much appreciated!

HairyFotr added a commit that referenced this issue Nov 6, 2015
@HairyFotr
Copy link
Owner

Ah, this case was already covered, but only for one type parameter. Should be fixed now.

Thanks again for reporting!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants