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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
object Test1 {
def one[T](x: T): Option[T] = Some(x)
val x = "one"
val y: Option[x.type] = one(x)
}
object Test2 {
// Has never worked, but seems desirable given the recent changes to
// pattern type inference.
val a = ""
object Id {
def unapply(xxxx: Any): Some[a.type] = Some[a.type](a)
}
val b: a.type = (a: a.type) match {
case Id(x) => x
}
}
object Test3 {
val a = ""
object Id {
def unapply(xxxx: Any): Some[Test3.type] = Some[Test3.type](Test3)
}
val b: Test3.type = a match {
case Id(x) => x
}
}
class Test4 {
val a = ""
object Id {
def unapply(xxxx: Any): Some[Test4.this.type] = Some[Test4.this.type](Test4.this)
}
val b: Test4.this.type = a match {
case Id(x) => x
}
}
class Super5 {
final val q = ""
def q1: q.type = q
}
class Test5 extends Super5 {
val a = ""
object Id {
def unapply(xxxx: Any): Some[Test5.super.q.type] = Some[Test5.super.q.type](q1)
}
val b: Test5.super.q.type = a match {
case Id(x) => x
}
}
|