commit 0504240e7411c04a879255b26c4b12920a3e55c0
Author: Severin Heiniger <severinheiniger@gmail.com>
Date:   Sun Sep 1 01:58:53 2013 +0200

    Allow underscores in type parameter names. Fixes #644938.

diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index fe9de20..483c46f 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -75,12 +75,16 @@ public class Vala.GObjectModule : GTypeModule {
 
 		/* create type, dup_func, and destroy_func properties for generic types */
 		foreach (TypeParameter type_param in cl.get_type_parameters ()) {
-			string func_name, enum_value;
+			string prop_name_prefix, func_name, enum_value;
 			CCodeConstant func_name_constant;
 			CCodeFunctionCall cinst, cspec;
 
+			// underscores are the only characters allowed in Vala identifiers
+			// but not in GObject property names
+			prop_name_prefix = type_param.name.down ().replace ("_", "-");
+
 			func_name = "%s_type".printf (type_param.name.down ());
-			func_name_constant = new CCodeConstant ("\"%s-type\"".printf (type_param.name.down ()));
+			func_name_constant = new CCodeConstant ("\"%s-type\"".printf (prop_name_prefix));
 			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 			cinst.add_argument (ccall);
@@ -97,7 +101,7 @@ public class Vala.GObjectModule : GTypeModule {
 
 
 			func_name = "%s_dup_func".printf (type_param.name.down ());
-			func_name_constant = new CCodeConstant ("\"%s-dup-func\"".printf (type_param.name.down ()));
+			func_name_constant = new CCodeConstant ("\"%s-dup-func\"".printf (prop_name_prefix));
 			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 			cinst.add_argument (ccall);
@@ -113,7 +117,7 @@ public class Vala.GObjectModule : GTypeModule {
 
 
 			func_name = "%s_destroy_func".printf (type_param.name.down ());
-			func_name_constant = new CCodeConstant ("\"%s-destroy-func\"".printf (type_param.name.down ()));
+			func_name_constant = new CCodeConstant ("\"%s-destroy-func\"".printf (prop_name_prefix));
 			enum_value = "%s_%s".printf (get_ccode_lower_case_name (cl, null), func_name).up ();
 			cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 			cinst.add_argument (ccall);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b84ee04..9937bd5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -128,6 +128,7 @@ TESTS = \
 	objects/bug634782.vala \
 	objects/bug642809.vala \
 	objects/bug643711.vala \
+	objects/bug644938.vala \
 	objects/bug646362.vala \
 	objects/bug646792.vala \
 	objects/bug653138.vala \
diff --git a/tests/objects/bug644938.vala b/tests/objects/bug644938.vala
new file mode 100644
index 0000000..7434f10
--- /dev/null
+++ b/tests/objects/bug644938.vala
@@ -0,0 +1,14 @@
+// Assert that type parameter names may contain underscores
+
+public abstract class Foo<TYPE_PARAMETER_NAME_WITH_UNDERSCORES> : Object {
+	public abstract void method(TYPE_PARAMETER_NAME_WITH_UNDERSCORES o);
+}
+
+public class Bar : Foo<int> {
+	public override void method(int i) {
+	}
+}
+
+void main () {
+	new Bar();
+}
\ No newline at end of file
