From: Michal Strehovský Date: Tue, 30 Jan 2018 20:08:58 +0000 (+0100) Subject: Move the MethodImpl iterator when checking default interface methods (#16099) X-Git-Tag: accepted/tizen/unified/20190422.045933~3158 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51c63b16bafe1f3f34e7f47dc12f722ebee4d432;p=platform%2Fupstream%2Fcoreclr.git Move the MethodImpl iterator when checking default interface methods (#16099) Fixes #16064. --- diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp index 9308844..1d58704 100644 --- a/src/vm/methodtablebuilder.cpp +++ b/src/vm/methodtablebuilder.cpp @@ -10821,7 +10821,7 @@ BOOL MethodTableBuilder::HasDefaultInterfaceImplementation(MethodDesc *pDeclMD) if (pMD->IsMethodImpl()) { MethodImpl::Iterator it(pMD); - while (it.IsValid()) + for (; it.IsValid(); it.Next()) { if (it.GetMethodDesc() == pDeclMD) return TRUE; diff --git a/tests/src/Regressions/coreclr/16064/methodimpl.il b/tests/src/Regressions/coreclr/16064/methodimpl.il new file mode 100644 index 0000000..289f8ad --- /dev/null +++ b/tests/src/Regressions/coreclr/16064/methodimpl.il @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +.assembly extern System.Runtime { } + +.assembly methodimpl { } + +.class interface private abstract auto ansi IFoo +{ + .method public hidebysig newslot virtual abstract instance int32 Frob() cil managed + { + } + + .method public hidebysig newslot virtual abstract instance int32 Unrelated() cil managed + { + } +} + +.class interface private abstract auto ansi IBar + implements IFoo +{ + .method public hidebysig newslot virtual final instance int32 Frob() cil managed + { + .override IFoo::Frob + .override IFoo::Unrelated + ldc.i4 50 + ret + } +} + +.class private auto ansi beforefieldinit Fooer + extends [System.Runtime]System.Object + implements IBar +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + ldarg.0 + call instance void [System.Runtime]System.Object::.ctor() + ret + } +} + +.method public hidebysig static int32 Main() cil managed +{ + .entrypoint + ldstr "DefaultImplementationsOfInterfaces" + call bool [System.Runtime]System.Runtime.CompilerServices.RuntimeFeature::IsSupported(string) + + // If default interfaces are not supported, consider the test successful. + brtrue DoRunTest + ldc.i4 100 + ret + +DoRunTest: + newobj instance void Fooer::.ctor() + callvirt instance int32 IFoo::Frob() + newobj instance void Fooer::.ctor() + callvirt instance int32 IFoo::Unrelated() + add + ret +} diff --git a/tests/src/Regressions/coreclr/16064/methodimpl.ilproj b/tests/src/Regressions/coreclr/16064/methodimpl.ilproj new file mode 100644 index 0000000..32da058 --- /dev/null +++ b/tests/src/Regressions/coreclr/16064/methodimpl.ilproj @@ -0,0 +1,35 @@ + + + + + $(MSBuildProjectName) + Debug + AnyCPU + 2.0 + {85DFC527-4DB1-595E-A7D7-E94EE1F8140D} + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 7a9bfb7d + true + true + Exe + BuildAndRun + 0 + + + + + False + + + + + + + + + + + + +