Created
January 30, 2015 19:50
-
-
Save HaloFour/01beae1fb2071a30446d to your computer and use it in GitHub Desktop.
Covariance in MSIL/CIL
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
.assembly extern mscorlib { | |
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) | |
.ver 4:0:0:0 | |
} | |
.assembly Covariance { | |
.ver 1:0:0:0 | |
} | |
.module Covariance.exe | |
.subsystem 0x0003 | |
.class public auto ansi beforefieldinit Foo extends [mscorlib]System.Object { | |
.method public hidebysig newslot virtual instance class Foo DoSomething() cil managed | |
{ | |
.maxstack 1 | |
ldstr "Foo::DoSomething()" | |
call void [mscorlib]System.Console::WriteLine(string) | |
ldarg.0 | |
ret | |
} | |
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed | |
{ | |
.maxstack 1 | |
ldarg.0 | |
call instance void [mscorlib]System.Object::.ctor() | |
ret | |
} | |
} | |
.class public auto ansi beforefieldinit Bar extends Foo | |
{ | |
.method public hidebysig virtual instance class Bar DoSomething() cil managed | |
{ | |
.maxstack 1 | |
ldstr "Bar::DoSomething()" | |
call void [mscorlib]System.Console::WriteLine(string) | |
ldarg.0 | |
call instance class Foo Foo::DoSomething() | |
castclass Bar | |
ret | |
} | |
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed | |
{ | |
.maxstack 1 | |
ldarg.0 | |
call instance void Foo::.ctor() | |
ret | |
} | |
} | |
.class private abstract auto ansi sealed beforefieldinit Program extends [mscorlib]System.Object | |
{ | |
.method private hidebysig static void Main() cil managed | |
{ | |
.entrypoint | |
.maxstack 1 | |
.locals init ( | |
class Bar bar1, | |
class Bar bar2 | |
) | |
newobj instance void Bar::.ctor() | |
stloc.0 | |
ldloc.0 | |
callvirt instance class Bar Bar::DoSomething() | |
stloc.1 | |
ret | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment