Sammy + wildcards + type inference = :(
Roman Janusz <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
Hello,
Is there any chance this will work?
$ scala -Xexperimental
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8
.0_40).
Type in expressions to have them evaluated.
Type :help for more information.
scala> new java.util.ArrayList[String]().stream.map(_.toInt)
<console>:8: error: no type parameters for method map: (x$1: java.util.
function.Function[_ >: String, _ <: R])java.util.stream.Stream[R] exist so
that it can be applied to arguments (java.util.function.Function[String,Int]
with Serializable)
--- because ---
argument expression's type is not compatible with formal parameter type;
found : java.util.function.Function[String,Int] with Serializable
required: java.util.function.Function[_ >: String, _ <: ?R]
Note: String <: Any (and java.util.function.Function[String,Int] with
Serializable <: java.util.function.Function[String,Int]), but Java-defined
trait Function is invariant in type T.
You may wish to investigate a wildcard type such as `_ <: Any`. (SLS 3.2.10)
new java.util.ArrayList[String]().stream.map(_.toInt)
^
<console>:8: error: type mismatch;
found : java.util.function.Function[String,Int] with Serializable
required: java.util.function.Function[_ >: String, _ <: R]
new java.util.ArrayList[String]().stream.map(_.toInt)
It would be a very disappointing limitation if it won't - it would negate
the most important promise of Sammy, which is good Java interop.
Thanks,
Roman
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.