Skip to content

Commit bac28ab

Browse files
atsushienojonpryor
authored andcommitted
[generator] Do not emit static properties as instance. (#159)
Without this, abstract classes that implement `java.time.chrono.Chronology` fail to bind because they will try to implement those static properties as instance (this check had been done for methods, but not for properties).
1 parent 3343634 commit bac28ab

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tools/generator/InterfaceGen.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void GenExtensionMethods (StreamWriter sw, string indent, CodeGenerationOptions
214214

215215
void GenProperties (StreamWriter sw, string indent, CodeGenerationOptions opt)
216216
{
217-
foreach (Property prop in Properties)
217+
foreach (Property prop in Properties.Where (p => !p.Getter.IsStatic))
218218
prop.GenerateDeclaration (sw, indent, opt, this, AssemblyQualifiedName + "Invoker");
219219
}
220220

@@ -256,22 +256,22 @@ void GenerateInvoker (StreamWriter sw, string indent, CodeGenerationOptions opt)
256256
sw.WriteLine ();
257257

258258
HashSet<string> members = new HashSet<string> ();
259-
GenerateInvoker (sw, Properties, indent + "\t", opt, members);
260-
GenerateInvoker (sw, Methods, indent + "\t", opt, members);
259+
GenerateInvoker (sw, Properties.Where (p => !p.Getter.IsStatic), indent + "\t", opt, members);
260+
GenerateInvoker (sw, Methods.Where (m => !m.IsStatic), indent + "\t", opt, members);
261261
if (FullName == "Java.Lang.ICharSequence")
262262
GenCharSequenceEnumerator (sw, indent + "\t", opt);
263263

264264
foreach (InterfaceGen iface in GetAllDerivedInterfaces ()) {
265-
GenerateInvoker (sw, iface.Properties, indent + "\t", opt, members);
266-
GenerateInvoker (sw, iface.Methods.Where (m => !IsCovariantMethod (m) && !(iface.FullName.StartsWith ("Java.Lang.ICharSequence") && m.Name.EndsWith ("Formatted"))), indent + "\t", opt, members);
265+
GenerateInvoker (sw, iface.Properties.Where (p => !p.Getter.IsStatic), indent + "\t", opt, members);
266+
GenerateInvoker (sw, iface.Methods.Where (m => !m.IsStatic && !IsCovariantMethod (m) && !(iface.FullName.StartsWith ("Java.Lang.ICharSequence") && m.Name.EndsWith ("Formatted"))), indent + "\t", opt, members);
267267
if (iface.FullName == "Java.Lang.ICharSequence")
268268
GenCharSequenceEnumerator (sw, indent + "\t", opt);
269269
}
270270
sw.WriteLine ("{0}}}", indent);
271271
sw.WriteLine ();
272272
}
273273

274-
void GenerateInvoker (StreamWriter sw, List<Property> properties, string indent, CodeGenerationOptions opt, HashSet<string> members)
274+
void GenerateInvoker (StreamWriter sw, IEnumerable<Property> properties, string indent, CodeGenerationOptions opt, HashSet<string> members)
275275
{
276276
foreach (Property prop in properties) {
277277
if (members.Contains (prop.Name))
@@ -635,7 +635,7 @@ public void GenerateAbstractMembers (ClassGen gen, StreamWriter sw, string inden
635635
m.GenerateAbstractDeclaration (sw, indent, opt, this, gen);
636636
opt.ContextGeneratedMethods.Add (m);
637637
}
638-
foreach (Property prop in Properties) {
638+
foreach (Property prop in Properties.Where (p => !p.Getter.IsStatic)) {
639639
if (gen.ContainsProperty (prop.Name, false))
640640
continue;
641641
prop.GenerateAbstractDeclaration (sw, indent, opt, gen);

0 commit comments

Comments
 (0)