summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-08-30 15:44:46 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:08 -0300
commitb55c812e620e4c31c0b4658534c74930124995a4 (patch)
treec2391973f3bf80983ab829778440d9e63c32e295
parentdb29a857e3734f6d36d3d8cd919574a0dd286ad9 (diff)
If a class have a non final method doesn't mean that class is polymorphic.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Ara├║jo <renato.araujo@openbossa.org>
-rw-r--r--abstractmetalang.cpp2
-rw-r--r--tests/testabstractmetaclass.cpp32
-rw-r--r--tests/testabstractmetaclass.h1
3 files changed, 34 insertions, 1 deletions
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index df26dda9..fe6c6b37 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -1283,7 +1283,7 @@ void AbstractMetaClass::setFunctions(const AbstractMetaFunctionList &functions)
f->setOwnerClass(this);
m_hasVirtualSlots = m_hasVirtualSlots || f->isVirtualSlot();
- m_hasVirtuals = m_hasVirtuals || !f->isFinal() || f->isVirtualSlot() || hasVirtualDestructor();
+ m_hasVirtuals = m_hasVirtuals || f->isVirtualSlot() || hasVirtualDestructor();
m_isPolymorphic = m_isPolymorphic || m_hasVirtuals;
m_hasNonpublic = m_hasNonpublic || !f->isPublic();
diff --git a/tests/testabstractmetaclass.cpp b/tests/testabstractmetaclass.cpp
index f412b19c..11e17d98 100644
--- a/tests/testabstractmetaclass.cpp
+++ b/tests/testabstractmetaclass.cpp
@@ -408,6 +408,38 @@ void TestAbstractMetaClass::testObjectTypesMustNotHaveCopyConstructors()
QCOMPARE(ctors.first()->minimalSignature(), QString("A()"));
}
+void TestAbstractMetaClass::testIsPolymorphic()
+{
+ const char* cppCode = "\
+ class A\
+ {\
+ public:\
+ A();\
+ inline bool abc() const {}\
+ };\
+ \
+ class B : public A\
+ {\
+ public:\
+ B();\
+ inline bool abc() const {}\
+ };";
+ const char* xmlCode = "\
+ <typesystem package='Foo'>\
+ <primitive-type name='bool' />\
+ <value-type name='A' />\
+ <value-type name='B' />\
+ </typesystem>";
+
+ TestUtil t(cppCode, xmlCode);
+ AbstractMetaClassList classes = t.builder()->classes();
+ QCOMPARE(classes.count(), 2);
+ AbstractMetaClass* b = classes.findClass("A");
+
+ QVERIFY(!b->isPolymorphic());
+ AbstractMetaClass* a = classes.findClass("B");
+ QVERIFY(!a->isPolymorphic());
+}
QTEST_APPLESS_MAIN(TestAbstractMetaClass)
diff --git a/tests/testabstractmetaclass.h b/tests/testabstractmetaclass.h
index 03b5721a..d725c46e 100644
--- a/tests/testabstractmetaclass.h
+++ b/tests/testabstractmetaclass.h
@@ -42,6 +42,7 @@ private slots:
void testClassInheritedDefaultConstructors();
void testAbstractClassDefaultConstructors();
void testObjectTypesMustNotHaveCopyConstructors();
+ void testIsPolymorphic();
};
#endif // TESTABSTRACTMETACLASS_H