@@ -1368,7 +1368,8 @@ private void GenerateFieldGetter(Field field, Class @class, QualifiedType return
1368
1368
var name = ( ( Class ) field . Namespace ) . Layout . Fields . First (
1369
1369
f => f . FieldPtr == field . OriginalPtr ) . Name ;
1370
1370
string returnVar ;
1371
- var arrayType = field . Type . Desugar ( ) as ArrayType ;
1371
+ Type fieldType = field . Type . Desugar ( ) ;
1372
+ var arrayType = fieldType as ArrayType ;
1372
1373
if ( @class . IsValueType )
1373
1374
{
1374
1375
if ( arrayType != null )
@@ -1385,8 +1386,8 @@ private void GenerateFieldGetter(Field field, Class @class, QualifiedType return
1385
1386
// Class field getter should return a reference object instead of a copy. Wrapping `returnVar` in
1386
1387
// IntPtr ensures that non-copying object constructor is invoked.
1387
1388
Class typeClass ;
1388
- if ( field . Type . TryGetClass ( out typeClass ) && ! typeClass . IsValueType &&
1389
- ! ASTUtils . IsMappedToPrimitive ( Context . TypeMaps , field . Type ) )
1389
+ if ( fieldType . TryGetClass ( out typeClass ) && ! typeClass . IsValueType &&
1390
+ ! ASTUtils . IsMappedToPrimitive ( Context . TypeMaps , fieldType ) )
1390
1391
returnVar = $ "new { TypePrinter . IntPtrType } (&{ returnVar } )";
1391
1392
}
1392
1393
@@ -1410,9 +1411,9 @@ private void GenerateFieldGetter(Field field, Class @class, QualifiedType return
1410
1411
Write ( "return " ) ;
1411
1412
1412
1413
var @return = marshal . Context . Return . ToString ( ) ;
1413
- if ( field . Type . IsPointer ( ) )
1414
+ if ( fieldType . IsPointer ( ) )
1414
1415
{
1415
- var final = field . Type . GetFinalPointee ( ) . Desugar ( resolveTemplateSubstitution : false ) ;
1416
+ var final = fieldType . GetFinalPointee ( ) . Desugar ( resolveTemplateSubstitution : false ) ;
1416
1417
var templateSubstitution = final as TemplateParameterSubstitutionType ;
1417
1418
if ( templateSubstitution != null && returnType . Type . IsDependent )
1418
1419
Write ( $ "({ templateSubstitution . ReplacedParameter . Parameter . Name } ) (object) ") ;
@@ -1422,13 +1423,13 @@ private void GenerateFieldGetter(Field field, Class @class, QualifiedType return
1422
1423
! final . IsPrimitiveType ( PrimitiveType . Char16 ) &&
1423
1424
! final . IsPrimitiveType ( PrimitiveType . Char32 ) ) ||
1424
1425
( ! Context . Options . MarshalCharAsManagedChar &&
1425
- ! ( ( PointerType ) field . Type ) . QualifiedPointee . Qualifiers . IsConst ) ) &&
1426
+ ! ( ( PointerType ) fieldType ) . QualifiedPointee . Qualifiers . IsConst ) ) &&
1426
1427
templateSubstitution == null ) ||
1427
- ( ! ( ( PointerType ) field . Type ) . QualifiedPointee . Qualifiers . IsConst &&
1428
+ ( ! ( ( PointerType ) fieldType ) . QualifiedPointee . Qualifiers . IsConst &&
1428
1429
( final . IsPrimitiveType ( PrimitiveType . WideChar ) ||
1429
1430
final . IsPrimitiveType ( PrimitiveType . Char16 ) ||
1430
1431
final . IsPrimitiveType ( PrimitiveType . Char32 ) ) ) )
1431
- Write ( $ "({ field . Type . GetPointee ( ) . Desugar ( ) } *) ") ;
1432
+ Write ( $ "({ fieldType . GetPointee ( ) . Desugar ( ) } *) ") ;
1432
1433
}
1433
1434
WriteLine ( $ "{ @return } ;") ;
1434
1435
0 commit comments