[229] Invalid error on generic interface/generic type

Hello, this following (bad) example compiles (with warnings), but is
indicated as an error in R#:

public interface ICloneableGeneric : ICloneable { T Clone(); } public class CloneableList : List, ICloneableGeneric where T : ICloneableGeneric, IDisposable { T ICloneableGeneric.Clone]]>()
{
throw new Exception("The method or operation is not
implemented.");
}


object ICloneable.Clone()
{
throw new Exception("The method or operation is not
implemented.");
}
}


Thanks,

Wiebe Tijsma

3 comments
Comment actions Permalink

Though there are some problems in ReSharper (which will be fixed shortly),
you code is not compilable - method cannot have the type parameter named as
the type parameter of the interface

public interface ICloneableGeneric : ICloneable { T Clone(); } -- Eugene Pasynkov Developer JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!" "Wiebe Tijsma" ]]> wrote in message
news:e0dstu$n14$1@is.intellij.net...

Hello, this following (bad) example compiles (with warnings), but is
indicated as an error in R#:

>

public interface ICloneableGeneric<T> : ICloneable
{
T Clone<T>();
}

>

public class CloneableList<T> : List<T>, ICloneableGeneric<T> where T
: ICloneableGeneric<T>, IDisposable
{

>

T ICloneableGeneric<T>.Clone<T>()
{
throw new Exception("The method or operation is not
implemented.");
}

>
>

object ICloneable.Clone()
{
throw new Exception("The method or operation is not
implemented.");
}
}

>
>

Thanks,

>

Wiebe Tijsma



0
Comment actions Permalink

Eugene Pasynkov (JetBrains) wrote:

Though there are some problems in ReSharper (which will be fixed shortly),
you code is not compilable - method cannot have the type parameter named as
the type parameter of the interface

public interface ICloneableGeneric<T> : ICloneable
{
T Clone<T>();
}


I know it's trash code, it's just that Visual Studio compiles it with
warnings (it probably shouldn't), but R# gives the wrong error message
('interface not implemented')...

Thanks!

Wiebe

0
Comment actions Permalink

This code is not compilable!

Type parameters cannot have duplicate names

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Wiebe Tijsma" <wiebeREMOVE@CAPITALStijsma.com> wrote in message
news:e0gc02$k4i$1@is.intellij.net...

Eugene Pasynkov (JetBrains) wrote:

>> Though there are some problems in ReSharper (which will be fixed
>> shortly), you code is not compilable - method cannot have the type
>> parameter named as the type parameter of the interface
>>
>> public interface ICloneableGeneric : ICloneable >> { >> T Clone(); >> } >> >> >]]>

I know it's trash code, it's just that Visual Studio compiles it with
warnings (it probably shouldn't), but R# gives the wrong error message
('interface not implemented')...

>

Thanks!

>

Wiebe



0

Please sign in to leave a comment.