Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Bartels <benjamin@bartels.dev>2022-01-04 02:36:18 +0300
committerGitHub <noreply@github.com>2022-01-04 02:36:18 +0300
commitf97546bbc372e5a27575a89fb5aafd4ae4924b45 (patch)
tree81ef83a64377ef6c024a7d48dbd4d8bf63a3bfbd /src/tests/ilverify
parenta2b288d7da6a36164e5e556cd736ca50e0a9bc02 (diff)
Fixed ILVerify incorrectly flagging valid default interface implementations (#61185)
* Added logic for default interface method traversal to ILVerify method discovery * Added Tests for DefaultImplFix * Moved call to default interface impl resolution outside of ResolveInterfaceMethodTarget
Diffstat (limited to 'src/tests/ilverify')
-rw-r--r--src/tests/ilverify/ILTests/DefaultInterfaceMethod.il124
-rw-r--r--src/tests/ilverify/ILTests/DefaultInterfaceMethod.ilproj3
-rw-r--r--src/tests/ilverify/ILTests/InterfaceImplementation.il51
3 files changed, 127 insertions, 51 deletions
diff --git a/src/tests/ilverify/ILTests/DefaultInterfaceMethod.il b/src/tests/ilverify/ILTests/DefaultInterfaceMethod.il
new file mode 100644
index 00000000000..a33f5cdddbe
--- /dev/null
+++ b/src/tests/ilverify/ILTests/DefaultInterfaceMethod.il
@@ -0,0 +1,124 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+.assembly DefaultInterfaceMethod
+{
+}
+
+.assembly extern System.Runtime
+{
+}
+
+.class interface private auto ansi abstract IInterface
+{
+ .method public hidebysig newslot abstract virtual
+ instance void Method () cil managed
+ {
+ }
+}
+
+.class public auto ansi beforefieldinit ChildClassDoesNotImplementDefaultInterfaceMethod_ValidType_Valid
+ extends [System.Runtime]System.Object
+ implements IDefaultImplInterface
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [System.Runtime]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ }
+}
+
+.class public auto ansi beforefieldinit ChildClassDoesImplementDefaultInterfaceMethod_ValidType_Valid
+ extends [System.Runtime]System.Object
+ implements IDefaultImplInterface
+{
+ .method public final hidebysig newslot virtual
+ instance void DefaultImplementation () cil managed
+ {
+ .maxstack 8
+
+ IL_0000: ret
+ }
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [System.Runtime]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ }
+}
+
+.class interface public auto ansi abstract IDefaultImplInterface
+{
+ .method public hidebysig newslot virtual
+ instance void DefaultImplementation () cil managed
+ {
+ .maxstack 8
+
+ IL_0000: ret
+ }
+}
+
+.class interface public auto ansi abstract IInheritedDefaultImplInterface
+ implements IInterface
+{
+ .method private final hidebysig virtual
+ instance void IInterface.Method () cil managed
+ {
+ .override method instance void IInterface::Method()
+ .maxstack 8
+
+ IL_0001: ret
+ }
+}
+
+.class public auto ansi beforefieldinit ClassInheritsFromInterfaceWhereContractIsImplementedByDerivedInterface_ValidType_Valid
+ extends [System.Runtime]System.Object
+ implements IInheritedDefaultImplInterface, IInterface
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [System.Runtime]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ }
+}
+
+.class interface public auto ansi abstract IReabstractDefaultImplementation
+ implements IInheritedDefaultImplInterface, IInterface
+{
+ .method private final hidebysig abstract virtual
+ instance void IInterface.Method () cil managed
+ {
+ .override method instance void IInterface::Method()
+ }
+}
+
+.class public auto ansi beforefieldinit ChildClassInheritsFromInterfaceWithDefaultImplementationWhereChildInterfaceReabstractsInterfaceMethod_InvalidType_InterfaceMethodNotImplemented
+ extends [System.Runtime]System.Object
+ implements IReabstractDefaultImplementation, IInheritedDefaultImplInterface, IInterface
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [System.Runtime]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ }
+}
diff --git a/src/tests/ilverify/ILTests/DefaultInterfaceMethod.ilproj b/src/tests/ilverify/ILTests/DefaultInterfaceMethod.ilproj
new file mode 100644
index 00000000000..8e8765d14a5
--- /dev/null
+++ b/src/tests/ilverify/ILTests/DefaultInterfaceMethod.ilproj
@@ -0,0 +1,3 @@
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="ILTests.targets" />
+</Project>
diff --git a/src/tests/ilverify/ILTests/InterfaceImplementation.il b/src/tests/ilverify/ILTests/InterfaceImplementation.il
index 29f5c49b503..5264e54bbbe 100644
--- a/src/tests/ilverify/ILTests/InterfaceImplementation.il
+++ b/src/tests/ilverify/ILTests/InterfaceImplementation.il
@@ -448,54 +448,3 @@
{
}
}
-
-.class public auto ansi beforefieldinit ChildClassDoesNotImplementDefaultInterfaceMethod_ValidType_Valid
- extends [System.Runtime]System.Object
- implements IDefaultImplInterface
-{
- .method public hidebysig specialname rtspecialname
- instance void .ctor () cil managed
- {
- .maxstack 8
-
- IL_0000: ldarg.0
- IL_0001: call instance void [System.Runtime]System.Object::.ctor()
- IL_0006: nop
- IL_0007: ret
- }
-}
-
-.class public auto ansi beforefieldinit ChildClassDoesImplementDefaultInterfaceMethod_ValidType_Valid
- extends [System.Runtime]System.Object
- implements IDefaultImplInterface
-{
- .method public final hidebysig newslot virtual
- instance void DefaultImplementation () cil managed
- {
- .maxstack 8
-
- IL_0000: ret
- }
-
- .method public hidebysig specialname rtspecialname
- instance void .ctor () cil managed
- {
- .maxstack 8
-
- IL_0000: ldarg.0
- IL_0001: call instance void [System.Runtime]System.Object::.ctor()
- IL_0006: nop
- IL_0007: ret
- }
-}
-
-.class interface public auto ansi abstract IDefaultImplInterface
-{
- .method public hidebysig newslot virtual
- instance void DefaultImplementation () cil managed
- {
- .maxstack 8
-
- IL_0000: ret
- }
-} \ No newline at end of file