@@ -1589,10 +1589,12 @@ void OutputVtblHelperMethod(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethod
15891589 var remappedName = FixupNameForMultipleHits ( cxxMethodDecl ) ;
15901590 var name = GetRemappedCursorName ( cxxMethodDecl ) ;
15911591 var needsReturnFixup = false ;
1592+ var needsCastToTransparentStruct = false ;
15921593
15931594 if ( returnType . Kind != CXTypeKind . CXType_Void )
15941595 {
15951596 needsReturnFixup = NeedsReturnFixup ( cxxMethodDecl ) ;
1597+ needsCastToTransparentStruct = _config . WithTransparentStructs . TryGetValue ( returnTypeName , out var transparentStruct ) && IsTransparentStructHandle ( transparentStruct . Kind ) ;
15961598 }
15971599
15981600 var desc = new FunctionOrDelegateDesc < ( string Name , PInvokeGenerator This ) >
@@ -1652,6 +1654,13 @@ void OutputVtblHelperMethod(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethod
16521654 body . Write ( "return " ) ;
16531655 }
16541656
1657+ if ( needsCastToTransparentStruct )
1658+ {
1659+ body . Write ( "((" ) ;
1660+ body . Write ( returnTypeName ) ;
1661+ body . Write ( ")(" ) ;
1662+ }
1663+
16551664 if ( needsReturnFixup )
16561665 {
16571666 body . Write ( '*' ) ;
@@ -1748,6 +1757,11 @@ void OutputVtblHelperMethod(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethod
17481757 body . Write ( " != 0" ) ;
17491758 }
17501759
1760+ if ( needsCastToTransparentStruct )
1761+ {
1762+ body . Write ( "))" ) ;
1763+ }
1764+
17511765 body . WriteSemicolon ( ) ;
17521766 body . WriteNewline ( ) ;
17531767
@@ -2743,9 +2757,9 @@ private void VisitVarDecl(VarDecl varDecl)
27432757 {
27442758 flags |= ValueFlags . Copy ;
27452759 }
2746- else if ( _config . WithTransparentStructs . TryGetValue ( typeName , out var transparentValueTypeName ) )
2760+ else if ( _config . WithTransparentStructs . TryGetValue ( typeName , out var transparentStruct ) )
27472761 {
2748- typeName = transparentValueTypeName ;
2762+ typeName = transparentStruct . Name ;
27492763 }
27502764 }
27512765 else if ( ( varDecl . StorageClass == CX_StorageClass . CX_SC_Static ) || openedOutputBuilder )
0 commit comments