blob: a1ee077fe799e93c70e9b85970bfbe0844f572a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import language.existentials
class Result[+A]
case class Success[A](x: A) extends Result[A]
class Apply[A]
object Apply {
def apply[A](f: Int => Result[A]): Apply[A] = new Apply[A]
}
object TestUnit {
//Error is here:
def goo = Apply { i =>
i match {
case 1 => Success(Some(1))
case _ => Success(None)
}
}
//If type is defined explicitly (which I wanted from compiler to infer), then all is ok
def foo = Apply[t forSome { type t >: Some[Int] with None.type <: Option[Int] }] { i =>
i match {
case 1 => Success(Some(1))
case _ => Success(None)
}
}
}
|