diff options
author | liu fengyun <liufengyunchina@gmail.com> | 2016-06-20 14:29:39 +0200 |
---|---|---|
committer | liu fengyun <liufengyunchina@gmail.com> | 2016-06-20 14:29:39 +0200 |
commit | cece884812143c6c8090ce08c6321bd4a1d52ea6 (patch) | |
tree | 2904ab37df31e7731b5ab638e9f6f5035e874cf0 /tests/pos/i1318.scala | |
parent | c7d1826cf0456e5efad5cb66ae06e7273c8a8e2a (diff) | |
download | dotty-cece884812143c6c8090ce08c6321bd4a1d52ea6.tar.gz dotty-cece884812143c6c8090ce08c6321bd4a1d52ea6.tar.bz2 dotty-cece884812143c6c8090ce08c6321bd4a1d52ea6.zip |
better handling of overloaded extractors
Diffstat (limited to 'tests/pos/i1318.scala')
-rw-r--r-- | tests/pos/i1318.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/pos/i1318.scala b/tests/pos/i1318.scala new file mode 100644 index 000000000..dfb882825 --- /dev/null +++ b/tests/pos/i1318.scala @@ -0,0 +1,38 @@ +object Foo { + class S(i: Int) + case class T(i: Int) extends S(i) + + object T { + def unapply(s: S): Option[(Int, Int)] = Some(5, 6) + // def unapply(o: Object): Option[(Int, Int, Int)] = Some(5, 6, 7) + } + + val s = new S(5) + + s match { + // case T(x, y, z) => println(x + y + z) + case T(x, y) => println(x + y) + case T(x) => println(x) + case _ => println("not match") + } +} + +object Bar { + case class T(i: Int) + class S(i: Int) extends T(i) + + object T { + def unapply(s: S): Option[(Int, Int)] = Some(5, 6) + // def unapply(o: Object): Option[(Int, Int, Int)] = Some(5, 6, 7) + } + + val s = new S(5) + + s match { + // case T(x, y, z) => println(x + y + z) + case T(x, y) => println(x + y) + case T(x) => println(x) + case _ => println("not match") + } +} + |