[vala] Genie: Report error on duplicate constructor or destructor in class



commit fd302f141029546cb2a544803f8dc58caae07870
Author: Jamie McCracken <jamie.mccrack gmail com>
Date:   Mon May 24 14:33:09 2010 -0400

    Genie: Report error on duplicate constructor or destructor in class

 vala/valagenieparser.vala |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 76e057e..a1305ea 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -2627,21 +2627,41 @@ public class Vala.Genie.Parser : CodeVisitor {
 		} else if (sym is Constructor) {
 			var c = (Constructor) sym;
 			if (c.binding == MemberBinding.INSTANCE) {
+				if (cl.constructor != null) {
+					Report.error (c.source_reference, "class already contains a constructor");
+				}
 				cl.constructor = c;
-			 } else if (c.binding == MemberBinding.CLASS) {
+			} else if (c.binding == MemberBinding.CLASS) {
+				if (cl.class_constructor != null) {
+					Report.error (c.source_reference, "class already contains a class constructor");
+				}
 				cl.class_constructor = c;
-			 } else {
-			 	cl.static_constructor = c;
-			 }
+			} else {
+				if (cl.static_constructor != null) {
+					Report.error (c.source_reference, "class already contains a static constructor");
+				}
+				cl.static_constructor = c;
+			}
+
 		} else if (sym is Destructor) {
 			var d = (Destructor) sym;
 			if (d.binding == MemberBinding.STATIC) {
+				if (cl.static_destructor != null) {
+					Report.error (d.source_reference, "class already contains a static destructor");
+				}
 				cl.static_destructor = (Destructor) d;
 			} else if (d.binding == MemberBinding.CLASS) {
+				if (cl.class_destructor != null) {
+					Report.error (d.source_reference, "class already contains a class destructor");
+				}
 				cl.class_destructor = (Destructor) d;
 			} else {
+				if (cl.destructor != null) {
+					Report.error (d.source_reference, "class already contains a destructor");
+				}
 				cl.destructor = (Destructor) d;
 			}
+
 		} else {
 			Report.error (sym.source_reference, "unexpected declaration in class");
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]