mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +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
|
class Generics
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public void Method1<T>(T val) where T : Array
|
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;
|
// ++methodItr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rebuildMethodInstance->mIsUnspecializedVariation) || (rebuildMethodInstance->IsSpecializedGenericMethod()))
|
if ((rebuildMethodInstance->IsOrInUnspecializedVariation()) || (rebuildMethodInstance->IsSpecializedGenericMethod()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SetAndRestoreValue<BfMethodInstance*> prevTypeInstance(rebuildModule->mCurMethodInstance, rebuildMethodInstance);
|
SetAndRestoreValue<BfMethodInstance*> prevTypeInstance(rebuildModule->mCurMethodInstance, rebuildMethodInstance);
|
||||||
|
|
|
@ -7655,7 +7655,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
||||||
|
|
||||||
bool isSkipCall = moduleMethodInstance.mMethodInstance->IsSkipCall(bypassVirtual);
|
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
|
// 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);
|
FinishDeferredEvals(argValues.mResolvedArgs);
|
||||||
|
|
|
@ -2647,7 +2647,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsUnspecializedTypeVariation()))
|
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsUnspecializedTypeVariation()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecializedVariation))
|
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->IsOrInUnspecializedVariation()))
|
||||||
return NULL; // Ignore errors on unspecialized variations, they are always dups
|
return NULL; // Ignore errors on unspecialized variations, they are always dups
|
||||||
if (!mHadBuildError)
|
if (!mHadBuildError)
|
||||||
mHadBuildError = true;
|
mHadBuildError = true;
|
||||||
|
@ -9781,9 +9781,6 @@ String BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodNameFlags
|
||||||
String methodName;
|
String methodName;
|
||||||
if ((methodNameFlags & BfMethodNameFlag_OmitTypeName) == 0)
|
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);
|
methodName = TypeToString(type, typeNameFlags);
|
||||||
if (methodName == "$")
|
if (methodName == "$")
|
||||||
methodName = "";
|
methodName = "";
|
||||||
|
@ -13977,7 +13974,7 @@ void BfModule::AssertErrorState()
|
||||||
|
|
||||||
if (mCurMethodInstance != NULL)
|
if (mCurMethodInstance != NULL)
|
||||||
{
|
{
|
||||||
if (mCurMethodInstance->mIsUnspecializedVariation)
|
if (mCurMethodInstance->IsOrInUnspecializedVariation())
|
||||||
return;
|
return;
|
||||||
if (mCurMethodInstance->mHasFailed)
|
if (mCurMethodInstance->mHasFailed)
|
||||||
return;
|
return;
|
||||||
|
@ -16925,6 +16922,8 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
if (!methodInstance->mIsReified)
|
if (!methodInstance->mIsReified)
|
||||||
BF_ASSERT(!mIsReified);
|
BF_ASSERT(!mIsReified);
|
||||||
|
|
||||||
|
BF_ASSERT(!methodInstance->GetOwner()->IsUnspecializedTypeVariation());
|
||||||
|
|
||||||
if (methodInstance->mMethodInfoEx != NULL)
|
if (methodInstance->mMethodInfoEx != NULL)
|
||||||
{
|
{
|
||||||
for (auto methodGenericArg : methodInstance->mMethodInfoEx->mMethodGenericArguments)
|
for (auto methodGenericArg : methodInstance->mMethodInfoEx->mMethodGenericArguments)
|
||||||
|
@ -19423,7 +19422,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
|
||||||
bool wantsVisitBody = true;
|
bool wantsVisitBody = true;
|
||||||
if ((methodDef->mMethodType == BfMethodType_Mixin) && (!methodGenericArguments.IsEmpty()))
|
if ((methodDef->mMethodType == BfMethodType_Mixin) && (!methodGenericArguments.IsEmpty()))
|
||||||
wantsVisitBody = false;
|
wantsVisitBody = false;
|
||||||
if (methodInstance->mIsUnspecializedVariation)
|
if (methodInstance->IsOrInUnspecializedVariation())
|
||||||
wantsVisitBody = false;
|
wantsVisitBody = false;
|
||||||
|
|
||||||
if (wantsVisitBody)
|
if (wantsVisitBody)
|
||||||
|
@ -19681,7 +19680,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
|
||||||
auto deferMethodState = rootMethodState;
|
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)
|
// 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))
|
(!mWantsIRIgnoreWrites) && (methodDef->mMethodType != BfMethodType_Mixin))
|
||||||
{
|
{
|
||||||
BP_ZONE("BfDeferredLocalMethod:create");
|
BP_ZONE("BfDeferredLocalMethod:create");
|
||||||
|
@ -20215,7 +20214,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
methodInstance->mIsUnspecialized = true;
|
methodInstance->mIsUnspecialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
methodInstance->mIsUnspecializedVariation |= typeInstance->IsUnspecializedTypeVariation();
|
//methodInstance->mIsUnspecializedVariation |= typeInstance->IsUnspecializedTypeVariation();
|
||||||
|
|
||||||
for (auto genericParamDef : methodDef->mGenericParams)
|
for (auto genericParamDef : methodDef->mGenericParams)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4841,18 +4841,20 @@ void BfModule::AddMethodToWorkList(BfMethodInstance* methodInstance)
|
||||||
|
|
||||||
if (methodInstance->IsSpecializedByAutoCompleteMethod())
|
if (methodInstance->IsSpecializedByAutoCompleteMethod())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BF_ASSERT(mCompiler->mCompileState != BfCompiler::CompileState_VData);
|
BF_ASSERT(mCompiler->mCompileState != BfCompiler::CompileState_VData);
|
||||||
if ((methodInstance->mIsReified) && (!methodInstance->mIsUnspecialized))
|
if ((methodInstance->mIsReified) && (!methodInstance->mIsUnspecialized))
|
||||||
{
|
{
|
||||||
BF_ASSERT(mCompiler->mCompileState != BfCompiler::CompileState_Unreified);
|
BF_ASSERT(mCompiler->mCompileState != BfCompiler::CompileState_Unreified);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodInstance->mIsUnspecializedVariation)
|
if (methodInstance->IsOrInUnspecializedVariation())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BF_ASSERT(!methodInstance->GetOwner()->IsUnspecializedTypeVariation());
|
||||||
|
|
||||||
BF_ASSERT(methodInstance->mMethodProcessRequest == NULL);
|
BF_ASSERT(methodInstance->mMethodProcessRequest == NULL);
|
||||||
|
|
||||||
auto defaultMethod = methodInstance->mMethodInstanceGroup->mDefault;
|
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
|
// When we're evaluating a method, make sure the params refer back to that method context
|
||||||
auto curTypeInstance = mCurTypeInstance;
|
auto curTypeInstance = mCurTypeInstance;
|
||||||
if (mCurMethodInstance != NULL)
|
//TODO: This caused MethodToString issues with interface "implementation method not found" errors
|
||||||
curTypeInstance = mCurMethodInstance->mMethodInstanceGroup->mOwner;
|
// if (mCurMethodInstance != NULL)
|
||||||
|
// curTypeInstance = mCurMethodInstance->mMethodInstanceGroup->mOwner;
|
||||||
|
|
||||||
BfTypeInstance* genericTypeInst = curTypeInstance->ToGenericTypeInstance();
|
BfTypeInstance* genericTypeInst = curTypeInstance->ToGenericTypeInstance();
|
||||||
if ((genericTypeInst->IsIncomplete()) && (genericTypeInst->mGenericTypeInfo->mGenericParams.size() == 0))
|
if ((genericTypeInst->IsIncomplete()) && (genericTypeInst->mGenericTypeInfo->mGenericParams.size() == 0))
|
||||||
|
@ -7065,7 +7068,7 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
||||||
bool doValidate = (genericTypeInstance->mGenericTypeInfo->mHadValidateErrors) ||
|
bool doValidate = (genericTypeInstance->mGenericTypeInfo->mHadValidateErrors) ||
|
||||||
(!genericTypeInstance->mGenericTypeInfo->mValidatedGenericConstraints) ||
|
(!genericTypeInstance->mGenericTypeInfo->mValidatedGenericConstraints) ||
|
||||||
(genericTypeInstance->mGenericTypeInfo->mIsUnspecializedVariation);
|
(genericTypeInstance->mGenericTypeInfo->mIsUnspecializedVariation);
|
||||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecializedVariation))
|
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->IsOrInUnspecializedVariation()))
|
||||||
doValidate = false;
|
doValidate = false;
|
||||||
if (mCurTypeInstance != NULL)
|
if (mCurTypeInstance != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -650,6 +650,11 @@ bool BfMethodInstance::IsSpecializedByAutoCompleteMethod()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BfMethodInstance::IsOrInUnspecializedVariation()
|
||||||
|
{
|
||||||
|
return (mIsUnspecializedVariation) || (GetOwner()->IsUnspecializedTypeVariation());
|
||||||
|
}
|
||||||
|
|
||||||
bool BfMethodInstance::HasExternConstraints()
|
bool BfMethodInstance::HasExternConstraints()
|
||||||
{
|
{
|
||||||
return (mMethodInfoEx != NULL) && (mMethodInfoEx->mGenericParams.size() > mMethodInfoEx->mMethodGenericArguments.size());
|
return (mMethodInfoEx != NULL) && (mMethodInfoEx->mGenericParams.size() > mMethodInfoEx->mMethodGenericArguments.size());
|
||||||
|
|
|
@ -867,6 +867,7 @@ public:
|
||||||
bool IsSpecializedGenericMethod();
|
bool IsSpecializedGenericMethod();
|
||||||
bool IsSpecializedGenericMethodOrType();
|
bool IsSpecializedGenericMethodOrType();
|
||||||
bool IsSpecializedByAutoCompleteMethod();
|
bool IsSpecializedByAutoCompleteMethod();
|
||||||
|
bool IsOrInUnspecializedVariation();
|
||||||
bool HasExternConstraints();
|
bool HasExternConstraints();
|
||||||
bool HasThis();
|
bool HasThis();
|
||||||
BfType* GetThisType();
|
BfType* GetThisType();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue