Open scabug opened 9 years ago
Imported From: https://issues.scala-lang.org/browse/SI-8983?orig=1 Reporter: stefan.wachter-at-gmx.de Affected Versions: 2.11.4
Correct me if I'm wrong, but I think this is a more self contained example of more or less the same problem:
val ok: Iterable[Boolean] = {
val a = Option(Option(true)).flatten
a
}
val err: Iterable[Boolean] = Option(Option(true)).flatten //error: polymorphic expression cannot be instantiated to expected type
(works in dotty)
Type inference fails if an expression is directly assigned to a value but succeeds if the very same expression is first assigned to an intermediary value and then to the actual value.
Comment to grasp the example code more quickly
The idea is to enable parser combinators to work with Shapeless HLists. An ordinary Parser[O] can be lifted into a Parser[O :: HNil]. Parsers are augmented with an "::" operation that allows to join two Parsers. The HListParser typeclass allows the join operation to work uniformly irrespective of where a parser works on HLists or not.
Example Code