1
- using System . Collections . Generic ;
1
+ using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Linq ;
3
4
using CppSharp . AST ;
4
5
@@ -20,39 +21,18 @@ public EqualiseAccessOfOverrideAndBasePass()
20
21
VisitOptions . VisitTemplateArguments = false ;
21
22
}
22
23
23
- public override bool VisitASTContext ( ASTContext context )
24
- {
25
- var result = base . VisitASTContext ( context ) ;
26
-
27
- foreach ( var baseOverride in basesOverrides )
28
- {
29
- var access = baseOverride . Value . Max ( o => o . Access ) ;
30
- foreach ( var @override in baseOverride . Value )
31
- @override . Access = access ;
32
- }
33
-
34
- return result ;
35
- }
36
-
37
24
public override bool VisitMethodDecl ( Method method )
38
25
{
39
- if ( ! base . VisitMethodDecl ( method ) || ! method . IsOverride )
40
- return false ;
41
-
42
- var baseMethod = method . GetRootBaseMethod ( ) ;
43
- if ( ! baseMethod . IsGenerated )
26
+ if ( ! base . VisitMethodDecl ( method ) || ! method . OverriddenMethods . Any ( ) )
44
27
return false ;
45
28
46
- HashSet < Method > overrides ;
47
- if ( basesOverrides . ContainsKey ( baseMethod ) )
48
- overrides = basesOverrides [ baseMethod ] ;
49
- else
50
- overrides = basesOverrides [ baseMethod ] = new HashSet < Method > { baseMethod } ;
51
- overrides . Add ( method ) ;
29
+ var virtuals = new List < Method > ( method . OverriddenMethods ) ;
30
+ virtuals . Add ( method ) ;
31
+ AccessSpecifier access = virtuals . Max ( o => o . Access ) ;
32
+ foreach ( var @virtual in virtuals )
33
+ @virtual . Access = access ;
52
34
53
35
return true ;
54
36
}
55
-
56
- private Dictionary < Method , HashSet < Method > > basesOverrides = new Dictionary < Method , HashSet < Method > > ( ) ;
57
37
}
58
38
}
0 commit comments