Bad code green - incorrect parameter type (0.5.275)

In the following code, the definition for a is correct. The definition
for b is incorrect (error shown at the bottom). The Scala plugin marks
the whole thing green.

Is there an existing YouTrack entry for this?

Donald

class TestStuff  {
   val a = Map[String, AnyRef](("userName", "bob"))
   val b = Map[String, AnyRef]("userName", "bob")
}


error: type mismatch;
found   : java.lang.String("userName")
required: (String, AnyRef)
val b = Map[String, AnyRef]("userName", "bob")

error: type mismatch;
found   : java.lang.String("bob")
required: (String, AnyRef)
val b = Map[String, AnyRef]("userName", "bob")

1 comment

Your code is something like this one:

def foo[T, K](x: (T, K)) = 1 foo[String, String]("1", "2")


And this code compiles well, because of very controversial Scala feature: tupling.
However your case is different, and it's like (which is not compiles):

def foo[T, K](x: (T, K)*) = 1 foo[String, String]("1", "2")


There is no any information (except compiler) about why here we can't use tupling (so it can be possible that it's compiler bug, but I think less tumpling is better...).
So you can see that this is very specific bug (and I don't remeber such reports). I mean you can create a ticket for any bug, becuase usually actual problem is very unexpected.

Best regards,
Alexander Podkhalyuzin.
0

Please sign in to leave a comment.