diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2019-04-08 13:14:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-08 13:14:39 +0200 |
commit | 24c92a5939002ecbadefbc5f93c2c8cc371d8b72 (patch) | |
tree | e846057269d2774850af5baa75cb1b3edf7cf8aa /src/vm/methodtablebuilder.cpp | |
parent | 67e8c9ba99ea32339e2df59d9615a88851fa6dc7 (diff) | |
download | coreclr-24c92a5939002ecbadefbc5f93c2c8cc371d8b72.tar.gz coreclr-24c92a5939002ecbadefbc5f93c2c8cc371d8b72.tar.bz2 coreclr-24c92a5939002ecbadefbc5f93c2c8cc371d8b72.zip |
Allow reabstraction of default interface methods (#23313)
Allow the runtime to load types with incomplete interface implementations. With this change, we allow (in pseudo-C#):
```csharp
interface IFoo { void Frob() { } }
interface IBar : IFoo { abstract void IFoo.Frob() }
class Fooer : IBar { }
```
Calling IFoo.Frob on an instance of `Fooer` will result in new exception being thrown because the default implementation of `IFoo.Frob` was re-abstracted by `IBar`.
Diffstat (limited to 'src/vm/methodtablebuilder.cpp')
-rw-r--r-- | src/vm/methodtablebuilder.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp index b9460264c3..286cd74c0a 100644 --- a/src/vm/methodtablebuilder.cpp +++ b/src/vm/methodtablebuilder.cpp @@ -10772,6 +10772,18 @@ BOOL MethodTableBuilder::HasDefaultInterfaceImplementation(bmtRTType *pDeclType, if (!pDeclMD->IsAbstract()) return TRUE; + // If the method is an abstract MethodImpl, this is a reabstraction: + // + // interface IFoo { void Frob() { } } + // interface IBar : IFoo { abstract void IFoo.Frob() } + // + // We don't require these to have an implementation because they're final anyway. + if (pDeclMD->IsMethodImpl()) + { + assert(pDeclMD->IsFinal()); + return TRUE; + } + int targetSlot = pDeclMD->GetSlot(); // Iterate over all the interfaces this type implements |