-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mono] Check for additional implemented variant interfaces (#57086)
* [class-setup-vtable] Use flags bitmask in check_interface_method_override No funcitonal change yet. * [class-setup-vtable] Check additional slots when explicitly implementing 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 #48512 * oops, disable vtable tracing * Use explicit variant interface to implement base type interfaces
- Loading branch information
1 parent
b493278
commit eeee548
Showing
1 changed file
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters