[Mono-dev] Compiler bug with Generics and where constraints
sontek at gmail.com
Mon Jul 16 20:13:35 EDT 2007
On 7/16/07, Adar Wesley <adar.wesley at gmail.com> wrote:
> Hi John,
> It seams to me there is a problem with the code. (I don't know if it
> worked before)
> 1. protected static T
> GetBusinessQueryObjectFromReader<T>(IDataReader reader)
> 2. 74 where T : BusinessQueryObject, new()
> The generic parameter T is contained. However in:
> public override T GetQueryObjects<T>(string query, params
> QueryParameter parameters)
> T is not constrained.
> When you try to call GetBusinessQueryObjectFromReader<T>(IDataReader
> from within GetQueryObjects<T> with the same generic parameter you get the
> Either add the same constraint on T in the decleration of
> GetQueryObjects<T> or remove
> the constraint from GetBusinessQueryObjectFromReader<T>.
The constraint is inherited and you can't add a constraint to a method that
you are overriding (because you inherited it)
but I found the actual cause of the problem, Its when passing the generic
type through an anonymous delegate.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list