diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 993ac044..8fcd5718 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -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; } } diff --git a/IDEHelper/Tests/src/MethodCalls.bf b/IDEHelper/Tests/src/MethodCalls.bf index e48e3886..bd80fdb0 100644 --- a/IDEHelper/Tests/src/MethodCalls.bf +++ b/IDEHelper/Tests/src/MethodCalls.bf @@ -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 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);