Reputation: 27455
I have the following trait:
trait F{
type T
}
and
trait C[T]{
def getF: F{ type T = //I want the outer T}
}
Is there a way to refer to the generic type argument without introducing helper type
variable and renaming the type parameter?
Upvotes: 1
Views: 47
Reputation: 40510
If you weren't so inclined to call all types T
, you could just do
trait C[Foo] {
def getF: F { type T = Foo }
}
Upvotes: 1
Reputation: 10710
It seems like in Dotty you can do so (see http://dotty.epfl.ch/docs/internals/higher-kinded-v2.html) :
trait C[type T]{ self =>
def getF: F{ type T = self.T }
}
Otherwise for the current scala version I don't know if it is feasible to do better than introducing an helper type
variable:
trait C[T]{
type A = T
def getF: F{ type T = A }
}
Upvotes: 2