vala r1530 - in trunk: . vala



Author: juergbi
Date: Sun Jun  1 15:44:30 2008
New Revision: 1530
URL: http://svn.gnome.org/viewvc/vala?rev=1530&view=rev

Log:
2008-06-01  JÃrg Billeter  <j bitron ch>

	* vala/valadelegate.vala:
	* vala/valasemanticanalyzer.vala:

	Improve error message for incompatible signal handlers,
	fixes bug 535953


Modified:
   trunk/ChangeLog
   trunk/vala/valadelegate.vala
   trunk/vala/valasemanticanalyzer.vala

Modified: trunk/vala/valadelegate.vala
==============================================================================
--- trunk/vala/valadelegate.vala	(original)
+++ trunk/vala/valadelegate.vala	Sun Jun  1 15:44:30 2008
@@ -281,4 +281,52 @@
 			return_type = new_type;
 		}
 	}
+
+	public string get_prototype_string (string name) {
+		return "%s %s %s".printf (get_return_type_string (), name, get_parameters_string ());
+	}
+
+	string get_return_type_string () {
+		string str = "";
+		if (!return_type.value_owned && return_type is ReferenceType) {
+			str = "weak ";
+		}
+		str += return_type.to_string ();
+
+		return str;
+	}
+
+	string get_parameters_string () {
+		string str = "(";
+
+		int i = 1;
+		foreach (FormalParameter param in parameters) {
+			if (i > 1) {
+				str += ", ";
+			}
+
+			if (param.direction != ParameterDirection.IN) {
+				if (param.direction == ParameterDirection.REF) {
+					str += "ref ";
+				} else if (param.direction == ParameterDirection.OUT) {
+					str += "out ";
+				}
+				if (!param.parameter_type.value_owned && param.parameter_type is ReferenceType) {
+					str += "weak ";
+				}
+			}
+
+			str += param.parameter_type.to_string ();
+
+			if (param.direction == ParameterDirection.IN && param.parameter_type.value_owned) {
+				str += "#";
+			}
+
+			i++;
+		}
+
+		str += ")";
+
+		return str;
+	}
 }

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Sun Jun  1 15:44:30 2008
@@ -3271,8 +3271,10 @@
 					}
 					a.right.target_type = new DelegateType (sig.get_delegate (new ObjectType ((ObjectTypeSymbol) sig.parent_symbol)));
 				} else if (!a.right.value_type.compatible (a.right.target_type)) {
+					var delegate_type = (DelegateType) a.right.target_type;
+
 					a.error = true;
-					Report.error (a.right.source_reference, "method `%s' is incompatible with signal `%s'".printf (a.right.value_type.to_string (), a.right.target_type.to_string ()));
+					Report.error (a.right.source_reference, "method `%s' is incompatible with signal `%s', expected `%s'".printf (a.right.value_type.to_string (), a.right.target_type.to_string (), delegate_type.delegate_symbol.get_prototype_string (m.name)));
 					return;
 				}
 			} else if (ma.symbol_reference is Property) {



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