Skip to content

Commit

Permalink
Check if all overloads actually exist before gathering them for inter…
Browse files Browse the repository at this point in the history
…nal function processing.
  • Loading branch information
tritao committed Aug 4, 2013
1 parent 85e6c9e commit 7dacbce
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/Generator/Generators/CSharp/CSharpTextTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,30 @@ public void GenerateClassInternals(Class @class)
PopBlock(NewLineKind.BeforeNextBlock);
}

private static HashSet<Function> GatherClassInternalFunctions(Class @class)
private static ISet<Function> GatherClassInternalFunctions(Class @class)
{
var functions = new HashSet<Function>();

Action<Method> tryAddOverload = method =>
{
if (method.IsSynthetized)
return;

if (method.IsPure)
return;

if (method.IsProxy)
return;

functions.Add(method);
};

foreach (var ctor in @class.Constructors)
{
if (ctor.IsCopyConstructor || ctor.IsMoveConstructor)
continue;

if (ctor.IsPure)
continue;

functions.Add(ctor);
tryAddOverload(ctor);
}

foreach (var method in @class.Methods)
Expand All @@ -390,23 +401,18 @@ private static HashSet<Function> GatherClassInternalFunctions(Class @class)
if (method.IsConstructor)
continue;

if (method.IsSynthetized)
continue;

if (method.IsPure)
continue;

functions.Add(method);
tryAddOverload(method);
}

foreach (var prop in @class.Properties)
{
if (prop.GetMethod != null)
functions.Add(prop.GetMethod);
tryAddOverload(prop.GetMethod);

if (prop.SetMethod != null)
functions.Add(prop.SetMethod);
tryAddOverload(prop.SetMethod);
}

return functions;
}

Expand Down

0 comments on commit 7dacbce

Please sign in to comment.