Skip to content

Commit ce22a3c

Browse files
committed
Fixed the generated C# when a specialisation of a template used as a secondary base has an invalid function.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 10c8211 commit ce22a3c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/Generator/AST/Utils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using CppSharp.AST.Extensions;
54
using CppSharp.Types;
@@ -20,7 +19,10 @@ public static bool CheckIgnoreFunction(Function function)
2019

2120
public static bool CheckIgnoreMethod(Method method)
2221
{
23-
if (!method.IsGenerated) return true;
22+
var originalClass = method.OriginalNamespace as Class;
23+
if (!method.IsGenerated &&
24+
(originalClass == null || method.IsInternal || !originalClass.IsInterface))
25+
return true;
2426

2527
if (method.IsDependent && UsesAdditionalTypeParam(method))
2628
return true;

src/Generator/Passes/MultipleInheritancePass.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ from b in @base.Bases
102102

103103
@interface.Methods.AddRange(
104104
from m in @base.Methods
105-
where !m.IsConstructor && !m.IsDestructor && !m.IsStatic && m.IsDeclared && !m.IsOperator
105+
where !m.IsConstructor && !m.IsDestructor && !m.IsStatic &&
106+
(m.IsGenerated || (m.IsInvalid && specialization != null)) && !m.IsOperator
106107
select new Method(m) { Namespace = @interface, OriginalFunction = m });
107108

108109
@interface.Properties.AddRange(
@@ -200,11 +201,11 @@ private void ImplementInterfaceMethods(Class @class, Class @interface)
200201
foreach (var method in @interface.Methods.Where(
201202
m => m.SynthKind != FunctionSynthKind.InterfaceDispose))
202203
{
203-
var existingImpl = @class.Methods.FirstOrDefault(
204+
var existingImpl = @class.Methods.Find(
204205
m => m.OriginalName == method.OriginalName &&
205-
m.Parameters.Where(p => !p.Ignore).SequenceEqual(
206-
method.Parameters.Where(p => !p.Ignore),
207-
ParameterTypeComparer.Instance));
206+
m.Parameters.Where(p => !p.Ignore).SequenceEqual(
207+
method.Parameters.Where(p => !p.Ignore),
208+
ParameterTypeComparer.Instance));
208209
if (existingImpl != null)
209210
{
210211
if (existingImpl.OriginalFunction == null)

0 commit comments

Comments
 (0)