So does anyone know “wat” the following Scala code returns? (Value and Type)
A Set<Int> containing 1,2,3?
Nope how about I give you a clue, there are 2 bugs in this one line:
- A type inferencing bug where it chooses Set<Any>
- A bug where the brackets are used for both calling the Set.apply method and constructing Unit, notice there no space between the “toSet” and “()”
Yup you guessed it, it returns:
Wat? Try it in your repl and for even more fun check the bytecode out.
Looks like (“-Yno-adapted-args”, “Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.”) is your friend
Pete Kneller has done some really good analysis so you can see all the different weird combinations