Skip to content

Commit db2e796

Browse files
committed
Fixed error
1 parent 41de24c commit db2e796

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Generator/Generators/CSharp/CSharpMarshal.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
167167
return true;
168168
}
169169

170-
if (finalPointee.IsPrimitiveType(out PrimitiveType primitive) || finalPointee.IsEnumType())
170+
PrimitiveType primitive;
171+
if (finalPointee.IsPrimitiveType(out primitive) || finalPointee.IsEnumType())
171172
{
172173
if (isRefParam)
173174
{
@@ -267,7 +268,8 @@ public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
267268

268269
var decl = typedef.Declaration;
269270

270-
if (decl.Type is FunctionType functionType || decl.Type.IsPointerTo(out functionType))
271+
var functionType = decl.Type as FunctionType;
272+
if (functionType != null || decl.Type.IsPointerTo(out functionType))
271273
{
272274
var ptrName = Generator.GeneratedIdentifier("ptr") +
273275
Context.ParameterIndex;
@@ -595,7 +597,9 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
595597
var param = Context.Parameter;
596598
var isRefParam = param != null && (param.IsInOut || param.IsOut);
597599
var finalPointee = pointer.GetFinalPointee();
598-
bool finalPointeeIsPrimitiveType = finalPointee.IsPrimitiveType(out PrimitiveType primitive);
600+
601+
PrimitiveType primitive;
602+
bool finalPointeeIsPrimitiveType = finalPointee.IsPrimitiveType(out primitive);
599603

600604
if (CSharpTypePrinter.IsConstCharString(pointee) && isRefParam)
601605
{

0 commit comments

Comments
 (0)