Skip to content

Commit 0e0513f

Browse files
committed
Fix regressed overloaded potential setters
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
1 parent 51978ad commit 0e0513f

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/Generator/Passes/GetterSetterToPropertyPass.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private static Property GetProperty(Method method, string name,
138138
Class @class = (Class) method.Namespace;
139139
Property property = @class.Properties.Find(
140140
p => p.Field == null &&
141-
(p.Name == name ||
141+
((!isSetter && p.HasSetter && p.Name == name) ||
142142
(isSetter && p.HasGetter &&
143143
GetReadWritePropertyName(p.GetMethod, name) == name)) &&
144144
((p.HasGetter &&
@@ -189,6 +189,15 @@ private static void ProcessProperties(Class @class, IEnumerable<Property> newPro
189189
continue;
190190
}
191191

192+
Property conflict = newProperties.LastOrDefault(
193+
p => p.Name == property.Name && p != property &&
194+
p.ExplicitInterfaceImpl == property.ExplicitInterfaceImpl);
195+
if (conflict != null && conflict.GetMethod != null)
196+
{
197+
conflict.GetMethod.GenerationKind = GenerationKind.Generate;
198+
conflict.GetMethod = null;
199+
}
200+
192201
RenameConflictingMethods(@class, property);
193202
CombineComments(property);
194203
}

tests/Common/Common.Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ public void TestProperties()
527527

528528
Assert.That(prop.StartWithVerb, Is.EqualTo(25));
529529
prop.StartWithVerb = 5;
530+
531+
Assert.That(prop.Contains('a'), Is.EqualTo(prop.Contains1("a")));
530532
}
531533
using (var prop = new HasOverridenSetter())
532534
{

tests/Common/Common.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,16 @@ void TestProperties::setStartWithVerb(int value)
642642
{
643643
}
644644

645+
bool TestProperties::contains(char c)
646+
{
647+
return true;
648+
}
649+
650+
bool TestProperties::contains(const char* str)
651+
{
652+
return true;
653+
}
654+
645655
HasOverridenSetter::HasOverridenSetter()
646656
{
647657
}

tests/Common/Common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ struct DLL_API TestProperties
619619

620620
int startWithVerb();
621621
void setStartWithVerb(int value);
622+
623+
bool contains(char c);
624+
bool contains(const char* str);
622625
private:
623626
int FieldValue;
624627
double _refToPrimitiveInSetter;

0 commit comments

Comments
 (0)