mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed some constraint lookups
This commit is contained in:
parent
3fcaa6b397
commit
ed6959973a
3 changed files with 60 additions and 2 deletions
|
@ -4228,7 +4228,8 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
{
|
||||
if ((target.mType != NULL && (target.mType->IsGenericParam())))
|
||||
{
|
||||
auto genericParamInst = mModule->GetGenericParamInstance((BfGenericParamType*)target.mType);
|
||||
auto genericParamType = (BfGenericParamType*)target.mType;
|
||||
auto genericParamInst = mModule->GetGenericParamInstance(genericParamType);
|
||||
|
||||
if (target.mValue)
|
||||
{
|
||||
|
@ -4242,10 +4243,20 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
}
|
||||
}
|
||||
|
||||
if ((mModule->mCurMethodInstance != NULL) && (mModule->mCurMethodInstance->mIsUnspecialized))
|
||||
bool isUnspecializedSection = false;
|
||||
if (genericParamType->mGenericParamKind == BfGenericParamKind_Method)
|
||||
isUnspecializedSection = (mModule->mCurMethodInstance != NULL) && (mModule->mCurMethodInstance->mIsUnspecialized);
|
||||
else
|
||||
isUnspecializedSection = (mModule->mCurTypeInstance != NULL) && (mModule->mCurTypeInstance->IsUnspecializedType());
|
||||
|
||||
if (isUnspecializedSection)
|
||||
{
|
||||
if (genericParamInst->mTypeConstraint != NULL)
|
||||
{
|
||||
target.mType = genericParamInst->mTypeConstraint;
|
||||
if (target.mType->IsWrappableType())
|
||||
target.mType = mModule->GetWrappedStructType(target.mType);
|
||||
}
|
||||
else
|
||||
target.mType = mModule->mContext->mBfObjectType;
|
||||
|
||||
|
@ -19600,6 +19611,13 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
|||
if (!target.HasType())
|
||||
return;
|
||||
|
||||
if (target.mType->IsGenericParam())
|
||||
{
|
||||
auto genericParamInstance = mModule->GetGenericParamInstance((BfGenericParamType*)target.mType);
|
||||
if (genericParamInstance->mTypeConstraint != NULL)
|
||||
target.mType = genericParamInstance->mTypeConstraint;
|
||||
}
|
||||
|
||||
BfCheckedKind checkedKind = BfCheckedKind_NotSet;
|
||||
|
||||
bool isInlined = false;
|
||||
|
|
|
@ -697,6 +697,12 @@ bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int*
|
|||
}
|
||||
else if (checkToken == BfToken_RBracket)
|
||||
{
|
||||
if (bracketDepth == 0)
|
||||
{
|
||||
// Not even an array
|
||||
return false;
|
||||
}
|
||||
|
||||
endBracket = checkIdx;
|
||||
}
|
||||
else if ((checkToken == BfToken_Star) || (checkToken == BfToken_Question))
|
||||
|
|
|
@ -76,6 +76,40 @@ namespace Tests
|
|||
ClassA<T>.DoAdd(val, val);
|
||||
}
|
||||
|
||||
struct StringViewEnumerator<TS, C> : IEnumerator<StringView>
|
||||
where C : const int
|
||||
where TS : StringView[C]
|
||||
{
|
||||
private TS mStrings;
|
||||
private int mIdx;
|
||||
|
||||
public this(TS strings)
|
||||
{
|
||||
mStrings = strings;
|
||||
mIdx = -1;
|
||||
}
|
||||
|
||||
public StringView Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return mStrings[mIdx];
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() mut
|
||||
{
|
||||
return ++mIdx != mStrings.Count;
|
||||
}
|
||||
|
||||
public Result<StringView> GetNext() mut
|
||||
{
|
||||
if (!MoveNext())
|
||||
return .Err;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue