| 26860 | } |
| 26861 | |
| 26862 | bool BfModule::SlotInterfaceMethod(BfMethodInstance* methodInstance) |
| 26863 | { |
| 26864 | auto typeInstance = mCurTypeInstance; |
| 26865 | auto methodDef = methodInstance->mMethodDef; |
| 26866 | |
| 26867 | if (methodDef->mMethodType == BfMethodType_Ctor) |
| 26868 | return true; |
| 26869 | |
| 26870 | bool foundOverride = false; |
| 26871 | |
| 26872 | if ((methodDef->mBody == NULL) && (methodDef->mProtection == BfProtection_Private)) |
| 26873 | { |
| 26874 | auto methodDeclaration = methodDef->GetMethodDeclaration(); |
| 26875 | BfAstNode* refNode = NULL; |
| 26876 | if (auto propertyDeclaration = methodDef->GetPropertyDeclaration()) |
| 26877 | refNode = propertyDeclaration->mProtectionSpecifier; |
| 26878 | else if (methodDeclaration != NULL) |
| 26879 | refNode = methodDeclaration->mProtectionSpecifier; |
| 26880 | Fail("Private interface methods must provide a body", refNode); |
| 26881 | } |
| 26882 | |
| 26883 | if ((methodInstance->mMethodInfoEx != NULL) && (methodInstance->mMethodInfoEx->mExplicitInterface != NULL) && (!methodDef->mIsOverride)) |
| 26884 | { |
| 26885 | Fail("Explicit interfaces can only be specified for overrides in interface declarations", methodDef->GetMethodDeclaration()->mExplicitInterface); |
| 26886 | } |
| 26887 | |
| 26888 | BfAstNode* declaringNode = methodDef->GetRefNode(); |
| 26889 | |
| 26890 | for (auto& ifaceTypeInst : typeInstance->mInterfaces) |
| 26891 | { |
| 26892 | auto ifaceInst = ifaceTypeInst.mInterfaceType; |
| 26893 | int startIdx = ifaceTypeInst.mStartInterfaceTableIdx; |
| 26894 | int iMethodCount = (int)ifaceInst->mMethodInstanceGroups.size(); |
| 26895 | |
| 26896 | if ((methodInstance->mMethodInfoEx != NULL) && (methodInstance->mMethodInfoEx->mExplicitInterface != NULL) && (methodInstance->mMethodInfoEx->mExplicitInterface != ifaceInst)) |
| 26897 | continue; |
| 26898 | |
| 26899 | ifaceInst->mTypeDef->PopulateMemberSets(); |
| 26900 | BfMethodDef* nextMethod = NULL; |
| 26901 | BfMemberSetEntry* entry = NULL; |
| 26902 | if (ifaceInst->mTypeDef->mMethodSet.TryGet(BfMemberSetEntry(methodDef), &entry)) |
| 26903 | nextMethod = (BfMethodDef*)entry->mMemberDef; |
| 26904 | |
| 26905 | while (nextMethod != NULL) |
| 26906 | { |
| 26907 | auto checkMethod = nextMethod; |
| 26908 | nextMethod = nextMethod->mNextWithSameName; |
| 26909 | |
| 26910 | auto ifaceMethod = ifaceInst->mMethodInstanceGroups[checkMethod->mIdx].mDefault; |
| 26911 | if (ifaceMethod == NULL) |
| 26912 | continue; |
| 26913 | if (CompareMethodSignatures(ifaceMethod, methodInstance)) |
| 26914 | { |
| 26915 | if (methodDef->mIsOverride) |
| 26916 | { |
| 26917 | if (ifaceMethod->mMethodDef->mProtection == BfProtection_Private) |
| 26918 | { |
| 26919 | auto error = Fail(StrFormat("Interface method '%s' cannot override private interface method '%s'", MethodToString(methodInstance).c_str(), MethodToString(ifaceMethod).c_str()), declaringNode); |
nothing calls this directly
no test coverage detected