[mono] Check for additional implemented variant interfaces#57086
[mono] Check for additional implemented variant interfaces#57086lambdageek merged 4 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: Issue DetailsIf a class implements a variant interface, consider whether it is explicitly implementing (as opposed to obtaining by being a subclass of some base class) some variant interfaces. Two examples: In this case, Conversely for contravariant gparams: In this case When this happens, the signature of the implementing method We should check the signature parameters of the candidate method and the implemented method, but I think the interface setup code already checks this for us. Fixes #48512
|
|
Test failures are related. I think I'm trashing some unrelated vtable entries. May need a signature check after all. |
…ride No funcitonal change yet.
…ing variant interfaces
If a class implements a variant interface, consider whether it is explicitly
implementing (as opposed to obtaining by being a subclass of some base class)
some variant interfaces.
Two examples:
public interface IFactory<out T> { T Get(); }
public class Foo {}
public class Bar : Foo {}
public class FooFactory : IFactory<Foo> { public Foo Get() => new Foo(); }
public class BarFactory : FooFactory, IFactory<Bar> { public new Bar Get() => new Bar(); }
In this case, BarFactory explicitly implements IFactory<Bar> and also
IFactory<Foo>.
Conversely for contravariant gparams:
interface ITaker<in T> { string Consume (T x); }
class Foo {}
class Bar : Foo {}
class BarTaker : ITaker<Bar> { public string Consume (Bar x) => "consumed Bar"; }
class FooTaker : BarTaker, ITaker<Foo> { public string Consume (Foo x) =>
"consumed Foo"; }
In this case FooTaker implements ITaker<Foo> but also ITaker<Bar>.
When this happens, the signature of the implementing method 'Bar
BarFactory:Get()' doesn't match the signature of the implemented interface
method 'Foo IFactory<Foo>:Get()'.
We should check the signature parameters of the candidate method and the
implemented method, but I think the interface setup code already checks this
for us.
Fixes dotnet#48512
ebbd614 to
022e2a7
Compare
If a class implements a variant interface, consider whether it is explicitly implementing (as opposed to obtaining by being a subclass of some base class) some variant interfaces.
Two examples:
In this case,
BarFactoryexplicitly implementsIFactory<Bar>and alsoIFactory<Foo>.Conversely for contravariant gparams:
In this case
FooTakerimplementsITaker<Foo>but alsoITaker<Bar>.When this happens, the signature of the implementing method
'Bar BarFactory:Get()'doesn't match the signature of the implemented interface method'Foo IFactory<Foo>:Get()'.We should check the signature parameters of the candidate method and the implemented method, but I think the interface setup code already checks this for us.
Fixes #48512