Skip to content

Commit e5d79e9

Browse files
committed
Skip attaching field accessor if a method with the same name already exists on the object. (Albeit a bit inefficiently).
1 parent 4996800 commit e5d79e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/generation/base_type_generator.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ export abstract class BaseTypeGenerator<Type extends RustType> {
127127
accessorName = Generator.snakeCaseToCamelCase(field.contextualName);
128128
}
129129

130+
const methodNames = [];
131+
for (const currentMethod of containerType.methods) {
132+
const swiftMethodName = this.swiftMethodName(currentMethod, containerType);
133+
methodNames.push(swiftMethodName);
134+
}
135+
136+
if (methodNames.includes(accessorName)) {
137+
console.log('Presumptive redundant accessor:', accessorName);
138+
return '';
139+
}
140+
130141
const swiftReturnType = this.getPublicTypeSignature(field.type, containerType);
131142
const fieldAccessor = `self.cType!.${field.contextualName}`;
132143
const preparedReturnValue = this.prepareRustReturnValueForSwift(field, containerType);

0 commit comments

Comments
 (0)