| 24550 | } |
| 24551 | |
| 24552 | void BfModule::StartMethodDeclaration(BfMethodInstance* methodInstance, BfMethodState* prevMethodState) |
| 24553 | { |
| 24554 | methodInstance->mHasStartedDeclaration = true; |
| 24555 | auto methodDef = methodInstance->mMethodDef; |
| 24556 | auto typeInstance = methodInstance->GetOwner(); |
| 24557 | |
| 24558 | bool hasNonGenericParams = false; |
| 24559 | bool hasGenericParams = false; |
| 24560 | |
| 24561 | int dependentGenericStartIdx = 0; |
| 24562 | |
| 24563 | if (methodDef->mIsLocalMethod) |
| 24564 | { |
| 24565 | // If we're a local generic method inside an outer generic method, we can still be considered unspecialized |
| 24566 | // if our outer method's generic args are specialized but ours are unspecialized. This is because locals get |
| 24567 | // instantiated uniquely for each specialized or unspecialized pass through the outer method, but the local |
| 24568 | // method still 'inherits' the outer's generic arguments -- but we still need to make an unspecialized pass |
| 24569 | // over the local method each time |
| 24570 | auto rootMethodInstance = prevMethodState->GetRootMethodState()->mMethodInstance; |
| 24571 | dependentGenericStartIdx = 0; |
| 24572 | if (rootMethodInstance != NULL) |
| 24573 | { |
| 24574 | if (rootMethodInstance->mMethodInfoEx != NULL) |
| 24575 | dependentGenericStartIdx = (int)rootMethodInstance->mMethodInfoEx->mMethodGenericArguments.size(); |
| 24576 | |
| 24577 | methodInstance->mIsUnspecialized = rootMethodInstance->mIsUnspecialized; |
| 24578 | methodInstance->mIsUnspecializedVariation = rootMethodInstance->mIsUnspecializedVariation; |
| 24579 | } |
| 24580 | } |
| 24581 | |
| 24582 | for (int genericArgIdx = dependentGenericStartIdx; genericArgIdx < (int)methodInstance->GetNumGenericArguments(); genericArgIdx++) |
| 24583 | { |
| 24584 | auto genericArgType = methodInstance->mMethodInfoEx->mMethodGenericArguments[genericArgIdx]; |
| 24585 | if (genericArgType->IsGenericParam()) |
| 24586 | { |
| 24587 | hasGenericParams = true; |
| 24588 | auto genericParam = (BfGenericParamType*)genericArgType; |
| 24589 | methodInstance->mIsUnspecialized = true; |
| 24590 | if ((genericParam->mGenericParamKind != BfGenericParamKind_Method) || (genericParam->mGenericParamIdx != genericArgIdx)) |
| 24591 | methodInstance->mIsUnspecializedVariation = true; |
| 24592 | } |
| 24593 | else |
| 24594 | { |
| 24595 | hasNonGenericParams = true; |
| 24596 | if (genericArgType->IsUnspecializedType()) |
| 24597 | { |
| 24598 | methodInstance->mIsUnspecialized = true; |
| 24599 | methodInstance->mIsUnspecializedVariation = true; |
| 24600 | } |
| 24601 | } |
| 24602 | } |
| 24603 | |
| 24604 | if ((hasGenericParams) && (hasNonGenericParams)) |
| 24605 | { |
| 24606 | methodInstance->mIsUnspecializedVariation = true; |
| 24607 | } |
| 24608 | |
| 24609 | if (typeInstance->IsUnspecializedType()) |
nothing calls this directly
no test coverage detected