diff --git a/BeefLibs/corlib/src/Reflection/TypeInstance.bf b/BeefLibs/corlib/src/Reflection/TypeInstance.bf index cf7ebd3e..7099a05e 100644 --- a/BeefLibs/corlib/src/Reflection/TypeInstance.bf +++ b/BeefLibs/corlib/src/Reflection/TypeInstance.bf @@ -56,22 +56,6 @@ namespace System.Reflection { extension TypeInstance { - public override Result 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); diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 9fc1a414..205322b0 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -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) { diff --git a/IDEHelper/Tests/src/Extensions.bf b/IDEHelper/Tests/src/Extensions.bf index 8a2b897c..91874ef1 100644 --- a/IDEHelper/Tests/src/Extensions.bf +++ b/IDEHelper/Tests/src/Extensions.bf @@ -94,6 +94,17 @@ namespace Tests } } + class ClassC + { + public extern void MethodA(); + public void MethodB() => MethodA(); + } + + extension ClassC + { + public override void MethodA() { } + } + class TClassA 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]