mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed MethodToString for unspecialized type variations
This commit is contained in:
parent
f8175e84a1
commit
76cd052c4a
7 changed files with 41 additions and 17 deletions
|
@ -17,8 +17,6 @@ namespace IDETest
|
|||
{
|
||||
class Generics
|
||||
{
|
||||
|
||||
|
||||
public void Method1<T>(T val) where T : Array
|
||||
{
|
||||
|
||||
|
@ -38,5 +36,23 @@ namespace IDETest
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
interface IFaceA<T>
|
||||
{
|
||||
public void MethodA<M1>(T val, M1 val2, delegate T (M1 arg) val3);
|
||||
}
|
||||
|
||||
class ClassA<T1, T2> : IFaceA<(T1, T2)> //FAIL 'IDETest.Generics.ClassA<T1, T2>' does not implement interface member 'IDETest.Generics.IFaceA<(T1, T2)>.MethodA<M1>((T1, T2) val, M1 val2, delegate (T1, T2)(M1 arg) val3)'
|
||||
{
|
||||
void MethodA<M>(int a)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MethodB()
|
||||
{
|
||||
function void() f = => MethodA<T2>; //FAIL Method 'IDETest.Generics.ClassA<T1, T2>.MethodA<T2>(int a)' does not match function 'function void()'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4769,7 +4769,7 @@ void BfCompiler::GetSymbolReferences()
|
|||
// ++methodItr;
|
||||
}
|
||||
|
||||
if ((rebuildMethodInstance->mIsUnspecializedVariation) || (rebuildMethodInstance->IsSpecializedGenericMethod()))
|
||||
if ((rebuildMethodInstance->IsOrInUnspecializedVariation()) || (rebuildMethodInstance->IsSpecializedGenericMethod()))
|
||||
continue;
|
||||
|
||||
SetAndRestoreValue<BfMethodInstance*> prevTypeInstance(rebuildModule->mCurMethodInstance, rebuildMethodInstance);
|
||||
|
|
|
@ -7655,7 +7655,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
|
||||
bool isSkipCall = moduleMethodInstance.mMethodInstance->IsSkipCall(bypassVirtual);
|
||||
|
||||
if ((moduleMethodInstance.mMethodInstance->mIsUnspecializedVariation) && (!mModule->mBfIRBuilder->mIgnoreWrites))
|
||||
if ((moduleMethodInstance.mMethodInstance->IsOrInUnspecializedVariation()) && (!mModule->mBfIRBuilder->mIgnoreWrites))
|
||||
{
|
||||
// Invalid methods such as types with a HasVar tuple generic arg will be marked as mIsUnspecializedVariation and shouldn't actually be called
|
||||
FinishDeferredEvals(argValues.mResolvedArgs);
|
||||
|
|
|
@ -2647,7 +2647,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
|||
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsUnspecializedTypeVariation()))
|
||||
return NULL;
|
||||
|
||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecializedVariation))
|
||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->IsOrInUnspecializedVariation()))
|
||||
return NULL; // Ignore errors on unspecialized variations, they are always dups
|
||||
if (!mHadBuildError)
|
||||
mHadBuildError = true;
|
||||
|
@ -9781,9 +9781,6 @@ String BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodNameFlags
|
|||
String methodName;
|
||||
if ((methodNameFlags & BfMethodNameFlag_OmitTypeName) == 0)
|
||||
{
|
||||
// Don't use the 'mCurMethodInstance' owner for the type instance if there's one already set
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
||||
|
||||
methodName = TypeToString(type, typeNameFlags);
|
||||
if (methodName == "$")
|
||||
methodName = "";
|
||||
|
@ -13977,7 +13974,7 @@ void BfModule::AssertErrorState()
|
|||
|
||||
if (mCurMethodInstance != NULL)
|
||||
{
|
||||
if (mCurMethodInstance->mIsUnspecializedVariation)
|
||||
if (mCurMethodInstance->IsOrInUnspecializedVariation())
|
||||
return;
|
||||
if (mCurMethodInstance->mHasFailed)
|
||||
return;
|
||||
|
@ -16925,6 +16922,8 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
if (!methodInstance->mIsReified)
|
||||
BF_ASSERT(!mIsReified);
|
||||
|
||||
BF_ASSERT(!methodInstance->GetOwner()->IsUnspecializedTypeVariation());
|
||||
|
||||
if (methodInstance->mMethodInfoEx != NULL)
|
||||
{
|
||||
for (auto methodGenericArg : methodInstance->mMethodInfoEx->mMethodGenericArguments)
|
||||
|
@ -19423,7 +19422,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
|
|||
bool wantsVisitBody = true;
|
||||
if ((methodDef->mMethodType == BfMethodType_Mixin) && (!methodGenericArguments.IsEmpty()))
|
||||
wantsVisitBody = false;
|
||||
if (methodInstance->mIsUnspecializedVariation)
|
||||
if (methodInstance->IsOrInUnspecializedVariation())
|
||||
wantsVisitBody = false;
|
||||
|
||||
if (wantsVisitBody)
|
||||
|
@ -19681,7 +19680,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
|
|||
auto deferMethodState = rootMethodState;
|
||||
|
||||
// Since we handle errors & warnings in the capture phase, we don't need to process any local methods for resolve-only (unless we're doing a mDbgVerifyCodeGen)
|
||||
if ((!localMethod->mDeclOnly) && (!methodInstance->mIsUnspecializedVariation) &&
|
||||
if ((!localMethod->mDeclOnly) && (!methodInstance->IsOrInUnspecializedVariation()) &&
|
||||
(!mWantsIRIgnoreWrites) && (methodDef->mMethodType != BfMethodType_Mixin))
|
||||
{
|
||||
BP_ZONE("BfDeferredLocalMethod:create");
|
||||
|
@ -20215,7 +20214,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
|||
methodInstance->mIsUnspecialized = true;
|
||||
}
|
||||
|
||||
methodInstance->mIsUnspecializedVariation |= typeInstance->IsUnspecializedTypeVariation();
|
||||
//methodInstance->mIsUnspecializedVariation |= typeInstance->IsUnspecializedTypeVariation();
|
||||
|
||||
for (auto genericParamDef : methodDef->mGenericParams)
|
||||
{
|
||||
|
|
|
@ -4841,18 +4841,20 @@ void BfModule::AddMethodToWorkList(BfMethodInstance* methodInstance)
|
|||
|
||||
if (methodInstance->IsSpecializedByAutoCompleteMethod())
|
||||
return;
|
||||
|
||||
|
||||
BF_ASSERT(mCompiler->mCompileState != BfCompiler::CompileState_VData);
|
||||
if ((methodInstance->mIsReified) && (!methodInstance->mIsUnspecialized))
|
||||
{
|
||||
BF_ASSERT(mCompiler->mCompileState != BfCompiler::CompileState_Unreified);
|
||||
}
|
||||
|
||||
if (methodInstance->mIsUnspecializedVariation)
|
||||
if (methodInstance->IsOrInUnspecializedVariation())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BF_ASSERT(!methodInstance->GetOwner()->IsUnspecializedTypeVariation());
|
||||
|
||||
BF_ASSERT(methodInstance->mMethodProcessRequest == NULL);
|
||||
|
||||
auto defaultMethod = methodInstance->mMethodInstanceGroup->mDefault;
|
||||
|
@ -6705,8 +6707,9 @@ BfGenericParamInstance* BfModule::GetGenericTypeParamInstance(int genericParamId
|
|||
{
|
||||
// When we're evaluating a method, make sure the params refer back to that method context
|
||||
auto curTypeInstance = mCurTypeInstance;
|
||||
if (mCurMethodInstance != NULL)
|
||||
curTypeInstance = mCurMethodInstance->mMethodInstanceGroup->mOwner;
|
||||
//TODO: This caused MethodToString issues with interface "implementation method not found" errors
|
||||
// if (mCurMethodInstance != NULL)
|
||||
// curTypeInstance = mCurMethodInstance->mMethodInstanceGroup->mOwner;
|
||||
|
||||
BfTypeInstance* genericTypeInst = curTypeInstance->ToGenericTypeInstance();
|
||||
if ((genericTypeInst->IsIncomplete()) && (genericTypeInst->mGenericTypeInfo->mGenericParams.size() == 0))
|
||||
|
@ -7065,7 +7068,7 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
bool doValidate = (genericTypeInstance->mGenericTypeInfo->mHadValidateErrors) ||
|
||||
(!genericTypeInstance->mGenericTypeInfo->mValidatedGenericConstraints) ||
|
||||
(genericTypeInstance->mGenericTypeInfo->mIsUnspecializedVariation);
|
||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecializedVariation))
|
||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->IsOrInUnspecializedVariation()))
|
||||
doValidate = false;
|
||||
if (mCurTypeInstance != NULL)
|
||||
{
|
||||
|
|
|
@ -650,6 +650,11 @@ bool BfMethodInstance::IsSpecializedByAutoCompleteMethod()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BfMethodInstance::IsOrInUnspecializedVariation()
|
||||
{
|
||||
return (mIsUnspecializedVariation) || (GetOwner()->IsUnspecializedTypeVariation());
|
||||
}
|
||||
|
||||
bool BfMethodInstance::HasExternConstraints()
|
||||
{
|
||||
return (mMethodInfoEx != NULL) && (mMethodInfoEx->mGenericParams.size() > mMethodInfoEx->mMethodGenericArguments.size());
|
||||
|
|
|
@ -867,6 +867,7 @@ public:
|
|||
bool IsSpecializedGenericMethod();
|
||||
bool IsSpecializedGenericMethodOrType();
|
||||
bool IsSpecializedByAutoCompleteMethod();
|
||||
bool IsOrInUnspecializedVariation();
|
||||
bool HasExternConstraints();
|
||||
bool HasThis();
|
||||
BfType* GetThisType();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue