lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [11/12] lucy-clownfish git commit: Don't allow inheriting from final class
Date Thu, 10 Mar 2016 13:35:28 GMT
Don't allow inheriting from final class


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/64142fb2
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/64142fb2
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/64142fb2

Branch: refs/heads/master
Commit: 64142fb25442fd7c0fb0b1281f441a1125873f31
Parents: 00efad1
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Mar 5 20:26:27 2016 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Thu Mar 10 14:22:10 2016 +0100

----------------------------------------------------------------------
 compiler/src/CFCClass.c     |  3 +++
 compiler/src/CFCTestClass.c | 21 ++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/64142fb2/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c
index 5e1f795..56edce5 100644
--- a/compiler/src/CFCClass.c
+++ b/compiler/src/CFCClass.c
@@ -474,6 +474,9 @@ CFCClass_add_child(CFCClass *self, CFCClass *child) {
     if (self->tree_grown) {
         CFCUtil_die("Can't call add_child after grow_tree");
     }
+    if (self->is_final) {
+        CFCUtil_die("Can't inherit from final class %s", self->name);
+    }
     if (self->is_inert) {
         CFCUtil_die("Can't inherit from inert class %s", self->name);
     }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/64142fb2/compiler/src/CFCTestClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestClass.c b/compiler/src/CFCTestClass.c
index 8acb300..9fa182c 100644
--- a/compiler/src/CFCTestClass.c
+++ b/compiler/src/CFCTestClass.c
@@ -44,7 +44,7 @@ S_has_symbol(CFCSymbol **symbols, const char *name);
 
 const CFCTestBatch CFCTEST_BATCH_CLASS = {
     "Clownfish::CFC::Model::Class",
-    96,
+    97,
     S_run_tests
 };
 
@@ -211,6 +211,25 @@ S_run_tests(CFCTest *test) {
 
     CFCClass_add_child(foo, foo_jr);
     CFCClass_add_child(foo_jr, final_foo);
+
+    {
+        CFCClass *bar
+            = CFCClass_create(neato, NULL, "Foo::FooJr::FinalFoo::Bar", NULL,
+                              NULL, NULL, "Foo::FooJr::FinalFoo", false, false,
+                              false);
+        char *error;
+
+        CFCUTIL_TRY {
+            CFCClass_add_child(final_foo, bar);
+        }
+        CFCUTIL_CATCH(error);
+        OK(test, error && strstr(error, "final class"),
+           "Can't add_child to final class");
+
+        FREEMEM(error);
+        CFCBase_decref((CFCBase*)bar);
+    }
+
     CFCClass_grow_tree(foo);
 
     {


Mime
View raw message