[vala] Report error when number of type arguments does not match



commit 53152c0274de23148810a3b2d4686e4d69948119
Author: Jürg Billeter <j bitron ch>
Date:   Sun Mar 21 11:08:26 2010 +0100

    Report error when number of type arguments does not match

 vala/valaobjecttype.vala |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaobjecttype.vala b/vala/valaobjecttype.vala
index e4556e5..bffc280 100644
--- a/vala/valaobjecttype.vala
+++ b/vala/valaobjecttype.vala
@@ -1,6 +1,6 @@
 /* valaobjecttype.vala
  *
- * Copyright (C) 2007-2008  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -100,6 +100,19 @@ public class Vala.ObjectType : ReferenceType {
 	}
 
 	public override bool check (SemanticAnalyzer analyzer) {
-		return type_symbol.check (analyzer);
+		if (!type_symbol.check (analyzer)) {
+			return false;
+		}
+
+		int n_type_args = get_type_arguments ().size;
+		if (n_type_args > 0 && n_type_args < type_symbol.get_type_parameters ().size) {
+			Report.error (source_reference, "too few type arguments");
+			return false;
+		} else if (n_type_args > 0 && n_type_args > type_symbol.get_type_parameters ().size) {
+			Report.error (source_reference, "too many type arguments");
+			return false;
+		}
+
+		return true;
 	}
 }



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