Aladdin - Scala Bugtracking
[#1161] project: compiler priority: low category: missing feature
submitter assigned to status date submitted
Nikolay Martin open 2007-06-01 09:06:24.0
subject [contrib #624] type inference needed help
code
/*
This issue is very minor, I'm only raising it in case it indicates an unexpected problem. I'm testing with the nightly snapshot 2.5.0.11868.20070531-045012


Martin:

Many thanks for the change you recently made for 'bug' #1119 "equivalent to requires for virtual types"

(It achieves what I was requesting: 
 In 2.5.0-final, derived classes might have to provide both a type selfType and a value self. 
 Now with your change, they only have to provide selfType.)

Regards,
Eric.
*/

class O
{
}

abstract class Factory
{
    type clientType

    def create(client: clientType): O
}

trait Client
{
    type selfType >: this.type <: Client

    def factories: List[Factory { type clientType >: selfType }] = Nil // no factories by default

    // works
    private val self: selfType = this
    def selfOutputs: List[O] = factories.map(_.create(self))

    // works
    def annotatedThisOutputs: List[O] = factories.map(_.create(this: selfType))

    // does not compile
    def thisOutputs: List[O] = factories.map(_.create(this))
}
what happened
error: type mismatch;
 found   : Client
 required: x$1.clientType
    def thisOutputs: List[O] = factories.map(_.create(this))
                                                      ^
one error found
what expected successful compilation
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-06-01 09:07:04.0