Aladdin - Scala Bugtracking
[#881] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-01-08 23:14:07.0
subject [contrib #289] unapply discards type path
code
object Foo
{
    class Bar(val x : String)
    def p(b : Bar) = Console.println(b.x)

    def unapply(s : String) : Option[Tuple1[Bar]] =
        Some(Tuple1(new Bar(s)))
}

object Test
{
    def main(argv : Array[String]) = {
        "baz" match {
            case Foo(x) =>
                Foo.p(x)
        }
    }
}
what happened
/home/jwebb/tests/test.scala:15 error: type mismatch;
 found   : Foo#Bar
 required: Foo.Bar
                                Foo.p(x)
                                      ^
one error found
what expected Silent compile.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-01-08 23:14:34.0
contribution #289
Martin  edited on  2007-01-09 14:27:03.0
Burak  edited on  2007-01-19 16:03:44.0
Martin, it's your memberType implementation that turns result the unapp.tpe (...)Option[Foo.this.Bar] into unappType (...)Option[Foo#Bar]. I guess it should preserve the result type, given that Foo is an object and Bar is a class?
Martin  edited on  2007-03-08 10:47:07.0