A reference to a generic type type obscured by an abstract type element

Is there a way to refer to a parameter of a general type that is obscured by a member of an abstract type with the same name?

Suppose we have a class and an extension class:

trait Foo {
    type T
    var get: T = _
}

class Bar[X] extends Foo {
    override type T = X //We can set the type member by referencing the generic parameter X
}

class Baz[T] extends Foo {
    override type T = ??? //How can we reference the generic parameter T here?
}

Obviously, it is usually not easy to name a general parameter that is different from a type member, but this is not always the best option (for example, when using an external library). Is there a way to refer to a shaded general parameter? Where in the Scala spec is this interaction between type members and common parameters?

+4
source share
1 answer

trait T , . , SI-8421. , :

. . , , Template PackageDef.

, , .

, , ( 2.12.0-M2) , .

+1

All Articles