Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I specify constraints on type members of type parameters?

Tags:

scala

Is it possible to defer type member constraints to the usage site?

trait Query {
  type Result
}

Pseudocode:

def fooRequiresAnyRefResults[Q <: Query, Q#Result <: AnyRef]()
like image 603
Lawrence Wagerfield Avatar asked Mar 02 '14 12:03

Lawrence Wagerfield


1 Answers

I can't test it right now, but this should work :

def f[Q <: Query {type Result <: AnyRef}]() = ...

like image 117
Marth Avatar answered Oct 22 '22 04:10

Marth