From 951667d5ee2a7c2e0467854bea1156470651c752 Mon Sep 17 00:00:00 2001 From: buraq Date: Fri, 18 Feb 2005 18:33:15 +0000 Subject: new test case for sequence convention in patter... new test case for sequence convention in pattern matching --- test/files/run/regularpatmat.check | 1 + test/files/run/regularpatmat.scala | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'test/files') diff --git a/test/files/run/regularpatmat.check b/test/files/run/regularpatmat.check index cc902ea473..ad48fcaf98 100644 --- a/test/files/run/regularpatmat.check +++ b/test/files/run/regularpatmat.check @@ -118,3 +118,4 @@ passed ok passed ok passed ok passed ok +testBugSequenceApply hello hello \ No newline at end of file diff --git a/test/files/run/regularpatmat.scala b/test/files/run/regularpatmat.scala index b5c345cf2d..8d4bb00b6e 100644 --- a/test/files/run/regularpatmat.scala +++ b/test/files/run/regularpatmat.scala @@ -20,7 +20,7 @@ object Test { testBO.main( args ); testMZ.main; //testNN.main; - () + testBugSequenceApply.main; } } @@ -716,3 +716,29 @@ object testNO { // this does not need to be run, only compiled } + +/** see comments in scala.tools.scalac.transformer.matching.PatternMatcher::isSeqApply 2005-02-17 + */ +object testBugSequenceApply { + + val x = List(1,2,3); + + case class ThreeBars extends Seq[Int] { + override def length = 3; + def elements = x.elements; + def apply(i:Int) = x.apply(i); + } + + // this works + def main:Unit = { + Console.print("testBugSequenceApply "); + val z: Seq[Int] = new ThreeBars(); + Console.print(z.match { + case Seq(1,2,3) => "hello" // but ThreeBars is a case class... + }); + + Console.print(ThreeBars().match { + case Seq(1,2,3) => " hello" // but ThreeBars is a case class... + }); + } +} -- cgit v1.2.3