diff options
Diffstat (limited to 'tests/pos/infersingle.scala')
-rw-r--r-- | tests/pos/infersingle.scala | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/pos/infersingle.scala b/tests/pos/infersingle.scala new file mode 100644 index 000000000..60f4ff07e --- /dev/null +++ b/tests/pos/infersingle.scala @@ -0,0 +1,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 + } +} |