forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dim] Emit error when calling abstract methods (mono/mono#15433)
* Emitting bad image exception when a non virtual call is calling an abstract method. * Fixing side-effect. Implementing the same thing on interpreter. Adding unit test. Commit migrated from mono/mono@c011456
- Loading branch information
Showing
8 changed files
with
155 additions
and
7 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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
|
||
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
|
||
|
||
// Metadata version: v4.0.30319.assembly extern mscorlib { } | ||
.assembly abstractcalls { } | ||
|
||
.class interface public abstract auto ansi I1 | ||
{ | ||
.method public hidebysig newslot virtual abstract | ||
instance int32 Add(int32 x) cil managed | ||
{ | ||
} | ||
} | ||
|
||
.class public abstract auto ansi C1 | ||
extends [mscorlib]System.Object | ||
implements I1 | ||
{ | ||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
ldarg.0 | ||
call instance void [mscorlib]System.Object::.ctor() | ||
ret | ||
} | ||
|
||
.method public hidebysig newslot virtual abstract | ||
instance int32 Remove(int32 x) cil managed | ||
{ | ||
} | ||
} | ||
|
||
.class public auto ansi C2 | ||
extends [mscorlib]System.Object | ||
implements I1 | ||
{ | ||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
ldarg.0 | ||
call instance void C1::.ctor() | ||
ret | ||
} | ||
|
||
.method public hidebysig virtual | ||
instance int32 Remove(int32 x) cil managed | ||
{ | ||
ldc.i4.0 | ||
ret | ||
} | ||
|
||
.method public hidebysig newslot virtual | ||
instance int32 Add(int32 x) cil managed | ||
{ | ||
ldc.i4.5 | ||
ret | ||
} | ||
} | ||
|
||
.method private hidebysig static void CallClass() cil managed | ||
{ | ||
newobj instance void C2::.ctor() | ||
ldc.i4.0 | ||
call instance int32 C1::Remove(int32) | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static void CallInterface() cil managed | ||
{ | ||
newobj instance void C2::.ctor() | ||
ldc.i4.0 | ||
call instance int32 I1::Add(int32) | ||
pop | ||
ret | ||
} | ||
|
||
.method private hidebysig static int32 Main() cil managed | ||
{ | ||
.entrypoint | ||
|
||
.try | ||
{ | ||
call void CallClass() | ||
leave Fail | ||
} | ||
catch [System.Runtime]System.BadImageFormatException | ||
{ | ||
leave AbstractClassOK | ||
} | ||
|
||
AbstractClassOK: | ||
|
||
.try | ||
{ | ||
call void CallInterface() | ||
leave Fail | ||
} | ||
catch [System.Runtime]System.BadImageFormatException | ||
{ | ||
leave AbstractInterfaceOK | ||
} | ||
|
||
AbstractInterfaceOK: | ||
ldc.i4 0 | ||
ret | ||
|
||
Fail: | ||
ldc.i4 155 | ||
ret | ||
} | ||
|