Subject: Re: [scala-user] Command pattern with parametrized return type and variance For reference, The Book has explanatory material in 19.4, 19.5. http://www.artima.com/pins1ed/type-parameterization.html On Tue, Feb 21, 2012 at 12:36 PM, Adam Warski <adam@xxxxxxxxxx> wrote: > Hello, > > I have a (sealed) series of commands, each of which has a different return > type. The basic trait is a Command[R], where R is the return type. > There is then a command executor, which has a def execute[R](cmd: > Command[R]): R, and executes an action appropriate for a command using > pattern matching. > All works well until I add a variance annotation (+R) to the trait: > > https://gist.github.com/1878718 > > Any ideas why? :) > > Thanks, > Adam > |