| 14277 | } |
| 14278 | |
| 14279 | bool BfModule::IsCompatibleInterfaceMethod(BfMethodInstance* iMethodInst, BfMethodInstance* methodInstance) |
| 14280 | { |
| 14281 | if ((iMethodInst->GetNumGenericParams() != 0) || (methodInstance->GetNumGenericParams() != 0)) |
| 14282 | return false; |
| 14283 | |
| 14284 | if (iMethodInst->mMethodDef->mName != methodInstance->mMethodDef->mName) |
| 14285 | return false; |
| 14286 | |
| 14287 | if (iMethodInst->mMethodDef->mIsOperator != methodInstance->mMethodDef->mIsOperator) |
| 14288 | return false; |
| 14289 | |
| 14290 | if (iMethodInst->mMethodDef->mIsOperator) |
| 14291 | { |
| 14292 | auto iOperatorDef = (BfOperatorDef*)iMethodInst->mMethodDef; |
| 14293 | auto operatorDef = (BfOperatorDef*)methodInstance->mMethodDef; |
| 14294 | |
| 14295 | if (iOperatorDef->mOperatorDeclaration->mUnaryOp != operatorDef->mOperatorDeclaration->mUnaryOp) |
| 14296 | return false; |
| 14297 | if (iOperatorDef->mOperatorDeclaration->mBinOp != operatorDef->mOperatorDeclaration->mBinOp) |
| 14298 | return false; |
| 14299 | } |
| 14300 | |
| 14301 | if (iMethodInst->GetParamCount() != methodInstance->GetParamCount()) |
| 14302 | return false; |
| 14303 | |
| 14304 | auto selfType = methodInstance->GetOwner(); |
| 14305 | for (int paramIdx = 0; paramIdx < (int)iMethodInst->GetParamCount(); paramIdx++) |
| 14306 | { |
| 14307 | if (iMethodInst->GetParamKind(paramIdx) != methodInstance->GetParamKind(paramIdx)) |
| 14308 | return false; |
| 14309 | |
| 14310 | BfType* iParamType = iMethodInst->GetParamType(paramIdx); |
| 14311 | BfType* methodParamType = methodInstance->GetParamType(paramIdx); |
| 14312 | |
| 14313 | iParamType = ResolveSelfType(iParamType, selfType); |
| 14314 | methodParamType = ResolveSelfType(methodParamType, selfType); |
| 14315 | |
| 14316 | if (!iParamType->IsGenericParam()) |
| 14317 | { |
| 14318 | if (methodParamType != iParamType) |
| 14319 | return false; |
| 14320 | } |
| 14321 | else |
| 14322 | { |
| 14323 | if (!methodParamType->IsGenericParam()) |
| 14324 | return false; |
| 14325 | |
| 14326 | auto genericParamType = (BfGenericParamType*)methodParamType; |
| 14327 | if (genericParamType->mGenericParamKind == BfGenericParamKind_Type) |
| 14328 | return false; |
| 14329 | |
| 14330 | auto genericParam = methodInstance->mMethodInfoEx->mGenericParams[genericParamType->mGenericParamIdx]; |
| 14331 | bool hadInterface = false; |
| 14332 | for (auto interfaceConstraint : genericParam->mInterfaceConstraints) |
| 14333 | if (interfaceConstraint == iParamType) |
| 14334 | hadInterface = true; |
| 14335 | if (!hadInterface) |
| 14336 | return false; |
nothing calls this directly
no test coverage detected