mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Fixed explicit interface indexer
This commit is contained in:
parent
908a76b92a
commit
295057b026
2 changed files with 32 additions and 1 deletions
|
@ -21931,6 +21931,10 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
|
|||
|
||||
void BfExprEvaluator::HandleIndexerExpression(BfIndexerExpression* indexerExpr, BfTypedValue target)
|
||||
{
|
||||
BfAstNode* refNode = indexerExpr->mOpenBracket;
|
||||
if (refNode == NULL)
|
||||
refNode = indexerExpr->mTarget;
|
||||
|
||||
bool wantStatic = false;
|
||||
// Try first as a non-static indexer, then as a static indexer
|
||||
|
||||
|
@ -22028,6 +22032,13 @@ void BfExprEvaluator::HandleIndexerExpression(BfIndexerExpression* indexerExpr,
|
|||
BfMethodDef* methodDef = NULL;
|
||||
|
||||
auto startCheckTypeInst = target.mType->ToTypeInstance();
|
||||
auto lookupType = target.mType;
|
||||
if (lookupType != NULL)
|
||||
{
|
||||
lookupType = BindGenericType(refNode, lookupType);
|
||||
if (lookupType->IsGenericParam())
|
||||
startCheckTypeInst = NULL;
|
||||
}
|
||||
|
||||
for (int pass = 0; pass < 2; pass++)
|
||||
{
|
||||
|
@ -22036,7 +22047,7 @@ void BfExprEvaluator::HandleIndexerExpression(BfIndexerExpression* indexerExpr,
|
|||
BfPropertyDef* foundProp = NULL;
|
||||
BfTypeInstance* foundPropTypeInst = NULL;
|
||||
|
||||
BfBaseClassWalker baseClassWalker(target.mType, NULL, mModule, true);
|
||||
BfBaseClassWalker baseClassWalker(lookupType, NULL, mModule, true);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
@ -109,6 +109,22 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
class IndexTestExplicit : IIndexable<float>
|
||||
{
|
||||
public float IIndexable<float>.this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static float Get<T>(T indexable) where T : IIndexable<float>
|
||||
{
|
||||
float f = indexable[4];
|
||||
|
@ -147,6 +163,10 @@ namespace Tests
|
|||
|
||||
IndexTest it = scope .();
|
||||
Test.Assert(it[5] == 5.0f);
|
||||
Test.Assert(Get(it) == 4);
|
||||
|
||||
IndexTestExplicit it2 = scope .();
|
||||
Test.Assert(Get(it2) == 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue