From a12a3e253289f8bea9ef6caee78e875df6e934a5 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Wed, 6 Jul 2016 23:36:37 +0300 Subject: [PATCH] Fixed a naming conflict involving abstract properties. Signed-off-by: Dimitar Dobrev --- .../Passes/GetterSetterToPropertyAdvancedPass.cs | 10 ++++++++++ tests/CSharp/CSharp.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs b/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs index 1dc770bb..628a2ba5 100644 --- a/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs +++ b/src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs @@ -158,6 +158,16 @@ namespace CppSharp.Passes throw new Exception(string.Format( "Property {0} has a base property null but its getter has a generated base method.", getter.QualifiedOriginalName)); + if (baseVirtualProperty != null && !baseVirtualProperty.IsVirtual) + { + // the only way the above can happen is if we are generating properties in abstract implementations + // in which case we can have less naming conflicts since the abstract base can also contain non-virtual properties + if (getter.SynthKind == FunctionSynthKind.AbstractImplCall) + return; + throw new Exception(string.Format( + "Base of property {0} is not virtual while the getter is.", + getter.QualifiedOriginalName)); + } if (baseVirtualProperty != null && baseVirtualProperty.SetMethod == null) setter = null; } diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index ad9ea1ba..01b464de 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -931,3 +931,11 @@ template struct iterator_category_with_traversal : Category, Traversal { }; + + +class HasConflictWithAbstractProperty +{ +public: + int conflictWithProperty(); + virtual int getConflictWithProperty() = 0; +};