mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Property visibility fixes for default interface methods
This commit is contained in:
parent
2746a53839
commit
16de3a14a4
5 changed files with 45 additions and 11 deletions
|
@ -19050,7 +19050,7 @@ BfModuleMethodInstance BfExprEvaluator::GetPropertyMethodInstance(BfMethodDef* m
|
|||
checkType = mModule->GetWrappedStructType(checkType);
|
||||
if ((checkType != NULL) && (checkType->IsTypeInstance()))
|
||||
{
|
||||
auto activeTypeDef = mModule->GetActiveTypeDef();
|
||||
auto activeTypeDef = mModule->GetActiveTypeDef(NULL, false, true);
|
||||
BfTypeInterfaceEntry* bestIFaceEntry = NULL;
|
||||
|
||||
bool checkedUnderlying = false;
|
||||
|
@ -19213,6 +19213,11 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
|
|||
}
|
||||
}
|
||||
|
||||
if (mModule->mCurMethodInstance->mIsForeignMethodDef)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
SetAndRestoreValue<BfFunctionBindResult*> prevFunctionBindResult(mFunctionBindResult, NULL);
|
||||
|
|
|
@ -1949,7 +1949,7 @@ public:
|
|||
BfType* ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTypeRef, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags);
|
||||
void ShowAmbiguousTypeError(BfAstNode* refNode, BfTypeDef* typeDef, BfTypeDef* otherTypeDef);
|
||||
void ShowGenericArgCountError(BfAstNode* typeRef, int wantedGenericParams);
|
||||
BfTypeDef* GetActiveTypeDef(BfTypeInstance* typeInstanceOverride = NULL, bool useMixinDecl = false); // useMixinDecl is useful for type lookup, but we don't want the decl project to limit what methods the user can call
|
||||
BfTypeDef* GetActiveTypeDef(BfTypeInstance* typeInstanceOverride = NULL, bool useMixinDecl = false, bool useForeignImpl = false); // useMixinDecl is useful for type lookup, but we don't want the decl project to limit what methods the user can call
|
||||
BfTypeDef* FindTypeDefRaw(const BfAtomComposite& findName, int numGenericArgs, BfTypeInstance* typeInstance, BfTypeDef* useTypeDef, BfTypeLookupError* error, BfTypeLookupResultCtx* lookupResultCtx = NULL, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0);
|
||||
BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfTypeInstance* typeInstanceOverride = NULL, BfTypeLookupError* error = NULL, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0);
|
||||
BfTypeDef* FindTypeDef(const StringImpl& typeName, int numGenericArgs = 0, BfTypeInstance* typeInstanceOverride = NULL, BfTypeLookupError* error = NULL, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0);
|
||||
|
|
|
@ -9921,7 +9921,7 @@ void BfModule::ShowGenericArgCountError(BfAstNode* typeRef, int wantedGenericPar
|
|||
Fail(StrFormat("Too few generic parameters, expected %d more", -genericArgDiffCount), lastNode);
|
||||
}
|
||||
|
||||
BfTypeDef* BfModule::GetActiveTypeDef(BfTypeInstance* typeInstanceOverride, bool useMixinDecl)
|
||||
BfTypeDef* BfModule::GetActiveTypeDef(BfTypeInstance* typeInstanceOverride, bool useMixinDecl, bool useForeignImpl)
|
||||
{
|
||||
BfTypeDef* useTypeDef = NULL;
|
||||
BfTypeInstance* typeInstance = (typeInstanceOverride != NULL) ? typeInstanceOverride : mCurTypeInstance;
|
||||
|
@ -9933,12 +9933,20 @@ BfTypeDef* BfModule::GetActiveTypeDef(BfTypeInstance* typeInstanceOverride, bool
|
|||
useTypeDef = mCurMethodState->mMixinState->mMixinMethodInstance->mMethodDef->mDeclaringType->GetDefinition();
|
||||
else if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mDeclaringType != NULL))
|
||||
{
|
||||
auto declTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
||||
useTypeDef = declTypeDef->GetDefinition(true);
|
||||
if ((declTypeDef->IsEmitted()) && (useTypeDef->mIsCombinedPartial))
|
||||
if ((mCurMethodInstance->mIsForeignMethodDef) && (useForeignImpl))
|
||||
{
|
||||
// Always consider methods to belong to the primary type declaration
|
||||
useTypeDef = useTypeDef->mPartials[0];
|
||||
// Use the concrete impl typeDef, not the foreign method typedecl (the interface)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto declTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
||||
useTypeDef = declTypeDef->GetDefinition(true);
|
||||
if ((declTypeDef->IsEmitted()) && (useTypeDef->mIsCombinedPartial))
|
||||
{
|
||||
// Always consider methods to belong to the primary type declaration
|
||||
useTypeDef = useTypeDef->mPartials[0];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mContext->mCurTypeState != NULL)
|
||||
|
@ -14981,7 +14989,7 @@ bool BfModule::TypeIsSubTypeOf(BfTypeInstance* srcType, BfTypeInstance* wantType
|
|||
if (checkAccessibility)
|
||||
{
|
||||
if (checkActiveTypeDef == NULL)
|
||||
checkActiveTypeDef = GetActiveTypeDef(NULL, false);
|
||||
checkActiveTypeDef = GetActiveTypeDef(NULL, false, true);
|
||||
|
||||
// We need to be lenient when validating generic constraints
|
||||
// Otherwise "T<A> where T : IB" declared in a lib won't be able to match a type B in a using project 'C',
|
||||
|
|
|
@ -4,6 +4,19 @@ using System.Diagnostics;
|
|||
|
||||
namespace LibA
|
||||
{
|
||||
public interface ITaggable
|
||||
{
|
||||
public String Tag
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public bool MatchesTag(String tag)
|
||||
{
|
||||
return Tag.Equals(tag);
|
||||
}
|
||||
}
|
||||
|
||||
struct LibAStruct
|
||||
{
|
||||
int mA;
|
||||
|
|
|
@ -405,6 +405,14 @@ namespace Tests
|
|||
public static String Serialize(Self value);
|
||||
}
|
||||
|
||||
public class EngineTag : LibA.ITaggable
|
||||
{
|
||||
public String Tag
|
||||
{
|
||||
get => "ET";
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestDefaults()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue