mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
For for 'in' with unqualified dot constructor
This commit is contained in:
parent
62a171c649
commit
b0b85b7b43
2 changed files with 26 additions and 0 deletions
|
@ -18145,6 +18145,18 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m
|
|||
expectingType = underlyingType;
|
||||
}
|
||||
|
||||
BfType* inRefType = NULL;
|
||||
if ((expectingType != NULL) && (expectingType->IsRef()))
|
||||
{
|
||||
auto refType = (BfRefType*)expectingType;
|
||||
if (refType->mRefKind == BfRefType::RefKind_In)
|
||||
{
|
||||
inRefType = expectingType;
|
||||
auto underlyingType = expectingType->GetUnderlyingType();
|
||||
expectingType = underlyingType;
|
||||
}
|
||||
}
|
||||
|
||||
if (expectingType != NULL)
|
||||
{
|
||||
if (expectingType->IsSizedArray())
|
||||
|
@ -18188,6 +18200,12 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m
|
|||
mResult = ctorResult;
|
||||
mModule->ValidateAllocation(expectingType, invocationExpr->mTarget);
|
||||
|
||||
if ((inRefType != NULL) && (mResult.mType == expectingType) && (mResult.IsAddr()))
|
||||
{
|
||||
// Put back the 'in'
|
||||
mResult = BfTypedValue(mResult.mValue, inRefType);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,11 @@ namespace Tests
|
|||
{
|
||||
}
|
||||
|
||||
public static int InCallStruct(in StructA val)
|
||||
{
|
||||
return val.mA + val.mB;
|
||||
}
|
||||
|
||||
public static int ParamsA(int a, params Span<int> ints)
|
||||
{
|
||||
int result = a;
|
||||
|
@ -207,6 +212,9 @@ namespace Tests
|
|||
StructA sa2 = .(200, 201);
|
||||
StructA sa3 = .(300, 301);
|
||||
|
||||
Test.Assert(InCallStruct(sa) == 201);
|
||||
Test.Assert(InCallStruct(.(200, 202)) == 402);
|
||||
|
||||
Test.Assert(Method0(sa) == 100);
|
||||
Test.Assert(Method1(sa, sa2) == 200);
|
||||
Test.Assert(Method2(sa, sa2, sa3) == 300);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue