@@ -571,50 +571,54 @@ public override TypePrinterResult VisitFieldDecl(Field field)
571571
572572 public override TypePrinterResult VisitFunctionDecl ( Function function )
573573 {
574- return VisitDeclaration ( function ) ;
575- }
576-
577- public override TypePrinterResult VisitMethodDecl ( Method method )
578- {
579- // HACK: this should never happen but there's an inexplicable crash
580- // with the 32-bit Windows CI - needs investigation.
581- var functionType = method . FunctionType . Type . Desugar ( ) as FunctionType ;
582- if ( functionType == null )
583- return string . Empty ;
584-
585- var @return = method . IsConstructor || method . IsDestructor ||
586- method . OperatorKind == CXXOperatorKind . Conversion ||
587- method . OperatorKind == CXXOperatorKind . ExplicitConversion ?
588- new TypePrinterResult ( ) : method . OriginalReturnType . Visit ( this ) ;
589-
590574 string @class ;
591575 switch ( MethodScopeKind )
592576 {
593577 case TypePrintScopeKind . Qualified :
594- @class = $ "{ method . Namespace . Visit ( this ) } ::";
578+ @class = $ "{ function . Namespace . Visit ( this ) } ::";
595579 break ;
596580 case TypePrintScopeKind . GlobalQualified :
597- @class = $ "::{ method . Namespace . Visit ( this ) } ::";
581+ @class = $ "::{ function . Namespace . Visit ( this ) } ::";
598582 break ;
599583 default :
600584 @class = string . Empty ;
601585 break ;
602586 }
603587
604- var @params = string . Join ( ", " , method . Parameters . Select ( p => p . Visit ( this ) ) ) ;
605- var @const = method . IsConst ? " const" : string . Empty ;
606- var name = method . OperatorKind == CXXOperatorKind . Conversion ||
607- method . OperatorKind == CXXOperatorKind . ExplicitConversion ?
608- $ "operator { method . OriginalReturnType . Visit ( this ) } " :
609- method . OriginalName ;
610-
588+ var @params = string . Join ( ", " , function . Parameters . Select ( p => p . Visit ( this ) ) ) ;
589+ var @const = function is Method method && method . IsConst ? " const" : string . Empty ;
590+ var name = function . OperatorKind == CXXOperatorKind . Conversion ||
591+ function . OperatorKind == CXXOperatorKind . ExplicitConversion ?
592+ $ "operator { function . OriginalReturnType . Visit ( this ) } " :
593+ function . OriginalName ;
594+
595+ FunctionType functionType ;
596+ CppSharp . AST . Type desugared = function . FunctionType . Type . Desugar ( ) ;
597+ if ( ! desugared . IsPointerTo ( out functionType ) )
598+ functionType = ( FunctionType ) desugared ;
611599 string exceptionType = Print ( functionType . ExceptionSpecType ) ;
612600
601+ var @return = function . OriginalReturnType . Visit ( this ) ;
613602 if ( ! string . IsNullOrEmpty ( @return . Type ) )
614603 @return . NamePrefix . Append ( ' ' ) ;
615- @return . NamePrefix . Append ( @class ) . Append ( name ) . Append ( '(' ) . Append ( @params ) . Append ( ')' ) ;
616- @return . NameSuffix . Append ( @const ) . Append ( exceptionType ) ;
617- return @return . ToString ( ) ;
604+ @return . Name = @class + name ;
605+ @return . NameSuffix . Append ( '(' ) . Append ( @params ) . Append ( ')' ) . Append ( @const ) . Append ( exceptionType ) ;
606+ return @return ;
607+ }
608+
609+ public override TypePrinterResult VisitMethodDecl ( Method method )
610+ {
611+ var @return = VisitFunctionDecl ( method ) ;
612+
613+ if ( method . IsConstructor || method . IsDestructor ||
614+ method . OperatorKind == CXXOperatorKind . Conversion ||
615+ method . OperatorKind == CXXOperatorKind . ExplicitConversion )
616+ {
617+ @return . Type = string . Empty ;
618+ @return . NamePrefix . Clear ( ) ;
619+ }
620+
621+ return @return ;
618622 }
619623
620624 public override TypePrinterResult VisitParameterDecl ( Parameter parameter )
0 commit comments