Created
July 30, 2020 05:00
-
-
Save lawrence-laz/fc7f3739614da5539ea063608d5d1c38 to your computer and use it in GitHub Desktop.
Weakpoint of generic overload resolution in C#
This file contains hidden or 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
class Foo | |
{ | |
public static void Bar<TZoom>(TZoom zoom) where TZoom : IZoom { } | |
public static void Bar<TBoom, TLoom>(TBoom boom) where TBoom : IBoom<TLoom> { } | |
} | |
interface IZoom { } | |
interface IBoom<T> { } | |
class Zoom1 : IZoom { } | |
class Zoom2 : IZoom { } | |
class Boom1 : IBoom<Loom> { } | |
class Boom2 : IBoom<Loom> { } | |
class Loom { } | |
var boom = new Boom1(); | |
Foo.Bar(boom); // Error, cannot convert Boom1 to IZoom. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment