mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed mangling issue with method overrides in extensions
This commit is contained in:
parent
e2de5becab
commit
2e3880100b
3 changed files with 40 additions and 18 deletions
|
@ -56,22 +56,6 @@ namespace System.Reflection
|
|||
{
|
||||
extension TypeInstance
|
||||
{
|
||||
public override Result<FieldInfo> GetField(String fieldName)
|
||||
{
|
||||
for (int32 i = 0; i < mFieldDataCount; i++)
|
||||
{
|
||||
FieldData* fieldData = &mFieldDataPtr[i];
|
||||
if (fieldData.[Friend]mName == fieldName)
|
||||
return FieldInfo(this, fieldData);
|
||||
}
|
||||
return .Err;
|
||||
}
|
||||
|
||||
public override FieldInfo.Enumerator GetFields(BindingFlags bindingFlags = cDefaultLookup)
|
||||
{
|
||||
return FieldInfo.Enumerator(this, bindingFlags);
|
||||
}
|
||||
|
||||
public override MethodInfo.Enumerator GetMethods(BindingFlags bindingFlags = cDefaultLookup)
|
||||
{
|
||||
return MethodInfo.Enumerator(this, bindingFlags);
|
||||
|
|
|
@ -20248,8 +20248,32 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
|
|||
{
|
||||
if ((methodDef->mIsOverride) && (mCurTypeInstance->mTypeDef->mIsCombinedPartial))
|
||||
{
|
||||
BfLogSysM("Function collision from inner override erased prevFunc %p: %d\n", methodInstance, prevFunc.mId);
|
||||
mBfIRBuilder->Func_SafeRename(prevFunc);
|
||||
mCurTypeInstance->mTypeDef->PopulateMemberSets();
|
||||
BfMethodDef* nextMethod = NULL;
|
||||
BfMemberSetEntry* entry = NULL;
|
||||
if (mCurTypeInstance->mTypeDef->mMethodSet.TryGet(BfMemberSetEntry(methodDef), &entry))
|
||||
nextMethod = (BfMethodDef*)entry->mMemberDef;
|
||||
while (nextMethod != NULL)
|
||||
{
|
||||
auto checkMethod = nextMethod;
|
||||
nextMethod = nextMethod->mNextWithSameName;
|
||||
|
||||
if (checkMethod == methodDef)
|
||||
continue;
|
||||
auto checkMethodInstance = mCurTypeInstance->mMethodInstanceGroups[checkMethod->mIdx].mDefault;
|
||||
if (checkMethodInstance == NULL)
|
||||
continue;
|
||||
if (!CompareMethodSignatures(checkMethodInstance, mCurMethodInstance))
|
||||
continue;
|
||||
// Take over function
|
||||
mCurMethodInstance->mIRFunction = prevFunc;
|
||||
}
|
||||
|
||||
if (!mCurMethodInstance->mIRFunction)
|
||||
{
|
||||
BfLogSysM("Function collision from inner override erased prevFunc %p: %d\n", methodInstance, prevFunc.mId);
|
||||
mBfIRBuilder->Func_SafeRename(prevFunc);
|
||||
}
|
||||
}
|
||||
else if (methodDef->mIsExtern)
|
||||
{
|
||||
|
|
|
@ -94,6 +94,17 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
class ClassC
|
||||
{
|
||||
public extern void MethodA();
|
||||
public void MethodB() => MethodA();
|
||||
}
|
||||
|
||||
extension ClassC
|
||||
{
|
||||
public override void MethodA() { }
|
||||
}
|
||||
|
||||
class TClassA<T> where T : IDisposable
|
||||
{
|
||||
public int32 mA = 10;
|
||||
|
@ -167,6 +178,9 @@ namespace Tests
|
|||
ClassA ca = scope ClassA();
|
||||
ca.mA = 123;
|
||||
ca.mB = 234;
|
||||
|
||||
ClassC cc = scope .();
|
||||
cc.MethodB();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue