mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Support interface binding with complex 'Self' returns ie: Result<Self>
This commit is contained in:
parent
b47f230345
commit
dc6f940561
3 changed files with 26 additions and 2 deletions
|
@ -5918,8 +5918,14 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto iReturnType = ifaceMethodInst->mReturnType;
|
auto iReturnType = ifaceMethodInst->mReturnType;
|
||||||
if (iReturnType->IsSelf())
|
if (iReturnType->IsUnspecializedTypeVariation())
|
||||||
iReturnType = typeInstance;
|
{
|
||||||
|
BfType* resolvedType = ResolveGenericType(iReturnType, NULL, NULL);
|
||||||
|
if (resolvedType != NULL)
|
||||||
|
iReturnType = resolvedType;
|
||||||
|
else
|
||||||
|
iReturnType = typeInstance;
|
||||||
|
}
|
||||||
|
|
||||||
if (ifaceMethodInst->mMethodDef->mIsOverride)
|
if (ifaceMethodInst->mMethodDef->mIsOverride)
|
||||||
continue; // Don't consider overrides here
|
continue; // Don't consider overrides here
|
||||||
|
@ -7684,6 +7690,9 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
return unspecializedType;
|
return unspecializedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((unspecializedType->IsSelf()) && (mCurTypeInstance != NULL))
|
||||||
|
return mCurTypeInstance;
|
||||||
|
|
||||||
if (!unspecializedType->IsUnspecializedType())
|
if (!unspecializedType->IsUnspecializedType())
|
||||||
{
|
{
|
||||||
return unspecializedType;
|
return unspecializedType;
|
||||||
|
|
|
@ -659,6 +659,8 @@ public:
|
||||||
virtual bool IsDot() override { return mTypeDef->mTypeCode == BfTypeCode_Dot; }
|
virtual bool IsDot() override { return mTypeDef->mTypeCode == BfTypeCode_Dot; }
|
||||||
virtual bool IsVar() override { return mTypeDef->mTypeCode == BfTypeCode_Var; }
|
virtual bool IsVar() override { return mTypeDef->mTypeCode == BfTypeCode_Var; }
|
||||||
virtual bool IsLet() override { return mTypeDef->mTypeCode == BfTypeCode_Let; }
|
virtual bool IsLet() override { return mTypeDef->mTypeCode == BfTypeCode_Let; }
|
||||||
|
virtual bool IsUnspecializedType() override { return mTypeDef->mTypeCode == BfTypeCode_Self; }
|
||||||
|
virtual bool IsUnspecializedTypeVariation() override { return mTypeDef->mTypeCode == BfTypeCode_Self; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class BfTypeInstance;
|
class BfTypeInstance;
|
||||||
|
|
|
@ -315,6 +315,19 @@ namespace Tests
|
||||||
return val.Val;
|
return val.Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IParsable
|
||||||
|
{
|
||||||
|
static Result<Self> Parse(StringView sv, Self defaultVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ClassH : IParsable
|
||||||
|
{
|
||||||
|
public static Result<Self> Parse(StringView sv, ClassH defaultVal)
|
||||||
|
{
|
||||||
|
return .Err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void TestDefaults()
|
public static void TestDefaults()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue